diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2003-07-10 03:05:13 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2003-07-10 03:05:13 +0800 |
commit | 2bd47d3cda52acc0beb688ffb4a8202412de5c09 (patch) | |
tree | 66b1a9f93e8b5bfdeb8c9350bda05f98d3e7eeca /camel | |
parent | 16ce509ec02a99acf7324c4e157cf1cf781a8a67 (diff) | |
download | gsoc2013-evolution-2bd47d3cda52acc0beb688ffb4a8202412de5c09.tar.gz gsoc2013-evolution-2bd47d3cda52acc0beb688ffb4a8202412de5c09.tar.zst gsoc2013-evolution-2bd47d3cda52acc0beb688ffb4a8202412de5c09.zip |
Get rid of the #ifdef ENABLE_THREADS since we no longer plan to
2003-07-09 Jeffrey Stedfast <fejj@ximian.com>
* camel-block-file.c: Get rid of the #ifdef ENABLE_THREADS since
we no longer plan to support/maintain this.
* camel.c: Same.
* camel-certdb.c: Here too.
* camel-charset-map.c: And here.
* camel-cipher-context.c: "
* camel-data-wrapper.c: "
* camel-digest-folder.c: "
* camel-exception.c: "
* camel-folder.c: "
* camel-folder-summary.c: "
* camel-lock-client.c: "
* camel-mime-utils.c: "
* camel-object.c: "
* camel-operation.c: "
* camel-partition-table.c: "
* camel-sasl-popb4smtp.c: "
* camel-service.c: "
* camel-session.c: "
* camel-store.c: "
* camel-store-summary.c: "
* camel-text-index.c: "
* camel-transport.c: "
* camel-vee-folder.c: "
* camel-tcp-stream-openssl.c: Removed pthread.h, it isn't needed.
svn path=/trunk/; revision=21777
Diffstat (limited to 'camel')
28 files changed, 353 insertions, 596 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 2185e1cb90..3c6a648b93 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,54 @@ +2003-07-09 Jeffrey Stedfast <fejj@ximian.com> + + * camel-block-file.c: Get rid of the #ifdef ENABLE_THREADS since + we no longer plan to support/maintain this. + + * camel.c: Same. + + * camel-certdb.c: Here too. + + * camel-charset-map.c: And here. + + * camel-cipher-context.c: " + + * camel-data-wrapper.c: " + + * camel-digest-folder.c: " + + * camel-exception.c: " + + * camel-folder.c: " + + * camel-folder-summary.c: " + + * camel-lock-client.c: " + + * camel-mime-utils.c: " + + * camel-object.c: " + + * camel-operation.c: " + + * camel-partition-table.c: " + + * camel-sasl-popb4smtp.c: " + + * camel-service.c: " + + * camel-session.c: " + + * camel-store.c: " + + * camel-store-summary.c: " + + * camel-text-index.c: " + + * camel-transport.c: " + + * camel-vee-folder.c: " + + * camel-tcp-stream-openssl.c: Removed pthread.h, it isn't needed. + 2003-07-09 Larry Ewing <lewing@ximian.com> * camel.h: remove reference to camel-pgp-mime.h diff --git a/camel/camel-block-file.c b/camel/camel-block-file.c index de7d757367..bf444ca403 100644 --- a/camel/camel-block-file.c +++ b/camel/camel-block-file.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Copyright (C) 2001-2003 Ximian Inc. * @@ -22,25 +23,20 @@ #include <config.h> #endif -#include <sys/stat.h> -#include <sys/uio.h> -#include <unistd.h> -#include <errno.h> -#include <string.h> #include <stdlib.h> - +#include <string.h> #include <sys/types.h> #include <sys/stat.h> +#include <sys/uio.h> +#include <pthread.h> +#include <unistd.h> #include <fcntl.h> +#include <errno.h> #include "e-util/e-msgport.h" #include "camel-block-file.h" -#ifdef ENABLE_THREADS -#include <pthread.h> -#endif - #define d(x) /*(printf("%s(%d):%s: ", __FILE__, __LINE__, __PRETTY_FUNCTION__),(x))*/ /* Locks must be obtained in the order defined */ @@ -51,16 +47,15 @@ struct _CamelBlockFilePrivate { struct _CamelBlockFilePrivate *prev; struct _CamelBlockFile *base; - -#ifdef ENABLE_THREADS + pthread_mutex_t root_lock; /* for modifying the root block */ pthread_mutex_t cache_lock; /* for refcounting, flag manip, cache manip */ pthread_mutex_t io_lock; /* for all io ops */ -#endif + unsigned int deleted:1; }; -#ifdef ENABLE_THREADS + #define CAMEL_BLOCK_FILE_LOCK(kf, lock) (pthread_mutex_lock(&(kf)->priv->lock)) #define CAMEL_BLOCK_FILE_TRYLOCK(kf, lock) (pthread_mutex_trylock(&(kf)->priv->lock)) #define CAMEL_BLOCK_FILE_UNLOCK(kf, lock) (pthread_mutex_unlock(&(kf)->priv->lock)) @@ -70,14 +65,6 @@ struct _CamelBlockFilePrivate { static pthread_mutex_t block_file_lock = PTHREAD_MUTEX_INITIALIZER; -#else -#define CAMEL_BLOCK_FILE_LOCK(kf, lock) -#define CAMEL_BLOCK_FILE_TRYLOCK(kf, lock) -#define CAMEL_BLOCK_FILE_UNLOCK(kf, lock) -#define LOCK(x) -#define UNLOCK(x) -#endif - /* lru cache of block files */ static EDList block_file_list = E_DLIST_INITIALISER(block_file_list); /* list to store block files that are actually intialised */ @@ -180,13 +167,11 @@ camel_block_file_init(CamelBlockFile *bs) p = bs->priv = g_malloc0(sizeof(*bs->priv)); p->base = bs; - -#ifdef ENABLE_THREADS + pthread_mutex_init(&p->root_lock, NULL); pthread_mutex_init(&p->cache_lock, NULL); pthread_mutex_init(&p->io_lock, NULL); -#endif - + /* link into lru list */ LOCK(block_file_lock); e_dlist_addhead(&block_file_list, (EDListNode *)p); @@ -241,12 +226,11 @@ camel_block_file_finalise(CamelBlockFile *bs) g_free(bs->path); if (bs->fd != -1) close(bs->fd); - -#ifdef ENABLE_THREADS + pthread_mutex_destroy(&p->io_lock); pthread_mutex_destroy(&p->cache_lock); pthread_mutex_destroy(&p->root_lock); -#endif + g_free(p); } @@ -811,25 +795,16 @@ struct _CamelKeyFilePrivate { struct _CamelKeyFilePrivate *prev; struct _CamelKeyFile *base; -#ifdef ENABLE_THREADS pthread_mutex_t lock; -#endif unsigned int deleted:1; }; -#ifdef ENABLE_THREADS #define CAMEL_KEY_FILE_LOCK(kf, lock) (pthread_mutex_lock(&(kf)->priv->lock)) #define CAMEL_KEY_FILE_TRYLOCK(kf, lock) (pthread_mutex_trylock(&(kf)->priv->lock)) #define CAMEL_KEY_FILE_UNLOCK(kf, lock) (pthread_mutex_unlock(&(kf)->priv->lock)) static pthread_mutex_t key_file_lock = PTHREAD_MUTEX_INITIALIZER; -#else -#define CAMEL_KEY_FILE_LOCK(kf, lock) -#define CAMEL_KEY_FILE_TRYLOCK(kf, lock) -#define CAMEL_KEY_FILE_UNLOCK(kf, lock) -#endif - /* lru cache of block files */ static EDList key_file_list = E_DLIST_INITIALISER(key_file_list); static EDList key_file_active_list = E_DLIST_INITIALISER(key_file_active_list); @@ -848,11 +823,9 @@ camel_key_file_init(CamelKeyFile *bs) p = bs->priv = g_malloc0(sizeof(*bs->priv)); p->base = bs; - -#ifdef ENABLE_THREADS + pthread_mutex_init(&p->lock, NULL); -#endif - + LOCK(key_file_lock); e_dlist_addhead(&key_file_list, (EDListNode *)p); UNLOCK(key_file_lock); @@ -874,11 +847,9 @@ camel_key_file_finalise(CamelKeyFile *bs) UNLOCK(key_file_lock); g_free(bs->path); - -#ifdef ENABLE_THREADS + pthread_mutex_destroy(&p->lock); -#endif - + g_free(p); } diff --git a/camel/camel-certdb.c b/camel/camel-certdb.c index 7f944f8fcd..8df6f2e578 100644 --- a/camel/camel-certdb.c +++ b/camel/camel-certdb.c @@ -2,7 +2,7 @@ /* * Authors: Jeffrey Stedfast <fejj@ximian.com> * - * Copyright 2002 Ximian, Inc. (www.ximian.com) + * Copyright 2002-2003 Ximian, Inc. (www.ximian.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -117,12 +117,10 @@ camel_certdb_init (CamelCertDB *certdb) certdb->certs = g_ptr_array_new (); certdb->cert_hash = g_hash_table_new (g_str_hash, g_str_equal); -#ifdef ENABLE_THREADS certdb->priv->db_lock = g_mutex_new (); certdb->priv->io_lock = g_mutex_new (); certdb->priv->alloc_lock = g_mutex_new (); certdb->priv->ref_lock = g_mutex_new (); -#endif } static void @@ -145,12 +143,10 @@ camel_certdb_finalize (CamelObject *obj) if (certdb->cert_chunks) e_memchunk_destroy (certdb->cert_chunks); -#ifdef ENABLE_THREADS g_mutex_free (p->db_lock); g_mutex_free (p->io_lock); g_mutex_free (p->alloc_lock); g_mutex_free (p->ref_lock); -#endif g_free (p); } diff --git a/camel/camel-charset-map.c b/camel/camel-charset-map.c index 0066bfcaee..9bd4f4e253 100644 --- a/camel/camel-charset-map.c +++ b/camel/camel-charset-map.c @@ -5,7 +5,7 @@ * Jeffrey Stedfast <fejj@ximian.com> * Dan Winship <danw@ximian.com> * - * Copyright 2000, 2003 Ximian, Inc. (www.ximian.com) + * Copyright 2000-2003 Ximian, Inc. (www.ximian.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -204,12 +204,9 @@ int main (void) #include "camel-charset-map-private.h" #include <glib.h> -#include <glib/gunicode.h> #include <locale.h> #include <ctype.h> -#ifdef ENABLE_THREADS #include <pthread.h> -#endif #ifdef HAVE_CODESET #include <langinfo.h> #endif @@ -217,7 +214,7 @@ int main (void) void camel_charset_init (CamelCharset *c) { - c->mask = ~0; + c->mask = (unsigned int) ~0; c->level = 0; } diff --git a/camel/camel-charset-map.h b/camel/camel-charset-map.h index b0a47615ca..cd627ee488 100644 --- a/camel/camel-charset-map.h +++ b/camel/camel-charset-map.h @@ -1,5 +1,6 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - * Copyright (C) 2000 Ximian Inc. + * Copyright (C) 2000-2003 Ximian Inc. * * Authors: Michael Zucchi <notzed@ximian.com> * @@ -26,8 +27,6 @@ extern "C" { #pragma } #endif /* __cplusplus */ -#include <iconv.h> - typedef struct _CamelCharset CamelCharset; struct _CamelCharset { diff --git a/camel/camel-cipher-context.c b/camel/camel-cipher-context.c index c495a6479c..ccec652863 100644 --- a/camel/camel-cipher-context.c +++ b/camel/camel-cipher-context.c @@ -2,7 +2,7 @@ /* * Authors: Jeffrey Stedfast <fejj@ximian.com> * - * Copyright 2001 Ximian, Inc. (www.ximian.com) + * Copyright 2001-2003 Ximian, Inc. (www.ximian.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -24,27 +24,20 @@ #include <config.h> #endif -#include "camel-cipher-context.h" - #include <glib.h> - -#ifdef ENABLE_THREADS #include <pthread.h> + +#include "camel-cipher-context.h" + #define CIPHER_LOCK(ctx) g_mutex_lock (((CamelCipherContext *) ctx)->priv->lock) #define CIPHER_UNLOCK(ctx) g_mutex_unlock (((CamelCipherContext *) ctx)->priv->lock); -#else -#define CIPHER_LOCK(ctx) -#define CIPHER_UNLOCK(ctx) -#endif #define d(x) #define CCC_CLASS(o) CAMEL_CIPHER_CONTEXT_CLASS(CAMEL_OBJECT_GET_CLASS(o)) struct _CamelCipherContextPrivate { -#ifdef ENABLE_THREADS GMutex *lock; -#endif }; static const char *cipher_hash_to_id (CamelCipherContext *context, CamelCipherHash hash); @@ -66,16 +59,14 @@ static int cipher_export_keys (CamelCipherContext *context, GPtrArr CamelStream *ostream, CamelException *ex); -static CamelObjectClass *parent_class; +static CamelObjectClass *parent_class = NULL; static void camel_cipher_context_init (CamelCipherContext *context) { context->priv = g_new0 (struct _CamelCipherContextPrivate, 1); -#ifdef ENABLE_THREADS context->priv->lock = g_mutex_new (); -#endif } static void @@ -85,9 +76,7 @@ camel_cipher_context_finalise (CamelObject *o) camel_object_unref (CAMEL_OBJECT (context->session)); -#ifdef ENABLE_THREADS g_mutex_free (context->priv->lock); -#endif g_free (context->priv); } diff --git a/camel/camel-data-wrapper.c b/camel/camel-data-wrapper.c index e1d27896a4..7f9625d19b 100644 --- a/camel/camel-data-wrapper.c +++ b/camel/camel-data-wrapper.c @@ -1,11 +1,9 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; -*- */ -/* camel-data-wrapper.c : Abstract class for a data_wrapper */ - /* * * Authors: Bertrand Guiheneuf <bertrand@helixcode.com> * - * Copyright 1999, 2000 Ximian, Inc. (www.ximian.com) + * Copyright 1999-2003 Ximian, Inc. (www.ximian.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -22,6 +20,7 @@ * USA */ + #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -70,9 +69,7 @@ camel_data_wrapper_init (gpointer object, gpointer klass) CamelDataWrapper *camel_data_wrapper = CAMEL_DATA_WRAPPER (object); camel_data_wrapper->priv = g_malloc (sizeof (struct _CamelDataWrapperPrivate)); -#ifdef ENABLE_THREADS pthread_mutex_init (&camel_data_wrapper->priv->stream_lock, NULL); -#endif camel_data_wrapper->mime_type = header_content_type_new ("application", "octet-stream"); camel_data_wrapper->offline = FALSE; @@ -84,9 +81,8 @@ camel_data_wrapper_finalize (CamelObject *object) { CamelDataWrapper *camel_data_wrapper = CAMEL_DATA_WRAPPER (object); -#ifdef ENABLE_THREADS pthread_mutex_destroy (&camel_data_wrapper->priv->stream_lock); -#endif + g_free (camel_data_wrapper->priv); if (camel_data_wrapper->mime_type) diff --git a/camel/camel-digest-folder.c b/camel/camel-digest-folder.c index 070e5aed3b..21a4071036 100644 --- a/camel/camel-digest-folder.c +++ b/camel/camel-digest-folder.c @@ -2,7 +2,7 @@ /* * Authors: Jeffrey Stedfast <fejj@ximian.com> * - * Copyright 2001 Ximian, Inc. (www.ximian.com) + * Copyright 2001-2003 Ximian, Inc. (www.ximian.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -39,18 +39,11 @@ struct _CamelDigestFolderPrivate { CamelMimeMessage *message; CamelFolderSearch *search; -#ifdef ENABLE_THREADS GMutex *search_lock; -#endif }; -#ifdef ENABLE_THREADS #define CAMEL_DIGEST_FOLDER_LOCK(f, l) (g_mutex_lock(((CamelDigestFolder *)f)->priv->l)) #define CAMEL_DIGEST_FOLDER_UNLOCK(f, l) (g_mutex_unlock(((CamelDigestFolder *)f)->priv->l)) -#else -#define CAMEL_DIGEST_FOLDER_LOCK(f, l) -#define CAMEL_DIGEST_FOLDER_UNLOCK(f, l) -#endif static CamelFolderClass *parent_class = NULL; @@ -113,12 +106,10 @@ camel_digest_folder_init (gpointer object, gpointer klass) digest_folder->priv = g_new (struct _CamelDigestFolderPrivate, 1); digest_folder->priv->message = NULL; digest_folder->priv->search = NULL; -#ifdef ENABLE_THREADS digest_folder->priv->search_lock = g_mutex_new (); -#endif } -static void +static void digest_finalize (CamelObject *object) { CamelDigestFolder *digest_folder = CAMEL_DIGEST_FOLDER (object); @@ -134,9 +125,7 @@ digest_finalize (CamelObject *object) if (digest_folder->priv->search) camel_object_unref (CAMEL_OBJECT (digest_folder->priv->search)); -#ifdef ENABLE_THREADS g_mutex_free (digest_folder->priv->search_lock); -#endif g_free (digest_folder->priv); } diff --git a/camel/camel-exception.c b/camel/camel-exception.c index 1bb6c22550..95e376624a 100644 --- a/camel/camel-exception.c +++ b/camel/camel-exception.c @@ -1,12 +1,10 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* camel-execpetion.c : exception utils */ - /* * * Author : * Bertrand Guiheneuf <bertrand@helixcode.com> * - * Copyright 1999, 2000 Ximian, Inc. (www.ximian.com) + * Copyright 1999-2003 Ximian, Inc. (www.ximian.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -28,6 +26,8 @@ #endif #include <glib.h> +#include <pthread.h> + #include "camel-exception.h" #include "e-util/e-memory.h" @@ -35,17 +35,10 @@ /* also, i'm not convinced mutexes are needed here. But it doesn't really hurt either */ -#ifdef ENABLE_THREADS -#include <pthread.h> - static pthread_mutex_t exception_mutex = PTHREAD_MUTEX_INITIALIZER; #define CAMEL_EXCEPTION_LOCK(e) (pthread_mutex_lock(&exception_mutex)) #define CAMEL_EXCEPTION_UNLOCK(e) (pthread_mutex_unlock(&exception_mutex)) -#else -#define CAMEL_EXCEPTION_LOCK(e) -#define CAMEL_EXCEPTION_UNLOCK(e) -#endif static EMemChunk *exception_chunks = NULL; diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c index b85b8e77ce..6f1fcabaa9 100644 --- a/camel/camel-folder-summary.c +++ b/camel/camel-folder-summary.c @@ -23,15 +23,15 @@ #include <config.h> #endif +#include <stdlib.h> +#include <string.h> #include <sys/types.h> #include <sys/stat.h> -#include <fcntl.h> - +#include <pthread.h> #include <unistd.h> -#include <ctype.h> -#include <string.h> +#include <fcntl.h> #include <errno.h> -#include <stdlib.h> +#include <ctype.h> #include <gal/util/e-iconv.h> @@ -57,18 +57,13 @@ #include "camel-private.h" -#ifdef ENABLE_THREADS -#include <pthread.h> static pthread_mutex_t info_lock = PTHREAD_MUTEX_INITIALIZER; /* this lock is ONLY for the standalone messageinfo stuff */ #define GLOBAL_INFO_LOCK(i) pthread_mutex_lock(&info_lock) #define GLOBAL_INFO_UNLOCK(i) pthread_mutex_unlock(&info_lock) -#else -#define GLOBAL_INFO_LOCK(i) -#define GLOBAL_INFO_UNLOCK(i) -#endif + /* this should probably be conditional on it existing */ #define USE_BSEARCH @@ -171,14 +166,12 @@ camel_folder_summary_init (CamelFolderSummary *s) s->messages = g_ptr_array_new(); s->messages_uid = g_hash_table_new(g_str_hash, g_str_equal); - -#ifdef ENABLE_THREADS + p->summary_lock = g_mutex_new(); p->io_lock = g_mutex_new(); p->filter_lock = g_mutex_new(); p->alloc_lock = g_mutex_new(); p->ref_lock = g_mutex_new(); -#endif } static void free_o_name(void *key, void *value, void *data) @@ -226,15 +219,13 @@ camel_folder_summary_finalize (CamelObject *obj) camel_object_unref((CamelObject *)p->filter_stream); if (p->index) camel_object_unref((CamelObject *)p->index); - -#ifdef ENABLE_THREADS + g_mutex_free(p->summary_lock); g_mutex_free(p->io_lock); g_mutex_free(p->filter_lock); g_mutex_free(p->alloc_lock); g_mutex_free(p->ref_lock); -#endif - + g_free(p); } diff --git a/camel/camel-folder.c b/camel/camel-folder.c index 7e52b08238..9a20e81ffd 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -5,7 +5,7 @@ * Author: * Bertrand Guiheneuf <bertrand@helixcode.com> * - * Copyright 1999, 2000 Ximian, Inc. (www.ximian.com) + * Copyright 1999-2003 Ximian, Inc. (www.ximian.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -22,6 +22,7 @@ * USA */ + #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -177,10 +178,8 @@ camel_folder_init (gpointer object, gpointer klass) folder->priv = g_malloc0(sizeof(*folder->priv)); folder->priv->frozen = 0; folder->priv->changed_frozen = camel_folder_change_info_new(); -#ifdef ENABLE_THREADS folder->priv->lock = e_mutex_new(E_MUTEX_REC); folder->priv->change_lock = e_mutex_new(E_MUTEX_SIMPLE); -#endif } static void @@ -200,10 +199,10 @@ camel_folder_finalize (CamelObject *object) camel_object_unref((CamelObject *)camel_folder->summary); camel_folder_change_info_free(p->changed_frozen); -#ifdef ENABLE_THREADS + e_mutex_destroy(p->lock); e_mutex_destroy(p->change_lock); -#endif + g_free(p); } @@ -1547,7 +1546,7 @@ camel_folder_is_frozen (CamelFolder *folder) return CF_CLASS (folder)->is_frozen (folder); } -#ifdef ENABLE_THREADS + struct _folder_filter_msg { CamelSessionThreadMsg msg; @@ -1622,7 +1621,7 @@ static CamelSessionThreadOps filter_ops = { filter_filter, filter_free, }; -#endif + /* Event hooks that block emission when frozen */ static gboolean @@ -1648,7 +1647,6 @@ folder_changed (CamelObject *obj, gpointer event_data) CAMEL_FOLDER_LOCK(folder, change_lock); if (driver) { -#ifdef ENABLE_THREADS GPtrArray *recents = g_ptr_array_new(); int i; struct _folder_filter_msg *msg; @@ -1665,13 +1663,7 @@ folder_changed (CamelObject *obj, gpointer event_data) msg->driver = driver; camel_exception_init(&msg->ex); camel_session_thread_queue(session, &msg->msg, 0); -#else - d(printf("Have '%d' recent messages, filtering\n", changed->recent->len)); - folder->priv->frozen++; - camel_filter_driver_filter_folder(driver, folder, NULL, changed->recent, FALSE, NULL); - camel_object_unref((CamelObject *)driver); - folder->priv->frozen--; -#endif + /* zero out the recent list so we dont reprocess */ /* this pokes past abstraction, but changeinfo is our structure anyway */ /* the only other alternative is to recognise when trigger is called from diff --git a/camel/camel-lock-client.c b/camel/camel-lock-client.c index dafdf46431..fb245d1eca 100644 --- a/camel/camel-lock-client.c +++ b/camel/camel-lock-client.c @@ -1,6 +1,6 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * - * Copyright (C) 2001 Ximian Inc. + * Copyright (C) 2001-2003 Ximian Inc. * * Authors: Michael Zucchi <notzed@ximian.com> * @@ -25,20 +25,14 @@ #include <stdio.h> #include <stdlib.h> - -#include <errno.h> #include <string.h> - #include <sys/types.h> #include <sys/stat.h> #include <sys/wait.h> - +#include <pthread.h> #include <unistd.h> #include <fcntl.h> - -#ifdef ENABLE_THREADS -#include <pthread.h> -#endif +#include <errno.h> #include "camel-exception.h" #include "camel-lock-helper.h" @@ -50,14 +44,9 @@ /* see also camel-lock.c */ #define _(x) (x) -#ifdef ENABLE_THREADS static pthread_mutex_t lock_lock = PTHREAD_MUTEX_INITIALIZER; #define LOCK() pthread_mutex_lock(&lock_lock) #define UNLOCK() pthread_mutex_unlock(&lock_lock) -#else -#define LOCK() -#define UNLOCK() -#endif static int lock_sequence; static int lock_helper_pid = -1; diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c index 2b71ec3866..ff2c0bb5fd 100644 --- a/camel/camel-mime-utils.c +++ b/camel/camel-mime-utils.c @@ -1,6 +1,6 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - * Copyright (C) 2000 Ximian Inc. + * Copyright (C) 2000-2003 Ximian Inc. * * Authors: Michael Zucchi <notzed@ximian.com> * Jeffrey Stedfast <fejj@ximian.com> @@ -27,24 +27,23 @@ #endif #include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/param.h> /* for MAXHOSTNAMELEN */ -#include <fcntl.h> #include <stdlib.h> #include <string.h> +#include <sys/types.h> +#include <sys/param.h> /* for MAXHOSTNAMELEN */ +#include <sys/stat.h> +#include <pthread.h> #include <unistd.h> +#include <regex.h> +#include <fcntl.h> +#include <errno.h> +#include <ctype.h> +#include <time.h> #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 1024 #endif -#include <time.h> - -#include <ctype.h> -#include <errno.h> -#include <regex.h> - #include <glib.h> #include <gal/util/e-iconv.h> #include <e-util/e-time-utils.h> @@ -53,10 +52,6 @@ #include "camel-charset-map.h" #include "camel-service.h" /* for camel_gethostbyname() */ -#ifdef ENABLE_THREADS -#include <pthread.h> -#endif - #ifndef CLEAN_DATE #include "broken-date-parser.h" #endif @@ -3780,14 +3775,9 @@ header_raw_clear(struct _header_raw **list) char * header_msgid_generate (void) { -#ifdef ENABLE_THREADS static pthread_mutex_t count_lock = PTHREAD_MUTEX_INITIALIZER; #define COUNT_LOCK() pthread_mutex_lock (&count_lock) #define COUNT_UNLOCK() pthread_mutex_unlock (&count_lock) -#else -#define COUNT_LOCK() -#define COUNT_UNLOCK() -#endif /* ENABLE_THREADS */ char host[MAXHOSTNAMELEN]; struct hostent *h = NULL; static int count = 0; diff --git a/camel/camel-object.c b/camel/camel-object.c index 56035c2754..e5dbbb463f 100644 --- a/camel/camel-object.c +++ b/camel/camel-object.c @@ -3,7 +3,7 @@ * Author: * Michael Zucchi <notzed@ximian.com> * - * Copyright 2000-2002 Ximian, Inc. (www.ximian.com) + * Copyright 2000-2003 Ximian, Inc. (www.ximian.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -26,15 +26,13 @@ #include <stdio.h> #include <string.h> +#include <pthread.h> +#include <semaphore.h> + #include "camel-object.h" #include <e-util/e-memory.h> - -#ifdef ENABLE_THREADS -#include <pthread.h> -#include <semaphore.h> #include <e-util/e-msgport.h> -#endif #define d(x) @@ -85,10 +83,8 @@ struct _CamelObjectBag { GHashTable *key_table; /* key by object */ CamelCopyFunc copy_key; GFreeFunc free_key; -#ifdef ENABLE_THREADS pthread_t owner; /* the thread that has reserved the bag for a new entry */ sem_t reserve_sem; /* used to track ownership */ -#endif }; /* used to tag a bag hookpair */ @@ -100,11 +96,8 @@ static CamelHookList *camel_object_get_hooks(CamelObject *o); static void camel_object_free_hooks(CamelObject *o); static void camel_object_bag_remove_unlocked(CamelObjectBag *inbag, CamelObject *o, CamelHookList *hooks); -#ifdef ENABLE_THREADS #define camel_object_unget_hooks(o) (e_mutex_unlock((CAMEL_OBJECT(o)->hooks->lock))) -#else -#define camel_object_unget_hooks(o) -#endif + /* ********************************************************************** */ @@ -121,21 +114,13 @@ static EMemChunk *type_chunks; CamelType camel_object_type; -#ifdef ENABLE_THREADS #define P_LOCK(l) (pthread_mutex_lock(&l)) #define P_UNLOCK(l) (pthread_mutex_unlock(&l)) #define E_LOCK(l) (e_mutex_lock(l)) #define E_UNLOCK(l) (e_mutex_unlock(l)) #define CLASS_LOCK(k) (g_mutex_lock((((CamelObjectClass *)k)->lock))) #define CLASS_UNLOCK(k) (g_mutex_unlock((((CamelObjectClass *)k)->lock))) -#else -#define P_LOCK(l) -#define P_UNLOCK(l) -#define E_LOCK(l) -#define E_UNLOCK(l) -#define CLASS_LOCK(k) -#define CLASS_UNLOCK(k) -#endif + static struct _CamelHookPair * pair_alloc(void) @@ -365,12 +350,10 @@ camel_type_register (CamelType parent, const char * name, klass = g_malloc0(klass_size); klass->klass_size = klass_size; - klass->object_size = object_size; -#ifdef ENABLE_THREADS + klass->object_size = object_size; klass->lock = g_mutex_new(); -#endif klass->instance_chunks = e_memchunk_new(8, object_size); - + klass->parent = parent; if (parent) { klass->next = parent->child; @@ -680,7 +663,8 @@ camel_object_class_add_event(CamelObjectClass *klass, const char *name, CamelObj } /* free hook data */ -static void camel_object_free_hooks(CamelObject *o) +static void +camel_object_free_hooks (CamelObject *o) { CamelHookPair *pair, *next; @@ -701,38 +685,30 @@ static void camel_object_free_hooks(CamelObject *o) } /* return (allocate if required) the object's hook list, locking at the same time */ -static CamelHookList *camel_object_get_hooks(CamelObject *o) +static CamelHookList * +camel_object_get_hooks (CamelObject *o) { -#ifdef ENABLE_THREADS static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; -#endif CamelHookList *hooks; /* if we have it, we dont have to do any other locking, otherwise use a global lock to setup the object's hook data */ -#ifdef ENABLE_THREADS if (o->hooks == NULL) { pthread_mutex_lock(&lock); -#endif if (o->hooks == NULL) { hooks = hooks_alloc(); -#ifdef ENABLE_THREADS hooks->lock = e_mutex_new(E_MUTEX_REC); -#endif hooks->flags = 0; hooks->depth = 0; hooks->list_length = 0; hooks->list = NULL; o->hooks = hooks; } -#ifdef ENABLE_THREADS pthread_mutex_unlock(&lock); } -#endif - -#ifdef ENABLE_THREADS + e_mutex_lock(o->hooks->lock); -#endif + return o->hooks; } @@ -1084,7 +1060,8 @@ camel_object_class_dump_tree(CamelType root) object_class_dump_tree_rec(root, 0); } -CamelObjectBag *camel_object_bag_new(GHashFunc hash, GEqualFunc equal, CamelCopyFunc keycopy, GFreeFunc keyfree) +CamelObjectBag * +camel_object_bag_new (GHashFunc hash, GEqualFunc equal, CamelCopyFunc keycopy, GFreeFunc keyfree) { CamelObjectBag *bag; @@ -1094,10 +1071,10 @@ CamelObjectBag *camel_object_bag_new(GHashFunc hash, GEqualFunc equal, CamelCopy bag->free_key = keyfree; bag->key_table = g_hash_table_new(NULL, NULL); bag->owner = 0; -#ifdef ENABLE_THREADS + /* init the semaphore to 1 owner, this is who has reserved the bag for adding */ sem_init(&bag->reserve_sem, 0, 1); -#endif + return bag; } @@ -1107,7 +1084,8 @@ save_object(void *key, CamelObject *o, GPtrArray *objects) g_ptr_array_add(objects, o); } -void camel_object_bag_destroy(CamelObjectBag *bag) +void +camel_object_bag_destroy (CamelObjectBag *bag) { GPtrArray *objects = g_ptr_array_new(); int i; @@ -1122,13 +1100,12 @@ void camel_object_bag_destroy(CamelObjectBag *bag) g_ptr_array_free(objects, TRUE); g_hash_table_destroy(bag->object_table); g_hash_table_destroy(bag->key_table); -#ifdef ENABLE_THREADS sem_destroy(&bag->reserve_sem); -#endif g_free(bag); } -void camel_object_bag_add(CamelObjectBag *bag, const void *key, void *vo) +void +camel_object_bag_add (CamelObjectBag *bag, const void *key, void *vo) { CamelObject *o = vo; CamelHookList *hooks; @@ -1160,19 +1137,18 @@ void camel_object_bag_add(CamelObjectBag *bag, const void *key, void *vo) k = bag->copy_key(key); g_hash_table_insert(bag->object_table, k, vo); g_hash_table_insert(bag->key_table, vo, k); - -#ifdef ENABLE_THREADS + if (bag->owner == pthread_self()) { bag->owner = 0; sem_post(&bag->reserve_sem); } -#endif - + E_UNLOCK(type_lock); camel_object_unget_hooks(o); } -void *camel_object_bag_get(CamelObjectBag *bag, const void *key) +void * +camel_object_bag_get (CamelObjectBag *bag, const void *key) { CamelObject *o; @@ -1182,9 +1158,7 @@ void *camel_object_bag_get(CamelObjectBag *bag, const void *key) if (o) { /* we use the same lock as the refcount */ o->ref_count++; - } -#ifdef ENABLE_THREADS - else if (bag->owner != pthread_self()) { + } else if (bag->owner != pthread_self()) { E_UNLOCK(type_lock); sem_wait(&bag->reserve_sem); E_LOCK(type_lock); @@ -1195,10 +1169,9 @@ void *camel_object_bag_get(CamelObjectBag *bag, const void *key) /* we dont want to reserve the bag */ sem_post(&bag->reserve_sem); } -#endif E_UNLOCK(type_lock); - + return o; } @@ -1206,7 +1179,8 @@ void *camel_object_bag_get(CamelObjectBag *bag, const void *key) /* After calling reserve, you MUST call bag_abort or bag_add */ /* Also note that currently you can only reserve a single key at any one time in a given thread */ -void *camel_object_bag_reserve(CamelObjectBag *bag, const void *key) +void * +camel_object_bag_reserve (CamelObjectBag *bag, const void *key) { CamelObject *o; @@ -1215,9 +1189,7 @@ void *camel_object_bag_reserve(CamelObjectBag *bag, const void *key) o = g_hash_table_lookup(bag->object_table, key); if (o) { o->ref_count++; - } -#ifdef ENABLE_THREADS - else { + } else { g_assert(bag->owner != pthread_self()); E_UNLOCK(type_lock); sem_wait(&bag->reserve_sem); @@ -1232,7 +1204,6 @@ void *camel_object_bag_reserve(CamelObjectBag *bag, const void *key) bag->owner = pthread_self(); } } -#endif E_UNLOCK(type_lock); @@ -1240,14 +1211,13 @@ void *camel_object_bag_reserve(CamelObjectBag *bag, const void *key) } /* abort a reserved key */ -void camel_object_bag_abort(CamelObjectBag *bag, const void *key) +void +camel_object_bag_abort (CamelObjectBag *bag, const void *key) { -#ifdef ENABLE_THREADS g_assert(bag->owner == pthread_self()); bag->owner = 0; sem_post(&bag->reserve_sem); -#endif } static void @@ -1260,7 +1230,8 @@ save_bag(void *key, CamelObject *o, GPtrArray *list) /* get a list of all objects in the bag, ref'd ignores any reserved keys */ -GPtrArray *camel_object_bag_list(CamelObjectBag *bag) +GPtrArray * +camel_object_bag_list (CamelObjectBag *bag) { GPtrArray *list; @@ -1274,7 +1245,8 @@ GPtrArray *camel_object_bag_list(CamelObjectBag *bag) } /* if bag is NULL, remove all bags from object */ -static void camel_object_bag_remove_unlocked(CamelObjectBag *inbag, CamelObject *o, CamelHookList *hooks) +static void +camel_object_bag_remove_unlocked (CamelObjectBag *inbag, CamelObject *o, CamelHookList *hooks) { CamelHookPair *pair, *parent; void *oldkey; @@ -1303,7 +1275,8 @@ static void camel_object_bag_remove_unlocked(CamelObjectBag *inbag, CamelObject } } -void camel_object_bag_remove(CamelObjectBag *inbag, void *vo) +void +camel_object_bag_remove (CamelObjectBag *inbag, void *vo) { CamelObject *o = vo; CamelHookList *hooks; diff --git a/camel/camel-object.h b/camel/camel-object.h index 5aa9d3157f..0bcdeaef0f 100644 --- a/camel/camel-object.h +++ b/camel/camel-object.h @@ -32,19 +32,17 @@ extern "C" { #pragma } #endif /* __cplusplus */ -#include <stdlib.h> /* size_t */ #include <glib.h> +#include <stdlib.h> /* size_t */ #include <stdarg.h> +#include <pthread.h> + #include <camel/camel-arg.h> #include <camel/camel-types.h> /* this is a @##$@#SF stupid header */ /* this crap shouldn't be here */ #include <camel/camel-i18n.h> -#ifdef ENABLE_THREADS -#include <pthread.h> -#endif - /* turn on so that camel_object_class_dump_tree() dumps object instances as well */ #define CAMEL_OBJECT_TRACK_INSTANCES diff --git a/camel/camel-operation.c b/camel/camel-operation.c index 8befacce19..3d5a9c8ada 100644 --- a/camel/camel-operation.c +++ b/camel/camel-operation.c @@ -1,19 +1,40 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Authors: Michael Zucchi <NotZed@ximian.com> + * + * Copyright 2003 Ximian, Inc. (www.ximian.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. + * + */ + + #ifdef HAVE_CONFIG_H #include <config.h> #endif +#include <glib.h> + #include <stdio.h> -#ifdef ENABLE_THREADS +#include <sys/time.h> +#include <unistd.h> #include <pthread.h> #ifdef HAVE_NSS #include <nspr.h> #endif -#endif -#include <sys/time.h> -#include <unistd.h> - -#include <glib.h> #include "camel-operation.h" #include "e-util/e-msgport.h" @@ -42,13 +63,11 @@ struct _CamelOperation { GSList *status_stack; struct _status_stack *lastreport; -#ifdef ENABLE_THREADS EMsgPort *cancel_port; int cancel_fd; #ifdef HAVE_NSS PRFileDesc *cancel_prfd; #endif -#endif }; #define CAMEL_OPERATION_CANCELLED (1<<0) @@ -57,14 +76,10 @@ struct _CamelOperation { /* Delay before a transient operation has any effect on the status */ #define CAMEL_OPERATION_TRANSIENT_DELAY (5) -#ifdef ENABLE_THREADS +static pthread_mutex_t operation_active_lock = PTHREAD_MUTEX_INITIALIZER; #define CAMEL_ACTIVE_LOCK() pthread_mutex_lock(&operation_active_lock) #define CAMEL_ACTIVE_UNLOCK() pthread_mutex_unlock(&operation_active_lock) -static pthread_mutex_t operation_active_lock = PTHREAD_MUTEX_INITIALIZER; -#else -#define CAMEL_ACTIVE_LOCK() -#define CAMEL_ACTIVE_UNLOCK() -#endif + static unsigned int stamp (void); @@ -87,7 +102,8 @@ typedef struct _CamelOperationMsg { * * Return value: A new operation handle. **/ -CamelOperation *camel_operation_new(CamelOperationStatusFunc status, void *status_data) +CamelOperation * +camel_operation_new (CamelOperationStatusFunc status, void *status_data) { CamelOperation *cc; @@ -98,18 +114,20 @@ CamelOperation *camel_operation_new(CamelOperationStatusFunc status, void *statu cc->refcount = 1; cc->status = status; cc->status_data = status_data; -#ifdef ENABLE_THREADS - cc->id = ~0; + cc->id = (pthread_t) ~0; cc->cancel_port = e_msgport_new(); cc->cancel_fd = -1; -#endif - + return cc; } -/* return the registered operation, or NULL if none registered */ -/* need to unref when done with it */ -CamelOperation *camel_operation_registered(void) +/** + * camel_operation_registered: + * + * Returns the registered operation, or %NULL if none registered. + **/ +CamelOperation * +camel_operation_registered (void) { CamelOperation *cc = NULL; @@ -126,21 +144,19 @@ CamelOperation *camel_operation_registered(void) /** * camel_operation_reset: - * @cc: + * @cc: operation context * * Resets an operation cancel state and message. **/ -void camel_operation_reset(CamelOperation *cc) +void +camel_operation_reset (CamelOperation *cc) { - GSList *n; - -#ifdef ENABLE_THREADS CamelOperationMsg *msg; - + GSList *n; + while ((msg = (CamelOperationMsg *)e_msgport_get(cc->cancel_port))) g_free(msg); -#endif - + n = cc->status_stack; while (n) { g_free(n->data); @@ -155,11 +171,12 @@ void camel_operation_reset(CamelOperation *cc) /** * camel_operation_ref: - * @cc: + * @cc: operation context * * Add a reference to the CamelOperation @cc. **/ -void camel_operation_ref(CamelOperation *cc) +void +camel_operation_ref (CamelOperation *cc) { g_assert(cc->refcount > 0); @@ -170,11 +187,12 @@ void camel_operation_ref(CamelOperation *cc) /** * camel_operation_unref: - * @cc: + * @cc: operation context * * Unref and potentially free @cc. **/ -void camel_operation_unref(CamelOperation *cc) +void +camel_operation_unref (CamelOperation *cc) { GSList *n; @@ -182,15 +200,13 @@ void camel_operation_unref(CamelOperation *cc) CAMEL_ACTIVE_LOCK(); if (cc->refcount == 1) { -#ifdef ENABLE_THREADS CamelOperationMsg *msg; - + while ((msg = (CamelOperationMsg *)e_msgport_get(cc->cancel_port))) g_free(msg); e_msgport_destroy(cc->cancel_port); -#endif - + if (cc->id != (~0)) { g_warning("Unreffing operation status which was still registered: %p\n", cc); g_hash_table_remove(operation_active, (void *)cc->id); @@ -213,12 +229,13 @@ void camel_operation_unref(CamelOperation *cc) /** * camel_operation_cancel_block: - * @cc: + * @cc: operation context * * Block cancellation for this operation. If @cc is NULL, then the * current thread is blocked. **/ -void camel_operation_cancel_block(CamelOperation *cc) +void +camel_operation_cancel_block (CamelOperation *cc) { CAMEL_ACTIVE_LOCK(); if (operation_active == NULL) @@ -234,13 +251,14 @@ void camel_operation_cancel_block(CamelOperation *cc) /** * camel_operation_cancel_unblock: - * @cc: + * @cc: operation context * * Unblock cancellation, when the unblock count reaches the block * count, then this operation can be cancelled. If @cc is NULL, then * the current thread is unblocked. **/ -void camel_operation_cancel_unblock(CamelOperation *cc) +void +camel_operation_cancel_unblock (CamelOperation *cc) { CAMEL_ACTIVE_LOCK(); if (operation_active == NULL) @@ -270,12 +288,13 @@ cancel_thread(void *key, CamelOperation *cc, void *data) /** * camel_operation_cancel: - * @cc: + * @cc: operation context * * Cancel a given operation. If @cc is NULL then all outstanding * operations are cancelled. **/ -void camel_operation_cancel(CamelOperation *cc) +void +camel_operation_cancel (CamelOperation *cc) { CamelOperationMsg *msg; @@ -298,7 +317,7 @@ void camel_operation_cancel(CamelOperation *cc) /** * camel_operation_register: - * @cc: + * @cc: operation context * * Register a thread or the main thread for cancellation through @cc. * If @cc is NULL, then a new cancellation is created for this thread, @@ -307,7 +326,8 @@ void camel_operation_cancel(CamelOperation *cc) * All calls to operation_register() should be matched with calls to * operation_unregister(), or resources will be lost. **/ -void camel_operation_register(CamelOperation *cc) +void +camel_operation_register (CamelOperation *cc) { pthread_t id = pthread_self(); @@ -337,12 +357,13 @@ void camel_operation_register(CamelOperation *cc) /** * camel_operation_unregister: - * @cc: + * @cc: operation context * * Unregister a given operation from being cancelled. If @cc is NULL, * then the current thread is used. **/ -void camel_operation_unregister(CamelOperation *cc) +void +camel_operation_unregister (CamelOperation *cc) { CAMEL_ACTIVE_LOCK(); @@ -372,14 +393,15 @@ void camel_operation_unregister(CamelOperation *cc) /** * camel_operation_cancel_check: - * @cc: + * @cc: operation context * * Check if cancellation has been applied to @cc. If @cc is NULL, * then the CamelOperation registered for the current thread is used. * * Return value: TRUE if the operation has been cancelled. **/ -gboolean camel_operation_cancel_check(CamelOperation *cc) +gboolean +camel_operation_cancel_check (CamelOperation *cc) { CamelOperationMsg *msg; int cancelled; @@ -412,7 +434,7 @@ gboolean camel_operation_cancel_check(CamelOperation *cc) /** * camel_operation_cancel_fd: - * @cc: + * @cc: operation context * * Retrieve a file descriptor that can be waited on (select, or poll) * for read, to asynchronously detect cancellation. @@ -420,7 +442,8 @@ gboolean camel_operation_cancel_check(CamelOperation *cc) * Return value: The fd, or -1 if cancellation is not available * (blocked, or has not been registered for this thread). **/ -int camel_operation_cancel_fd(CamelOperation *cc) +int +camel_operation_cancel_fd (CamelOperation *cc) { CAMEL_ACTIVE_LOCK(); @@ -445,7 +468,7 @@ int camel_operation_cancel_fd(CamelOperation *cc) #ifdef HAVE_NSS /** * camel_operation_cancel_prfd: - * @cc: + * @cc: operation context * * Retrieve a file descriptor that can be waited on (select, or poll) * for read, to asynchronously detect cancellation. @@ -453,7 +476,8 @@ int camel_operation_cancel_fd(CamelOperation *cc) * Return value: The fd, or NULL if cancellation is not available * (blocked, or has not been registered for this thread). **/ -PRFileDesc *camel_operation_cancel_prfd(CamelOperation *cc) +PRFileDesc * +camel_operation_cancel_prfd (CamelOperation *cc) { CAMEL_ACTIVE_LOCK(); @@ -478,14 +502,15 @@ PRFileDesc *camel_operation_cancel_prfd(CamelOperation *cc) /** * camel_operation_start: - * @cc: - * @what: - * @: + * @cc: operation context + * @what: action being performed (printf-style format string) + * @Varargs: varargs * * Report the start of an operation. All start operations should have * similar end operations. **/ -void camel_operation_start(CamelOperation *cc, char *what, ...) +void +camel_operation_start (CamelOperation *cc, char *what, ...) { va_list ap; char *msg; @@ -523,15 +548,16 @@ void camel_operation_start(CamelOperation *cc, char *what, ...) /** * camel_operation_start_transient: - * @cc: - * @what: - * @: + * @cc: operation context + * @what: printf-style format string describing the action being performed + * @Varargs: varargs * * Start a transient event. We only update this to the display if it * takes very long to process, and if we do, we then go back to the * previous state when finished. **/ -void camel_operation_start_transient(CamelOperation *cc, char *what, ...) +void +camel_operation_start_transient (CamelOperation *cc, char *what, ...) { va_list ap; char *msg; @@ -588,7 +614,8 @@ static unsigned int stamp(void) * If the total percentage is not know, then use * camel_operation_progress_count(). **/ -void camel_operation_progress(CamelOperation *cc, int pc) +void +camel_operation_progress (CamelOperation *cc, int pc) { unsigned int now; struct _status_stack *s; @@ -637,21 +664,30 @@ void camel_operation_progress(CamelOperation *cc, int pc) } } -void camel_operation_progress_count(CamelOperation *cc, int sofar) + +/** + * camel_operation_progress_count: + * @cc: operation context + * @sofar: + * + **/ +void +camel_operation_progress_count (CamelOperation *cc, int sofar) { camel_operation_progress(cc, sofar); } /** * camel_operation_end: - * @cc: + * @cc: operation context * @what: Format string. - * @: + * @Varargs: varargs * * Report the end of an operation. If @cc is NULL, then the currently * registered operation is notified. **/ -void camel_operation_end(CamelOperation *cc) +void +camel_operation_end (CamelOperation *cc) { struct _status_stack *s, *p; unsigned int now; diff --git a/camel/camel-partition-table.c b/camel/camel-partition-table.c index fad1a5e002..e5b2639a4a 100644 --- a/camel/camel-partition-table.c +++ b/camel/camel-partition-table.c @@ -1,5 +1,6 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - * Copyright (C) 2001 Ximian Inc. + * Copyright (C) 2001-2003 Ximian Inc. * * Authors: Michael Zucchi <notzed@ximian.com> * @@ -18,20 +19,19 @@ * Boston, MA 02111-1307, USA. */ + #ifdef HAVE_CONFIG_H #include <config.h> #endif -#include <sys/stat.h> -#include <sys/uio.h> -#include <unistd.h> -#include <errno.h> -#include <string.h> #include <stdlib.h> - +#include <string.h> #include <sys/types.h> #include <sys/stat.h> +#include <sys/uio.h> +#include <unistd.h> #include <fcntl.h> +#include <errno.h> #include "e-util/e-msgport.h" @@ -42,15 +42,10 @@ tables consistent after program crash without sync */ /*#define SYNC_UPDATES*/ -#ifdef ENABLE_THREADS -#include <pthread.h> -#endif - #define d(x) /*(printf("%s(%d):%s: ", __FILE__, __LINE__, __PRETTY_FUNCTION__),(x))*/ /* key index debug */ #define k(x) /*(printf("%s(%d):%s: ", __FILE__, __LINE__, __PRETTY_FUNCTION__),(x))*/ -#ifdef ENABLE_THREADS struct _CamelPartitionTablePrivate { pthread_mutex_t lock; /* for locking partition */ @@ -58,10 +53,7 @@ struct _CamelPartitionTablePrivate { #define CAMEL_PARTITION_TABLE_LOCK(kf, lock) (pthread_mutex_lock(&(kf)->priv->lock)) #define CAMEL_PARTITION_TABLE_UNLOCK(kf, lock) (pthread_mutex_unlock(&(kf)->priv->lock)) -#else -#define CAMEL_PARTITION_TABLE_LOCK(kf, lock) -#define CAMEL_PARTITION_TABLE_UNLOCK(kf, lock) -#endif + static void camel_partition_table_class_init(CamelPartitionTableClass *klass) @@ -76,9 +68,7 @@ camel_partition_table_init(CamelPartitionTable *cpi) e_dlist_init(&cpi->partition); p = cpi->priv = g_malloc0(sizeof(*cpi->priv)); -#ifdef ENABLE_THREADS pthread_mutex_init(&p->lock, NULL); -#endif } static void @@ -98,10 +88,9 @@ camel_partition_table_finalise(CamelPartitionTable *cpi) camel_object_unref((CamelObject *)cpi->blocks); } - -#ifdef ENABLE_THREADS + pthread_mutex_destroy(&p->lock); -#endif + g_free(p); } @@ -606,18 +595,13 @@ fail: /* ********************************************************************** */ -#ifdef ENABLE_THREADS - struct _CamelKeyTablePrivate { pthread_mutex_t lock; /* for locking key */ }; #define CAMEL_KEY_TABLE_LOCK(kf, lock) (pthread_mutex_lock(&(kf)->priv->lock)) #define CAMEL_KEY_TABLE_UNLOCK(kf, lock) (pthread_mutex_unlock(&(kf)->priv->lock)) -#else -#define CAMEL_KEY_TABLE_LOCK(kf, lock) -#define CAMEL_KEY_TABLE_UNLOCK(kf, lock) -#endif + static void camel_key_table_class_init(CamelKeyTableClass *klass) @@ -630,9 +614,7 @@ camel_key_table_init(CamelKeyTable *ki) struct _CamelKeyTablePrivate *p; p = ki->priv = g_malloc0(sizeof(*ki->priv)); -#ifdef ENABLE_THREADS pthread_mutex_init(&p->lock, NULL); -#endif } static void @@ -650,10 +632,9 @@ camel_key_table_finalise(CamelKeyTable *ki) camel_block_file_sync(ki->blocks); camel_object_unref((CamelObject *)ki->blocks); } - -#ifdef ENABLE_THREADS + pthread_mutex_destroy(&p->lock); -#endif + g_free(p); } diff --git a/camel/camel-private.h b/camel/camel-private.h index 6de65b54eb..c9ce24fd01 100644 --- a/camel/camel-private.h +++ b/camel/camel-private.h @@ -31,102 +31,62 @@ extern "C" { /* need a way to configure and save this data, if this header is to be installed. For now, dont install it */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#ifdef ENABLE_THREADS #include <pthread.h> #include <e-util/e-msgport.h> -#endif struct _CamelFolderPrivate { -#ifdef ENABLE_THREADS EMutex *lock; EMutex *change_lock; -#endif /* must require the 'change_lock' to access this */ int frozen; struct _CamelFolderChangeInfo *changed_frozen; /* queues changed events */ }; -#ifdef ENABLE_THREADS #define CAMEL_FOLDER_LOCK(f, l) (e_mutex_lock(((CamelFolder *)f)->priv->l)) #define CAMEL_FOLDER_UNLOCK(f, l) (e_mutex_unlock(((CamelFolder *)f)->priv->l)) -#else -#define CAMEL_FOLDER_LOCK(f, l) -#define CAMEL_FOLDER_UNLOCK(f, l) -#endif + struct _CamelStorePrivate { -#ifdef ENABLE_THREADS EMutex *folder_lock; /* for locking folder operations */ -#else - int dummy; -#endif }; -#ifdef ENABLE_THREADS #define CAMEL_STORE_LOCK(f, l) (e_mutex_lock(((CamelStore *)f)->priv->l)) #define CAMEL_STORE_UNLOCK(f, l) (e_mutex_unlock(((CamelStore *)f)->priv->l)) -#else -#define CAMEL_STORE_LOCK(f, l) -#define CAMEL_STORE_UNLOCK(f, l) -#endif + struct _CamelTransportPrivate { -#ifdef ENABLE_THREADS GMutex *send_lock; /* for locking send operations */ -#else - int dummy; -#endif }; -#ifdef ENABLE_THREADS #define CAMEL_TRANSPORT_LOCK(f, l) (g_mutex_lock(((CamelTransport *)f)->priv->l)) #define CAMEL_TRANSPORT_UNLOCK(f, l) (g_mutex_unlock(((CamelTransport *)f)->priv->l)) -#else -#define CAMEL_TRANSPORT_LOCK(f, l) -#define CAMEL_TRANSPORT_UNLOCK(f, l) -#endif + struct _CamelServicePrivate { -#ifdef ENABLE_THREADS EMutex *connect_lock; /* for locking connection operations */ EMutex *connect_op_lock;/* for locking the connection_op */ -#else - int dummy; -#endif }; -#ifdef ENABLE_THREADS #define CAMEL_SERVICE_LOCK(f, l) (e_mutex_lock(((CamelService *)f)->priv->l)) #define CAMEL_SERVICE_UNLOCK(f, l) (e_mutex_unlock(((CamelService *)f)->priv->l)) #define CAMEL_SERVICE_ASSERT_LOCKED(f, l) (e_mutex_assert_locked (((CamelService *)f)->priv->l)) -#else -#define CAMEL_SERVICE_LOCK(f, l) -#define CAMEL_SERVICE_UNLOCK(f, l) -#define CAMEL_SERVICE_ASSERT_LOCKED(f, l) -#endif + struct _CamelSessionPrivate { -#ifdef ENABLE_THREADS GMutex *lock; /* for locking everything basically */ GMutex *thread_lock; /* locking threads */ int thread_id; GHashTable *thread_active; EThread *thread_queue; -#else - int dummy; -#endif }; -#ifdef ENABLE_THREADS #define CAMEL_SESSION_LOCK(f, l) (g_mutex_lock(((CamelSession *)f)->priv->l)) #define CAMEL_SESSION_UNLOCK(f, l) (g_mutex_unlock(((CamelSession *)f)->priv->l)) -#else -#define CAMEL_SESSION_LOCK(f, l) -#define CAMEL_SESSION_UNLOCK(f, l) -#endif /* most of this stuff really is private, but the lock can be used by subordinate classes */ @@ -143,98 +103,61 @@ struct _CamelFolderSummaryPrivate { struct _CamelStreamFilter *filter_stream; struct _CamelIndex *index; - -#ifdef ENABLE_THREADS + GMutex *summary_lock; /* for the summary hashtable/array */ GMutex *io_lock; /* load/save lock, for access to saved_count, etc */ GMutex *filter_lock; /* for accessing any of the filtering/indexing stuff, since we share them */ GMutex *alloc_lock; /* for setting up and using allocators */ GMutex *ref_lock; /* for reffing/unreffing messageinfo's ALWAYS obtain before summary_lock */ -#endif }; -#ifdef ENABLE_THREADS #define CAMEL_SUMMARY_LOCK(f, l) (g_mutex_lock(((CamelFolderSummary *)f)->priv->l)) #define CAMEL_SUMMARY_UNLOCK(f, l) (g_mutex_unlock(((CamelFolderSummary *)f)->priv->l)) -#else -#define CAMEL_SUMMARY_LOCK(f, l) -#define CAMEL_SUMMARY_UNLOCK(f, l) -#endif + struct _CamelStoreSummaryPrivate { -#ifdef ENABLE_THREADS GMutex *summary_lock; /* for the summary hashtable/array */ GMutex *io_lock; /* load/save lock, for access to saved_count, etc */ GMutex *alloc_lock; /* for setting up and using allocators */ GMutex *ref_lock; /* for reffing/unreffing messageinfo's ALWAYS obtain before summary_lock */ -#else - int dummy; -#endif }; -#ifdef ENABLE_THREADS #define CAMEL_STORE_SUMMARY_LOCK(f, l) (g_mutex_lock(((CamelStoreSummary *)f)->priv->l)) #define CAMEL_STORE_SUMMARY_UNLOCK(f, l) (g_mutex_unlock(((CamelStoreSummary *)f)->priv->l)) -#else -#define CAMEL_STORE_SUMMARY_LOCK(f, l) -#define CAMEL_STORE_SUMMARY_UNLOCK(f, l) -#endif + struct _CamelVeeFolderPrivate { GList *folders; /* lock using subfolder_lock before changing/accessing */ GList *folders_changed; /* for list of folders that have changed between updates */ int freeze_count; -#ifdef ENABLE_THREADS GMutex *summary_lock; /* for locking vfolder summary */ GMutex *subfolder_lock; /* for locking the subfolder list */ GMutex *changed_lock; /* for locking the folders-changed list */ -#endif }; -#ifdef ENABLE_THREADS #define CAMEL_VEE_FOLDER_LOCK(f, l) (g_mutex_lock(((CamelVeeFolder *)f)->priv->l)) #define CAMEL_VEE_FOLDER_UNLOCK(f, l) (g_mutex_unlock(((CamelVeeFolder *)f)->priv->l)) -#else -#define CAMEL_VEE_FOLDER_LOCK(f, l) -#define CAMEL_VEE_FOLDER_UNLOCK(f, l) -#endif + struct _CamelDataWrapperPrivate { -#ifdef ENABLE_THREADS pthread_mutex_t stream_lock; -#else - int dummy; -#endif }; -#ifdef ENABLE_THREADS #define CAMEL_DATA_WRAPPER_LOCK(dw, l) (pthread_mutex_lock(&((CamelDataWrapper *)dw)->priv->l)) #define CAMEL_DATA_WRAPPER_UNLOCK(dw, l) (pthread_mutex_unlock(&((CamelDataWrapper *)dw)->priv->l)) -#else -#define CAMEL_DATA_WRAPPER_LOCK(dw, l) -#define CAMEL_DATA_WRAPPER_UNLOCK(dw, l) -#endif + /* most of this stuff really is private, but the lock can be used by subordinate classes */ struct _CamelCertDBPrivate { -#ifdef ENABLE_THREADS GMutex *db_lock; /* for the db hashtable/array */ GMutex *io_lock; /* load/save lock, for access to saved_count, etc */ GMutex *alloc_lock; /* for setting up and using allocators */ GMutex *ref_lock; /* for reffing/unreffing certs */ -#else - int dummy; -#endif }; -#ifdef ENABLE_THREADS #define CAMEL_CERTDB_LOCK(db, l) (g_mutex_lock (((CamelCertDB *) db)->priv->l)) #define CAMEL_CERTDB_UNLOCK(db, l) (g_mutex_unlock (((CamelCertDB *) db)->priv->l)) -#else -#define CAMEL_CERTDB_LOCK(db, l) -#define CAMEL_CERTDB_UNLOCK(db, l) -#endif #ifdef __cplusplus } diff --git a/camel/camel-sasl-popb4smtp.c b/camel/camel-sasl-popb4smtp.c index 1bc91e1402..329151872e 100644 --- a/camel/camel-sasl-popb4smtp.c +++ b/camel/camel-sasl-popb4smtp.c @@ -2,7 +2,7 @@ /* * Authors: Michael Zucchi <notzed@ximian.com> * - * Copyright 2001 Ximian, Inc. (www.ximian.com) + * Copyright 2001-2003 Ximian, Inc. (www.ximian.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -24,8 +24,10 @@ #include <config.h> #endif +#include <pthread.h> #include <string.h> #include <time.h> + #include "camel-sasl-popb4smtp.h" #include "camel-service.h" #include "camel-session.h" @@ -45,15 +47,9 @@ static GHashTable *poplast; /* use 1 hour as our pop timeout */ #define POPB4SMTP_TIMEOUT (60*60) -#ifdef ENABLE_THREADS -#include <pthread.h> static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; #define POPB4SMTP_LOCK(l) pthread_mutex_lock(&l) #define POPB4SMTP_UNLOCK(l) pthread_mutex_unlock(&l) -#else -#define POPB4SMTP_LOCK(l) -#define POPB4SMTP_UNLOCK(l) -#endif static CamelSaslClass *parent_class = NULL; diff --git a/camel/camel-service.c b/camel/camel-service.c index 7ea34d953d..ae3a36dba4 100644 --- a/camel/camel-service.c +++ b/camel/camel-service.c @@ -6,7 +6,7 @@ * Author : * Bertrand Guiheneuf <bertrand@helixcode.com> * - * Copyright 1999, 2000 Ximian, Inc. (www.ximian.com) + * Copyright 1999-2003 Ximian, Inc. (www.ximian.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -30,12 +30,10 @@ #include <ctype.h> #include <stdlib.h> #include <string.h> +#include <pthread.h> #include <errno.h> -#ifdef ENABLE_THREADS -#include <pthread.h> #include "e-util/e-msgport.h" -#endif #include "e-util/e-host-utils.h" @@ -93,12 +91,10 @@ static void camel_service_init (void *o, void *k) { CamelService *service = o; - + service->priv = g_malloc0(sizeof(*service->priv)); -#ifdef ENABLE_THREADS service->priv->connect_lock = e_mutex_new(E_MUTEX_REC); service->priv->connect_op_lock = e_mutex_new(E_MUTEX_SIMPLE); -#endif } static void @@ -123,10 +119,9 @@ camel_service_finalize (CamelObject *object) if (service->session) camel_object_unref (CAMEL_OBJECT (service->session)); -#ifdef ENABLE_THREADS e_mutex_destroy (service->priv->connect_lock); e_mutex_destroy (service->priv->connect_op_lock); -#endif + g_free (service->priv); } @@ -688,9 +683,7 @@ camel_service_gethost (CamelService *service, CamelException *ex) #endif struct _lookup_msg { -#ifdef ENABLE_THREADS EMsg msg; -#endif unsigned int cancelled:1; const char *name; int len; @@ -709,16 +702,13 @@ get_hostbyname(void *data) while ((info->result = e_gethostbyname_r(info->name, &info->hostbuf, info->hostbufmem, info->hostbuflen, &info->herr)) == ERANGE) { d(printf("gethostbyname fialed?\n")); -#ifdef ENABLE_THREADS pthread_testcancel(); -#endif info->hostbuflen *= 2; info->hostbufmem = g_realloc(info->hostbufmem, info->hostbuflen); } d(printf("gethostbyname ok?\n")); - -#ifdef ENABLE_THREADS + /* If we got cancelled, dont reply, just free it */ if (info->cancelled) { g_free(info->hostbufmem); @@ -726,21 +716,19 @@ get_hostbyname(void *data) } else { e_msgport_reply((EMsg *)info); } -#endif + return NULL; } struct hostent * camel_gethostbyname (const char *name, CamelException *exout) { -#ifdef ENABLE_THREADS int fdmax, status, fd, cancel_fd; -#endif struct _lookup_msg *msg; CamelException ex; - + g_return_val_if_fail(name != NULL, NULL); - + if (camel_operation_cancel_check(NULL)) { camel_exception_set (exout, CAMEL_EXCEPTION_USER_CANCEL, _("Cancelled")); return NULL; @@ -754,13 +742,10 @@ camel_gethostbyname (const char *name, CamelException *exout) msg->hostbufmem = g_malloc(msg->hostbuflen); msg->name = name; msg->result = -1; - -#ifdef ENABLE_THREADS + cancel_fd = camel_operation_cancel_fd(NULL); if (cancel_fd == -1) { -#endif get_hostbyname(msg); -#ifdef ENABLE_THREADS } else { EMsgPort *reply_port; pthread_t id; @@ -805,8 +790,7 @@ camel_gethostbyname (const char *name, CamelException *exout) } e_msgport_destroy(reply_port); } -#endif - + camel_operation_end(NULL); if (!camel_exception_is_set(&ex)) { @@ -835,27 +819,24 @@ static void * get_hostbyaddr (void *data) { struct _lookup_msg *info = data; - + while ((info->result = e_gethostbyaddr_r (info->name, info->len, info->type, &info->hostbuf, info->hostbufmem, info->hostbuflen, &info->herr)) == ERANGE) { d(printf ("gethostbyaddr fialed?\n")); -#ifdef ENABLE_THREADS pthread_testcancel (); -#endif info->hostbuflen *= 2; info->hostbufmem = g_realloc (info->hostbufmem, info->hostbuflen); } d(printf ("gethostbyaddr ok?\n")); -#ifdef ENABLE_THREADS if (info->cancelled) { g_free(info->hostbufmem); g_free(info); } else { e_msgport_reply((EMsg *)info); } -#endif + return NULL; } @@ -863,9 +844,7 @@ get_hostbyaddr (void *data) struct hostent * camel_gethostbyaddr (const char *addr, int len, int type, CamelException *exout) { -#ifdef ENABLE_THREADS int fdmax, status, fd, cancel_fd; -#endif struct _lookup_msg *msg; CamelException ex; @@ -886,13 +865,10 @@ camel_gethostbyaddr (const char *addr, int len, int type, CamelException *exout) msg->len = len; msg->type = type; msg->result = -1; - -#ifdef ENABLE_THREADS + cancel_fd = camel_operation_cancel_fd (NULL); if (cancel_fd == -1) { -#endif get_hostbyaddr (msg); -#ifdef ENABLE_THREADS } else { EMsgPort *reply_port; pthread_t id; @@ -936,10 +912,9 @@ camel_gethostbyaddr (const char *addr, int len, int type, CamelException *exout) e_msgport_destroy (reply_port); } -#endif camel_operation_end (NULL); - + if (!camel_exception_is_set(&ex)) { if (msg->result == 0) return &msg->hostbuf; diff --git a/camel/camel-session.c b/camel/camel-session.c index 764cb30a6a..d21ccc3ae8 100644 --- a/camel/camel-session.c +++ b/camel/camel-session.c @@ -28,11 +28,11 @@ #include <config.h> #endif -#include <errno.h> #include <stdio.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> +#include <errno.h> #include "camel-session.h" #include "camel-store.h" @@ -63,12 +63,10 @@ static char *get_storage_path (CamelSession *session, CamelService *service, CamelException *ex); -#ifdef ENABLE_THREADS static void *session_thread_msg_new(CamelSession *session, CamelSessionThreadOps *ops, unsigned int size); static void session_thread_msg_free(CamelSession *session, CamelSessionThreadMsg *msg); static int session_thread_queue(CamelSession *session, CamelSessionThreadMsg *msg, int flags); static void session_thread_wait(CamelSession *session, int id); -#endif /* The vfolder provider is always available */ static CamelProvider vee_provider = { @@ -93,13 +91,12 @@ camel_session_init (CamelSession *session) session->modules = camel_provider_init (); session->providers = g_hash_table_new (camel_strcase_hash, camel_strcase_equal); session->priv = g_malloc0(sizeof(*session->priv)); -#ifdef ENABLE_THREADS + session->priv->lock = g_mutex_new(); session->priv->thread_lock = g_mutex_new(); session->priv->thread_id = 1; session->priv->thread_active = g_hash_table_new(NULL, NULL); session->priv->thread_queue = NULL; -#endif } static gboolean @@ -119,22 +116,19 @@ static void camel_session_finalise (CamelObject *o) { CamelSession *session = (CamelSession *)o; - -#ifdef ENABLE_THREADS + g_hash_table_destroy(session->priv->thread_active); if (session->priv->thread_queue) e_thread_destroy(session->priv->thread_queue); -#endif - + g_free(session->storage_path); g_hash_table_foreach_remove (session->providers, camel_session_destroy_provider, NULL); g_hash_table_destroy (session->providers); - -#ifdef ENABLE_THREADS + g_mutex_free(session->priv->lock); g_mutex_free(session->priv->thread_lock); -#endif + g_free(session->priv); } @@ -147,13 +141,11 @@ camel_session_class_init (CamelSessionClass *camel_session_class) camel_session_class->get_provider = get_provider; camel_session_class->get_service = get_service; camel_session_class->get_storage_path = get_storage_path; - -#ifdef ENABLE_THREADS + camel_session_class->thread_msg_new = session_thread_msg_new; camel_session_class->thread_msg_free = session_thread_msg_free; camel_session_class->thread_queue = session_thread_queue; camel_session_class->thread_wait = session_thread_wait; -#endif vee_provider.object_types[CAMEL_PROVIDER_STORE] = camel_vee_store_get_type (); vee_provider.url_hash = camel_url_hash; @@ -696,8 +688,6 @@ camel_session_get_filter_driver (CamelSession *session, return CS_CLASS (session)->get_filter_driver (session, type, ex); } -#ifdef ENABLE_THREADS - static void *session_thread_msg_new(CamelSession *session, CamelSessionThreadOps *ops, unsigned int size) { CamelSessionThreadMsg *m; @@ -852,5 +842,3 @@ void camel_session_thread_wait(CamelSession *session, int id) CS_CLASS (session)->thread_wait(session, id); } - -#endif diff --git a/camel/camel-store-summary.c b/camel/camel-store-summary.c index f42a66c80b..86e42fc98c 100644 --- a/camel/camel-store-summary.c +++ b/camel/camel-store-summary.c @@ -23,14 +23,14 @@ #include <config.h> #endif +#include <stdlib.h> +#include <string.h> #include <sys/types.h> #include <sys/stat.h> -#include <fcntl.h> #include <unistd.h> #include <ctype.h> -#include <string.h> +#include <fcntl.h> #include <errno.h> -#include <stdlib.h> #include "camel-store-summary.h" @@ -105,13 +105,11 @@ camel_store_summary_init (CamelStoreSummary *s) s->folders = g_ptr_array_new(); s->folders_path = g_hash_table_new(g_str_hash, g_str_equal); - -#ifdef ENABLE_THREADS + p->summary_lock = g_mutex_new(); p->io_lock = g_mutex_new(); p->alloc_lock = g_mutex_new(); p->ref_lock = g_mutex_new(); -#endif } static void @@ -130,14 +128,12 @@ camel_store_summary_finalise (CamelObject *obj) if (s->store_info_chunks) e_memchunk_destroy(s->store_info_chunks); - -#ifdef ENABLE_THREADS + g_mutex_free(p->summary_lock); g_mutex_free(p->io_lock); g_mutex_free(p->alloc_lock); g_mutex_free(p->ref_lock); -#endif - + g_free(p); } diff --git a/camel/camel-store.c b/camel/camel-store.c index 0bc80b43de..eedc9dfa2a 100644 --- a/camel/camel-store.c +++ b/camel/camel-store.c @@ -6,7 +6,7 @@ * Bertrand Guiheneuf <bertrand@helixcode.com> * Dan Winship <danw@ximian.com> * - * Copyright 1999, 2000 Ximian, Inc. (www.ximian.com) + * Copyright 1999-2003 Ximian, Inc. (www.ximian.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -27,9 +27,9 @@ #include <config.h> #endif +#include <string.h> #include <sys/types.h> #include <sys/stat.h> -#include <string.h> #include "camel-session.h" #include "camel-store.h" @@ -138,9 +138,7 @@ camel_store_init (void *o) store->dir_sep = '/'; store->priv = g_malloc0 (sizeof (*store->priv)); -#ifdef ENABLE_THREADS store->priv->folder_lock = e_mutex_new (E_MUTEX_REC); -#endif } static void @@ -151,9 +149,8 @@ camel_store_finalize (CamelObject *object) if (store->folders) camel_object_bag_destroy(store->folders); -#ifdef ENABLE_THREADS e_mutex_destroy (store->priv->folder_lock); -#endif + g_free (store->priv); } diff --git a/camel/camel-tcp-stream-openssl.c b/camel/camel-tcp-stream-openssl.c index f83a6d0d72..c7250a84d1 100644 --- a/camel/camel-tcp-stream-openssl.c +++ b/camel/camel-tcp-stream-openssl.c @@ -32,20 +32,17 @@ #include <openssl/ssl.h> #include <openssl/x509.h> #include <openssl/err.h> +#include <string.h> #include <sys/time.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> -#include <string.h> #include "camel-session.h" #include "camel-service.h" #include "camel-operation.h" #include "camel-certdb.h" -#ifdef ENABLE_THREADS -#include <pthread.h> -#endif #define d(x) diff --git a/camel/camel-text-index.c b/camel/camel-text-index.c index 3682a6633e..fd10a5ce5f 100644 --- a/camel/camel-text-index.c +++ b/camel/camel-text-index.c @@ -1,6 +1,6 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; fill-column: 160 -*- */ /* - * Copyright (C) 2001 Ximian Inc. + * Copyright (C) 2001-2003 Ximian Inc. * * Authors: Michael Zucchi <notzed@ximian.com> * @@ -23,17 +23,16 @@ #include <config.h> #endif -#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> #include <sys/stat.h> #include <sys/uio.h> #include <unistd.h> #include <errno.h> -#include <string.h> -#include <stdlib.h> - -#include <sys/types.h> -#include <sys/stat.h> #include <fcntl.h> +#include <ctype.h> #include "e-util/e-msgport.h" #include "e-util/e-memory.h" @@ -46,7 +45,6 @@ #include <glib/gunicode.h> -#include <stdio.h> #define w(x) #define io(x) @@ -55,13 +53,8 @@ /* cursor debug */ #define c(x) -#ifdef ENABLE_THREADS #define CAMEL_TEXT_INDEX_LOCK(kf, lock) (e_mutex_lock(((CamelTextIndex *)kf)->priv->lock)) #define CAMEL_TEXT_INDEX_UNLOCK(kf, lock) (e_mutex_unlock(((CamelTextIndex *)kf)->priv->lock)) -#else -#define CAMEL_TEXT_INDEX_LOCK(kf, lock) -#define CAMEL_TEXT_INDEX_UNLOCK(kf, lock) -#endif static int text_index_compress_nosync(CamelIndex *idx); @@ -130,9 +123,7 @@ struct _CamelTextIndexPrivate { int word_cache_count; EDList word_cache; GHashTable *words; -#ifdef ENABLE_THREADS EMutex *lock; -#endif }; /* Root block of text index */ @@ -766,10 +757,8 @@ camel_text_index_init(CamelTextIndex *idx) /* this cache size and the block cache size have been tuned for about the best with moderate memory usage. Doubling the memory usage barely affects performance. */ p->word_cache_limit = 4096; /* 1024 = 128K */ - -#ifdef ENABLE_THREADS + p->lock = e_mutex_new(E_MUTEX_REC); -#endif } static void @@ -797,11 +786,9 @@ camel_text_index_finalise(CamelTextIndex *idx) camel_object_unref((CamelObject *)p->blocks); if (p->links) camel_object_unref((CamelObject *)p->links); - -#ifdef ENABLE_THREADS + e_mutex_destroy(p->lock); -#endif - + g_free(p); } diff --git a/camel/camel-transport.c b/camel/camel-transport.c index ca241d95a6..a708b1757d 100644 --- a/camel/camel-transport.c +++ b/camel/camel-transport.c @@ -59,9 +59,7 @@ camel_transport_init (gpointer object, gpointer klass) CamelTransport *xport = object; xport->priv = g_malloc0 (sizeof (struct _CamelTransportPrivate)); -#ifdef ENABLE_THREADS xport->priv->send_lock = g_mutex_new (); -#endif } static void @@ -69,9 +67,7 @@ camel_transport_finalize (CamelObject *object) { CamelTransport *xport = CAMEL_TRANSPORT (object); -#ifdef ENABLE_THREADS g_mutex_free (xport->priv->send_lock); -#endif g_free (xport->priv); } diff --git a/camel/camel-vee-folder.c b/camel/camel-vee-folder.c index 805f800b60..c17f7a0bde 100644 --- a/camel/camel-vee-folder.c +++ b/camel/camel-vee-folder.c @@ -1,5 +1,6 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - * Copyright (C) 2000 Ximian Inc. + * Copyright (C) 2000-2003 Ximian Inc. * * Authors: Michael Zucchi <notzed@ximian.com> * Jeffrey Stedfast <fejj@ximian.com> @@ -24,6 +25,7 @@ #endif #include <string.h> +#include <pthread.h> #include "camel-exception.h" #include "camel-vee-folder.h" @@ -87,16 +89,11 @@ static CamelFolderClass *camel_vee_folder_parent; /* use folder_unmatched->summary_lock for access to unmatched_uids or appropriate internals, for consistency */ static CamelVeeFolder *folder_unmatched; static GHashTable *unmatched_uids; /* a refcount of uid's that are matched by any rules */ -#ifdef ENABLE_THREADS -#include <pthread.h> static pthread_mutex_t unmatched_lock = PTHREAD_MUTEX_INITIALIZER; /* only used to initialise folder_unmatched */ #define UNMATCHED_LOCK() pthread_mutex_lock(&unmatched_lock) #define UNMATCHED_UNLOCK() pthread_mutex_unlock(&unmatched_lock) -#else -#define UNMATCHED_LOCK() -#define UNMATCHED_UNLOCK() -#endif + CamelType camel_vee_folder_get_type (void) @@ -164,13 +161,10 @@ camel_vee_folder_init (CamelVeeFolder *obj) obj->changes = camel_folder_change_info_new(); obj->search = camel_folder_search_new(); - -#ifdef ENABLE_THREADS + p->summary_lock = g_mutex_new(); p->subfolder_lock = g_mutex_new(); p->changed_lock = g_mutex_new(); -#endif - } static void @@ -206,12 +200,11 @@ camel_vee_folder_finalise (CamelObject *obj) camel_folder_change_info_free(vf->changes); camel_object_unref((CamelObject *)vf->search); - -#ifdef ENABLE_THREADS + g_mutex_free(p->summary_lock); g_mutex_free(p->subfolder_lock); g_mutex_free(p->changed_lock); -#endif + g_free(p); } @@ -1367,9 +1360,7 @@ folder_changed_change_uid(CamelFolder *sub, const char *uid, const char hash[8], } struct _folder_changed_msg { -#ifdef ENABLE_THREADS CamelSessionThreadMsg msg; -#endif CamelFolderChangeInfo *changes; CamelFolder *sub; CamelVeeFolder *vf; @@ -1600,20 +1591,17 @@ folder_changed_free(CamelSession *session, CamelSessionThreadMsg *msg) camel_object_unref((CamelObject *)m->sub); } -#ifdef ENABLE_THREADS static CamelSessionThreadOps folder_changed_ops = { folder_changed_change, folder_changed_free, }; -#endif static void folder_changed(CamelFolder *sub, CamelFolderChangeInfo *changes, CamelVeeFolder *vf) { struct _folder_changed_msg *m; CamelSession *session = ((CamelService *)((CamelFolder *)vf)->parent_store)->session; - -#ifdef ENABLE_THREADS + m = camel_session_thread_msg_new(session, &folder_changed_ops, sizeof(*m)); m->changes = camel_folder_change_info_new(); camel_folder_change_info_cat(m->changes, changes); @@ -1622,15 +1610,6 @@ folder_changed(CamelFolder *sub, CamelFolderChangeInfo *changes, CamelVeeFolder m->vf = vf; camel_object_ref((CamelObject *)vf); camel_session_thread_queue(session, &m->msg, 0); -#else - m = g_malloc(sizeof(*m)); - m->changes = changes; - m->sub = sub; - m->vf = vf; - folder_changed_change(session, &m->msg); - folder_changed_free(&m->msg); - g_free(m); -#endif } /* track flag changes in the summary, we just promote it to a folder_changed event */ diff --git a/camel/camel.c b/camel/camel.c index c225044a92..bebc1bbecc 100644 --- a/camel/camel.c +++ b/camel/camel.c @@ -1,27 +1,27 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* +/* + * Authors: Jeffrey Stedfast <fejj@ximian.com> + * Bertrand Guiheneuf <bertrand@helixcode.com> * - * Author : - * Bertrand Guiheneuf <bertrand@helixcode.com> + * Copyright 1999-2003 Ximian, Inc. (www.ximian.com) * - * Copyright 1999, 2000 Ximian, Inc. (www.ximian.com) + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA */ + #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -59,25 +59,17 @@ camel_shutdown (void) } } -gint +int camel_init (const char *configdir, gboolean nss_init) { CamelCertDB *certdb; char *path; -#ifdef ENABLE_THREADS -#ifdef G_THREADS_ENABLED - /*g_thread_init (NULL);*/ -#else /* G_THREADS_ENABLED */ - g_warning ("Threads are not supported by your version of glib"); -#endif /* G_THREADS_ENABLED */ -#endif /* ENABLE_THREADS */ - if (getenv ("CAMEL_VERBOSE_DEBUG")) camel_verbose_debug = TRUE; /* initialise global camel_object_type */ - camel_object_get_type(); + camel_object_get_type (); camel_mime_utils_init (); |