Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/ChangeLog,v
retrieving revision 1.418
diff -u -p -r1.418 ChangeLog
--- ChangeLog	4 Sep 2006 11:33:54 -0000	1.418
+++ ChangeLog	15 Sep 2006 20:08:57 -0000
@@ -1,3 +1,11 @@
+2006-09-14  Matthew Barnes  <mbarnes@redhat.com>
+
+	Fixes #356177
+
+	* libedataserver/e-msgport.c:
+	* libedataserver/e-msgport.h:
+	Remove EMutex (use GStaticMutex or GStaticRecMutex instead).
+
 2006-09-04  Harish Krishnaswamy  <kharish@novell.com>
 
 	* NEWS, configure.in: Evolution-Data-Server 1.8.0
Index: camel/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/ChangeLog,v
retrieving revision 1.2553
diff -u -p -r1.2553 ChangeLog
--- camel/ChangeLog	28 Aug 2006 17:24:46 -0000	1.2553
+++ camel/ChangeLog	15 Sep 2006 20:09:05 -0000
@@ -1,3 +1,26 @@
+2006-09-14  Matthew Barnes  <mbarnes@redhat.com>
+
+	Fixes #356177
+
+	* camel-folder.c:
+	* camel-object.c:
+	* camel-private.h:
+	* camel-provider.c:
+	* camel-service.c:
+	* camel-store.c:
+	* camel-text-index.c:
+	* providers/groupwise/camel-groupwise-folder.c:
+	* providers/groupwise/camel-groupwise-private.h:
+	* providers/groupwise/camel-groupwise-store.c:
+	* providers/imap/camel-imap-command.c:
+	* providers/imap/camel-imap-folder.c:
+	* providers/imap/camel-imap-private.h:
+	* providers/imap/camel-imap-store.c:
+	* providers/nntp/camel-nntp-folder.c:
+	* providers/nntp/camel-nntp-store.c:
+	Use GStaticMutex or GStaticRecMutex instead of EMutex.
+	Define LOCK/UNLOCK macros specifically for recursive mutexes.
+
 2006-08-28  Veerapuram Varadhan  <vvaradhan@novell.com>
 
 	** Fixes bug #331099 based on patches by Eric Anholt
Index: camel/camel-folder.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-folder.c,v
retrieving revision 1.215
diff -u -p -r1.215 camel-folder.c
--- camel/camel-folder.c	15 Jun 2006 15:22:10 -0000	1.215
+++ camel/camel-folder.c	15 Sep 2006 20:09:07 -0000
@@ -171,8 +171,8 @@ camel_folder_init (gpointer object, gpoi
 	folder->priv = g_malloc0(sizeof(*folder->priv));
 	folder->priv->frozen = 0;
 	folder->priv->changed_frozen = camel_folder_change_info_new();
-	folder->priv->lock = e_mutex_new(E_MUTEX_REC);
-	folder->priv->change_lock = e_mutex_new(E_MUTEX_SIMPLE);
+	g_static_rec_mutex_init(&folder->priv->lock);
+	g_static_mutex_init(&folder->priv->change_lock);
 }
 
 static void
@@ -193,8 +193,8 @@ camel_folder_finalize (CamelObject *obje
 
 	camel_folder_change_info_free(p->changed_frozen);
 	
-	e_mutex_destroy(p->lock);
-	e_mutex_destroy(p->change_lock);
+	g_static_rec_mutex_free(&p->lock);
+	g_static_mutex_free(&p->change_lock);
 	
 	g_free(p);
 }
@@ -267,12 +267,12 @@ camel_folder_sync (CamelFolder *folder, 
 {
 	g_return_if_fail (CAMEL_IS_FOLDER (folder));
 
-	CAMEL_FOLDER_LOCK(folder, lock);
+	CAMEL_FOLDER_REC_LOCK(folder, lock);
 	
 	if (!(folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED))
 		CF_CLASS (folder)->sync (folder, expunge, ex);
 	
-	CAMEL_FOLDER_UNLOCK(folder, lock);
+	CAMEL_FOLDER_REC_UNLOCK(folder, lock);
 }
 
 
@@ -529,12 +529,12 @@ camel_folder_expunge (CamelFolder *folde
 {
 	g_return_if_fail (CAMEL_IS_FOLDER (folder));
 	
-	CAMEL_FOLDER_LOCK(folder, lock);
+	CAMEL_FOLDER_REC_LOCK(folder, lock);
 	
 	if (!(folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED))
 		CF_CLASS (folder)->expunge (folder, ex);
 	
-	CAMEL_FOLDER_UNLOCK(folder, lock);
+	CAMEL_FOLDER_REC_UNLOCK(folder, lock);
 }
 
 static int
@@ -643,11 +643,11 @@ camel_folder_append_message (CamelFolder
 {
 	g_return_if_fail (CAMEL_IS_FOLDER (folder));
 
-	CAMEL_FOLDER_LOCK(folder, lock);
+	CAMEL_FOLDER_REC_LOCK(folder, lock);
 
 	CF_CLASS (folder)->append_message (folder, message, info, appended_uid, ex);
 
-	CAMEL_FOLDER_UNLOCK(folder, lock);
+	CAMEL_FOLDER_REC_UNLOCK(folder, lock);
 }
 
 
@@ -1065,11 +1065,11 @@ camel_folder_get_message (CamelFolder *f
 
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
 
-	CAMEL_FOLDER_LOCK(folder, lock);
+	CAMEL_FOLDER_REC_LOCK(folder, lock);
 
 	ret = CF_CLASS (folder)->get_message (folder, uid, ex);
 
-	CAMEL_FOLDER_UNLOCK(folder, lock);
+	CAMEL_FOLDER_REC_UNLOCK(folder, lock);
 
 	if (ret && camel_debug_start(":folder")) {
 		printf("CamelFolder:get_message('%s', '%s') =\n", folder->full_name, uid);
@@ -1474,9 +1474,9 @@ camel_folder_delete (CamelFolder *folder
 {
 	g_return_if_fail (CAMEL_IS_FOLDER (folder));
 	
-	CAMEL_FOLDER_LOCK (folder, lock);
+	CAMEL_FOLDER_REC_LOCK (folder, lock);
 	if (folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED) {
-		CAMEL_FOLDER_UNLOCK (folder, lock);
+		CAMEL_FOLDER_REC_UNLOCK (folder, lock);
 		return;
 	}
 	
@@ -1484,7 +1484,7 @@ camel_folder_delete (CamelFolder *folder
 	
 	CF_CLASS (folder)->delete (folder);
 
-	CAMEL_FOLDER_UNLOCK (folder, lock);
+	CAMEL_FOLDER_REC_UNLOCK (folder, lock);
 
 	camel_object_trigger_event (folder, "deleted", NULL);
 }
Index: camel/camel-object.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-object.c,v
retrieving revision 1.61
diff -u -p -r1.61 camel-object.c
--- camel/camel-object.c	28 Aug 2006 17:24:59 -0000	1.61
+++ camel/camel-object.c	15 Sep 2006 20:09:08 -0000
@@ -52,7 +52,7 @@
 
 /* A 'locked' hooklist, that is only allocated on demand */
 typedef struct _CamelHookList {
-	EMutex *lock;
+	GStaticRecMutex lock;
 
 	unsigned int depth:30;	/* recursive event depth */
 	unsigned int flags:2;	/* flags, see below */
@@ -125,7 +125,8 @@ static CamelHookList *camel_object_get_h
 static void camel_object_free_hooks(CamelObject *o);
 static void camel_object_bag_remove_unlocked(CamelObjectBag *inbag, CamelObject *o, CamelHookList *hooks);
 
-#define camel_object_unget_hooks(o) (e_mutex_unlock((CAMEL_OBJECT(o)->hooks->lock)))
+#define camel_object_unget_hooks(o) \
+	(g_static_rec_mutex_unlock(&CAMEL_OBJECT(o)->hooks->lock))
 
 
 /* ********************************************************************** */
@@ -137,7 +138,7 @@ static EMemChunk *hook_chunks;
 static unsigned int pair_id = 1;
 
 /* type-lock must be recursive, for atomically creating classes */
-static EMutex *type_lock;
+static GStaticRecMutex type_lock = G_STATIC_REC_MUTEX_INIT;
 /* ref-lock must be global :-(  for object bags to work */
 static GMutex *ref_lock;
 
@@ -150,12 +151,12 @@ CamelType camel_interface_type;
 
 #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)))
 #define REF_LOCK() (g_mutex_lock(ref_lock))
 #define REF_UNLOCK() (g_mutex_unlock(ref_lock))
+#define TYPE_LOCK() (g_static_rec_mutex_lock(&type_lock))
+#define TYPE_UNLOCK() (g_static_rec_mutex_unlock(&type_lock))
 
 static struct _CamelHookPair *
 pair_alloc(void)
@@ -216,7 +217,6 @@ camel_type_init(void)
 	init = TRUE;
 	pair_chunks = e_memchunk_new(16, sizeof(CamelHookPair));
 	hook_chunks = e_memchunk_new(16, sizeof(CamelHookList));
-	type_lock = e_mutex_new(E_MUTEX_REC);
 	type_chunks = e_memchunk_new(32, sizeof(CamelType));
 	type_table = g_hash_table_new(NULL, NULL);
 	ref_lock = g_mutex_new();
@@ -723,7 +723,7 @@ co_type_register(CamelType parent, const
 	/*int offset;
 	  size_t size;*/
 
-	E_LOCK(type_lock);
+	TYPE_LOCK();
 
 	/* Have to check creation, it might've happened in another thread before we got here */
 	klass = g_hash_table_lookup(type_table, name);
@@ -734,7 +734,7 @@ co_type_register(CamelType parent, const
 			g_warning("camel_type_register: Trying to re-register class '%s'", name);
 			klass = NULL;
 		}
-		E_UNLOCK(type_lock);
+		TYPE_UNLOCK();
 		return klass;
 	}
 
@@ -758,7 +758,7 @@ co_type_register(CamelType parent, const
 	if (parent
 	    && klass_size < parent->klass_size) {
 		g_warning("camel_type_register: '%s' has smaller class size than parent '%s'", name, parent->name);
-		E_UNLOCK(type_lock);
+		TYPE_UNLOCK();
 		return NULL;
 	}
 
@@ -789,7 +789,7 @@ co_type_register(CamelType parent, const
 
 	camel_type_class_init(klass, klass);
 
-	E_UNLOCK(type_lock);
+	TYPE_UNLOCK();
 
 	return klass;
 }
@@ -1254,7 +1254,7 @@ camel_object_free_hooks(CamelObject *o)
 			pair_free(pair);
 			pair = next;
 		}
-		e_mutex_destroy(o->hooks->lock);
+		g_static_rec_mutex_free(&o->hooks->lock);
 		hooks_free(o->hooks);
 		o->hooks = NULL;
 	}
@@ -1273,7 +1273,7 @@ camel_object_get_hooks(CamelObject *o)
 		pthread_mutex_lock(&lock);
 		if (o->hooks == NULL) {
 			hooks = hooks_alloc();
-			hooks->lock = e_mutex_new(E_MUTEX_REC);
+			g_static_rec_mutex_init(&hooks->lock);
 			hooks->flags = 0;
 			hooks->depth = 0;
 			hooks->list_length = 0;
@@ -1283,7 +1283,7 @@ camel_object_get_hooks(CamelObject *o)
 		pthread_mutex_unlock(&lock);
 	}
 	
-	e_mutex_lock(o->hooks->lock);
+	g_static_rec_mutex_lock(&o->hooks->lock);
 	
 	return o->hooks;	
 }
Index: camel/camel-private.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-private.h,v
retrieving revision 1.37
diff -u -p -r1.37 camel-private.h
--- camel/camel-private.h	8 Dec 2005 08:59:32 -0000	1.37
+++ camel/camel-private.h	15 Sep 2006 20:09:09 -0000
@@ -39,23 +39,31 @@ extern "C" {
 #include <libedataserver/e-msgport.h>
 
 struct _CamelFolderPrivate {
-	EMutex *lock;
-	EMutex *change_lock;
+	GStaticRecMutex lock;
+	GStaticMutex change_lock;
 	/* must require the 'change_lock' to access this */
 	int frozen;
 	struct _CamelFolderChangeInfo *changed_frozen; /* queues changed events */
 };
 
-#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))
+#define CAMEL_FOLDER_LOCK(f, l) \
+	(g_static_mutex_lock(&((CamelFolder *)f)->priv->l))
+#define CAMEL_FOLDER_UNLOCK(f, l) \
+	(g_static_mutex_unlock(&((CamelFolder *)f)->priv->l))
+#define CAMEL_FOLDER_REC_LOCK(f, l) \
+	(g_static_rec_mutex_lock(&((CamelFolder *)f)->priv->l))
+#define CAMEL_FOLDER_REC_UNLOCK(f, l) \
+	(g_static_rec_mutex_unlock(&((CamelFolder *)f)->priv->l))
 
 
 struct _CamelStorePrivate {
-	EMutex *folder_lock;	/* for locking folder operations */
+	GStaticRecMutex folder_lock;	/* for locking folder operations */
 };
 
-#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))
+#define CAMEL_STORE_LOCK(f, l) \
+	(g_static_rec_mutex_lock(&((CamelStore *)f)->priv->l))
+#define CAMEL_STORE_UNLOCK(f, l) \
+	(g_static_rec_mutex_unlock(&((CamelStore *)f)->priv->l))
 
 
 struct _CamelTransportPrivate {
@@ -67,13 +75,18 @@ struct _CamelTransportPrivate {
 
 
 struct _CamelServicePrivate {
-	EMutex *connect_lock;	/* for locking connection operations */
-	EMutex *connect_op_lock;/* for locking the connection_op */
+	GStaticRecMutex connect_lock;	/* for locking connection operations */
+	GStaticMutex connect_op_lock;	/* for locking the connection_op */
 };
 
-#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))
+#define CAMEL_SERVICE_LOCK(f, l) \
+	(g_static_mutex_lock(&((CamelService *)f)->priv->l))
+#define CAMEL_SERVICE_UNLOCK(f, l) \
+	(g_static_mutex_unlock(&((CamelService *)f)->priv->l))
+#define CAMEL_SERVICE_REC_LOCK(f, l) \
+	(g_static_rec_mutex_lock(&((CamelService *)f)->priv->l))
+#define CAMEL_SERVICE_REC_UNLOCK(f, l) \
+	(g_static_rec_mutex_unlock(&((CamelService *)f)->priv->l))
 
 
 struct _CamelSessionPrivate {
Index: camel/camel-provider.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-provider.c,v
retrieving revision 1.41
diff -u -p -r1.41 camel-provider.c
--- camel/camel-provider.c	30 Nov 2005 09:54:54 -0000	1.41
+++ camel/camel-provider.c	15 Sep 2006 20:09:09 -0000
@@ -51,10 +51,10 @@
 static GHashTable *module_table;
 /* table of CamelProvider's */
 static GHashTable *provider_table;
-static EMutex *provider_lock;
+static GStaticRecMutex provider_lock = G_STATIC_REC_MUTEX_INIT;
 
-#define LOCK() e_mutex_lock(provider_lock);
-#define UNLOCK() e_mutex_unlock(provider_lock);
+#define LOCK()		(g_static_rec_mutex_lock(&provider_lock))
+#define UNLOCK()	(g_static_rec_mutex_unlock(&provider_lock))
 
 /* The vfolder provider is always available */
 static CamelProvider vee_provider = {
@@ -76,7 +76,6 @@ static pthread_once_t setup_once = PTHRE
 static void
 provider_setup(void)
 {
-	provider_lock = e_mutex_new(E_MUTEX_REC);
 	module_table = g_hash_table_new(camel_strcase_hash, camel_strcase_equal);
 	provider_table = g_hash_table_new(camel_strcase_hash, camel_strcase_equal);
 
Index: camel/camel-service.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-service.c,v
retrieving revision 1.104
diff -u -p -r1.104 camel-service.c
--- camel/camel-service.c	16 Jan 2006 20:12:34 -0000	1.104
+++ camel/camel-service.c	15 Sep 2006 20:09:09 -0000
@@ -93,8 +93,8 @@ camel_service_init (void *o, void *k)
 	CamelService *service = o;
 	
 	service->priv = g_malloc0(sizeof(*service->priv));
-	service->priv->connect_lock = e_mutex_new(E_MUTEX_REC);
-	service->priv->connect_op_lock = e_mutex_new(E_MUTEX_SIMPLE);
+	g_static_rec_mutex_init(&service->priv->connect_lock);
+	g_static_mutex_init(&service->priv->connect_op_lock);
 }
 
 static void
@@ -119,8 +119,8 @@ camel_service_finalize (CamelObject *obj
 	if (service->session)
 		camel_object_unref (service->session);
 	
-	e_mutex_destroy (service->priv->connect_lock);
-	e_mutex_destroy (service->priv->connect_op_lock);
+	g_static_rec_mutex_free (&service->priv->connect_lock);
+	g_static_mutex_free (&service->priv->connect_op_lock);
 	
 	g_free (service->priv);
 }
@@ -346,10 +346,10 @@ camel_service_connect (CamelService *ser
 	g_return_val_if_fail (service->session != NULL, FALSE);
 	g_return_val_if_fail (service->url != NULL, FALSE);
 	
-	CAMEL_SERVICE_LOCK (service, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (service, connect_lock);
 	
 	if (service->status == CAMEL_SERVICE_CONNECTED) {
-		CAMEL_SERVICE_UNLOCK (service, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
 		return TRUE;
 	}
 
@@ -379,7 +379,7 @@ camel_service_connect (CamelService *ser
 	}
 	CAMEL_SERVICE_UNLOCK (service, connect_op_lock);
 
-	CAMEL_SERVICE_UNLOCK (service, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
 	
 	return ret;
 }
@@ -415,7 +415,7 @@ camel_service_disconnect (CamelService *
 	gboolean res = TRUE;
 	int unreg = FALSE;
 
-	CAMEL_SERVICE_LOCK (service, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (service, connect_lock);
 	
 	if (service->status != CAMEL_SERVICE_DISCONNECTED
 	    && service->status != CAMEL_SERVICE_DISCONNECTING) {
@@ -441,7 +441,7 @@ camel_service_disconnect (CamelService *
 		CAMEL_SERVICE_UNLOCK (service, connect_op_lock);
 	}
 	
-	CAMEL_SERVICE_UNLOCK (service, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
 	
 		service->status = CAMEL_SERVICE_DISCONNECTED;
 	return res;
@@ -638,9 +638,9 @@ camel_service_query_auth_types (CamelSer
 	
 	/* note that we get the connect lock here, which means the callee
 	   must not call the connect functions itself */
-	CAMEL_SERVICE_LOCK (service, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (service, connect_lock);
 	ret = CSERV_CLASS (service)->query_auth_types (service, ex);
-	CAMEL_SERVICE_UNLOCK (service, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
 	
 	return ret;
 }
Index: camel/camel-store.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-store.c,v
retrieving revision 1.173
diff -u -p -r1.173 camel-store.c
--- camel/camel-store.c	12 Apr 2006 19:14:13 -0000	1.173
+++ camel/camel-store.c	15 Sep 2006 20:09:10 -0000
@@ -140,7 +140,7 @@ camel_store_init (void *o)
 	store->mode = CAMEL_STORE_READ|CAMEL_STORE_WRITE;
 
 	store->priv = g_malloc0 (sizeof (*store->priv));
-	store->priv->folder_lock = e_mutex_new (E_MUTEX_REC);
+	g_static_rec_mutex_init (&store->priv->folder_lock);
 }
 
 static void
@@ -151,7 +151,7 @@ camel_store_finalize (CamelObject *objec
 	if (store->folders)
 		camel_object_bag_destroy(store->folders);
 	
-	e_mutex_destroy (store->priv->folder_lock);
+	g_static_rec_mutex_free (&store->priv->folder_lock);
 	
 	g_free (store->priv);
 }
@@ -472,7 +472,7 @@ camel_store_rename_folder (CamelStore *s
 				&& strncmp(folder->full_name, old_name, oldlen) == 0
 				&& folder->full_name[oldlen] == '/')) {
 				d(printf("Found subfolder of '%s' == '%s'\n", old_name, folder->full_name));
-				CAMEL_FOLDER_LOCK(folder, lock);
+				CAMEL_FOLDER_REC_LOCK(folder, lock);
 			} else {
 				g_ptr_array_remove_index_fast(folders, i);
 				i--;
@@ -499,7 +499,7 @@ camel_store_rename_folder (CamelStore *s
 			camel_folder_rename(folder, new);
 			g_free(new);
 
-			CAMEL_FOLDER_UNLOCK(folder, lock);
+			CAMEL_FOLDER_REC_UNLOCK(folder, lock);
 			camel_object_unref(folder);
 		}
 
@@ -517,7 +517,7 @@ camel_store_rename_folder (CamelStore *s
 		/* Failed, just unlock our folders for re-use */
 		for (i=0;i<folders->len;i++) {
 			folder = folders->pdata[i];
-			CAMEL_FOLDER_UNLOCK(folder, lock);
+			CAMEL_FOLDER_REC_UNLOCK(folder, lock);
 			camel_object_unref(folder);
 		}
 	}
Index: camel/camel-text-index.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-text-index.c,v
retrieving revision 1.25
diff -u -p -r1.25 camel-text-index.c
--- camel/camel-text-index.c	12 Apr 2006 19:14:13 -0000	1.25
+++ camel/camel-text-index.c	15 Sep 2006 20:09:12 -0000
@@ -55,8 +55,10 @@
 
 #define CAMEL_TEXT_INDEX_MAX_WORDLEN  (36)
 
-#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))
+#define CAMEL_TEXT_INDEX_LOCK(kf, lock) \
+	(g_static_rec_mutex_lock(&((CamelTextIndex *)kf)->priv->lock))
+#define CAMEL_TEXT_INDEX_UNLOCK(kf, lock) \
+	(g_static_rec_mutex_unlock(&((CamelTextIndex *)kf)->priv->lock))
 
 static int text_index_compress_nosync(CamelIndex *idx);
 
@@ -125,7 +127,7 @@ struct _CamelTextIndexPrivate {
 	int word_cache_count;
 	EDList word_cache;
 	GHashTable *words;
-	EMutex *lock;
+	GStaticRecMutex lock;
 };
 
 /* Root block of text index */
@@ -760,7 +762,7 @@ camel_text_index_init(CamelTextIndex *id
 	   with moderate memory usage.  Doubling the memory usage barely affects performance. */
 	p->word_cache_limit = 4096; /* 1024 = 128K */
 	
-	p->lock = e_mutex_new(E_MUTEX_REC);
+	g_static_rec_mutex_init(&p->lock);
 }
 
 static void
@@ -789,7 +791,7 @@ camel_text_index_finalise(CamelTextIndex
 	if (p->links)
 		camel_object_unref((CamelObject *)p->links);
 	
-	e_mutex_destroy(p->lock);
+	g_static_rec_mutex_free(&p->lock);
 	
 	g_free(p);
 }
Index: camel/providers/groupwise/camel-groupwise-folder.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/groupwise/camel-groupwise-folder.c,v
retrieving revision 1.142
diff -u -p -r1.142 camel-groupwise-folder.c
--- camel/providers/groupwise/camel-groupwise-folder.c	28 Aug 2006 15:12:28 -0000	1.142
+++ camel/providers/groupwise/camel-groupwise-folder.c	15 Sep 2006 20:09:14 -0000
@@ -68,8 +68,8 @@ static CamelOfflineFolderClass *parent_c
 struct _CamelGroupwiseFolderPrivate {
 
 #ifdef ENABLE_THREADS
-	EMutex *search_lock;    /* for locking the search object */
-	EMutex *cache_lock;     /* for locking the cache object */
+	GStaticMutex search_lock;	/* for locking the search object */
+	GStaticRecMutex cache_lock;	/* for locking the cache object */
 #endif
 
 };
@@ -186,7 +186,7 @@ groupwise_folder_get_message( CamelFolde
 		goto end; /*Dont cache if its sent items, since we need to Track Status*/
 
 	/* add to cache */
-	CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
+	CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
 	if ((cache_stream = camel_data_cache_add (gw_folder->cache, "cache", uid, NULL))) {
 		if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg, cache_stream) == -1
 				|| camel_stream_flush (cache_stream) == -1)
@@ -194,7 +194,7 @@ groupwise_folder_get_message( CamelFolde
 		camel_object_unref (cache_stream);
 	}
 
-	CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
+	CAMEL_GROUPWISE_FOLDER_REC_UNLOCK (folder, cache_lock);
 
 end:
 	camel_message_info_free (&mi->info);
@@ -414,10 +414,10 @@ groupwise_folder_rename (CamelFolder *fo
 
 	summary_path = g_strdup_printf ("%s/summary", folder_dir);
 
-	CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
+	CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
 	g_free (gw_folder->cache->path);
 	gw_folder->cache->path = g_strdup (folder_dir);
-	CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
+	CAMEL_GROUPWISE_FOLDER_REC_UNLOCK (folder, cache_lock);
 
 	((CamelFolderClass *)parent_class)->rename(folder, new);
 	camel_folder_summary_set_filename (folder->summary, summary_path);
@@ -436,7 +436,7 @@ groupwise_folder_search_by_expression (C
 	CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER(folder);
 	GPtrArray *matches;
 
-	CAMEL_GROUPWISE_FOLDER_LOCK(folder, search_lock);
+	CAMEL_GROUPWISE_FOLDER_LOCK(gw_folder, search_lock);
 	camel_folder_search_set_folder (gw_folder->search, folder);
 	matches = camel_folder_search_search(gw_folder->search, expression, NULL, ex);
 	CAMEL_GROUPWISE_FOLDER_UNLOCK(gw_folder, search_lock);
@@ -453,7 +453,7 @@ groupwise_folder_search_by_uids(CamelFol
 	if (uids->len == 0)
 		return g_ptr_array_new();
 
-	CAMEL_GROUPWISE_FOLDER_LOCK(folder, search_lock);
+	CAMEL_GROUPWISE_FOLDER_LOCK(gw_folder, search_lock);
 
 	camel_folder_search_set_folder(gw_folder->search, folder);
 	matches = camel_folder_search_search(gw_folder->search, expression, uids, ex);
@@ -470,7 +470,7 @@ groupwise_folder_search_free (CamelFolde
 
 	g_return_if_fail (gw_folder->search);
 
-	CAMEL_GROUPWISE_FOLDER_LOCK(folder, search_lock);
+	CAMEL_GROUPWISE_FOLDER_LOCK(gw_folder, search_lock);
 
 	camel_folder_search_free_result (gw_folder->search, uids);
 
@@ -613,16 +613,16 @@ groupwise_sync (CamelFolder *folder, gbo
 
 	container_id =  camel_groupwise_store_container_id_lookup (gw_store, folder->full_name) ;
 
-	CAMEL_SERVICE_LOCK (gw_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
 	if (!camel_groupwise_store_connected (gw_store, ex)) {
-		CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 		camel_exception_clear (ex);
 		return;
 	}
-	CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 
 	count = camel_folder_summary_count (folder->summary);
-	CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
+	CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
 	for (i=0 ; i < count ; i++) {
 		guint32 flags = 0;
 		info = camel_folder_summary_index (folder->summary, i);
@@ -672,17 +672,17 @@ groupwise_sync (CamelFolder *folder, gbo
 					}
 
 					if (g_list_length (deleted_items) == GROUPWISE_BULK_DELETE_LIMIT ) {
-						CAMEL_SERVICE_LOCK (gw_store, connect_lock);
+						CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
 						status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
-						CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+						CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 						if (status == E_GW_CONNECTION_STATUS_OK) {
 							char *uid;
 							while (deleted_items) {
 								uid = (char *)deleted_items->data;
-								CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
+								CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
 								camel_folder_summary_remove_uid (folder->summary, uid);
 								camel_data_cache_remove(gw_folder->cache, "cache", uid, ex);
-								CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
+								CAMEL_GROUPWISE_FOLDER_REC_UNLOCK (folder, cache_lock);
 								deleted_items = g_list_next (deleted_items);
 								count -= GROUPWISE_BULK_DELETE_LIMIT;
 								i -= GROUPWISE_BULK_DELETE_LIMIT;
@@ -695,24 +695,24 @@ groupwise_sync (CamelFolder *folder, gbo
 		camel_message_info_free (info);
 	}
 	
-	CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
+	CAMEL_GROUPWISE_FOLDER_REC_UNLOCK (folder, cache_lock);
 
 	if (deleted_items) {
-		CAMEL_SERVICE_LOCK (gw_store, connect_lock);
+		CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
 		if (!strcmp (folder->full_name, "Trash")) {
 			status = e_gw_connection_purge_selected_items (cnc, deleted_items);
 		} else {
 			status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
 		}
-		CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 		if (status == E_GW_CONNECTION_STATUS_OK) {
 			char *uid;
 			while (deleted_items) {
 				uid = (char *)deleted_items->data;
-				CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
+				CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
 				camel_folder_summary_remove_uid (folder->summary, uid);
 				camel_data_cache_remove(gw_folder->cache, "cache", uid, ex);
-				CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
+				CAMEL_GROUPWISE_FOLDER_REC_UNLOCK (folder, cache_lock);
 				deleted_items = g_list_next (deleted_items);
 				count -= GROUPWISE_BULK_DELETE_LIMIT;
 				i -= GROUPWISE_BULK_DELETE_LIMIT;
@@ -722,23 +722,23 @@ groupwise_sync (CamelFolder *folder, gbo
 	}
 
 	if (read_items && g_list_length (read_items)) {
-		CAMEL_SERVICE_LOCK (gw_store, connect_lock);
+		CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
 		e_gw_connection_mark_read (cnc, read_items);
-		CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 	}
 
 	if (expunge) {
-		CAMEL_SERVICE_LOCK (gw_store, connect_lock);
+		CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
 		status = e_gw_connection_purge_deleted_items (cnc);
 		if (status == E_GW_CONNECTION_STATUS_OK) {
 			g_message ("Purged deleted items in %s", folder->name);
 		}
-		CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 	}
 
-	CAMEL_SERVICE_LOCK (gw_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
 	groupwise_sync_summary (folder, ex);
-	CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 }
 
 CamelFolder *
@@ -985,7 +985,7 @@ groupwise_refresh_folder(CamelFolder *fo
 		gw_folder->need_refresh = TRUE;
 	}
 
-	CAMEL_SERVICE_LOCK (gw_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
 
 	if (!camel_groupwise_store_connected (gw_store, ex)) 
 		goto end1;
@@ -1092,7 +1092,7 @@ groupwise_refresh_folder(CamelFolder *fo
 	}
 
 
-	CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 	is_locked = FALSE;
 
 	/*
@@ -1124,7 +1124,7 @@ end2:
 	g_free (container_id);
 end1:
 	if (is_locked)
-		CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 	return;
 }
 
@@ -1149,8 +1149,6 @@ gw_update_cache (CamelFolder *folder, GL
 	GList *item_list = list;
 	int total_items = g_list_length (item_list), i=0;
 
-	CAMEL_SERVICE_ASSERT_LOCKED (gw_store, connect_lock);
-
 	changes = camel_folder_change_info_new ();
 	container_id = g_strdup (camel_groupwise_store_container_id_lookup (gw_store, folder->full_name));
 	if (!container_id) {
@@ -1343,7 +1341,7 @@ gw_update_cache (CamelFolder *folder, GL
 			if (mail_msg)
 				camel_medium_set_header (CAMEL_MEDIUM (mail_msg), "X-Evolution-Source", groupwise_base_url_lookup (priv));
 
-			CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
+			CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
 			if ((cache_stream = camel_data_cache_add (gw_folder->cache, "cache", id, NULL))) {
 				if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *) mail_msg, 	cache_stream) == -1 || camel_stream_flush (cache_stream) == -1)
 					camel_data_cache_remove (gw_folder->cache, "cache", id, NULL);
@@ -1351,7 +1349,7 @@ gw_update_cache (CamelFolder *folder, GL
 			}
 
 			camel_object_unref (mail_msg);
-			CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
+			CAMEL_GROUPWISE_FOLDER_REC_UNLOCK (folder, cache_lock);
 		}
 		/******************** Caching stuff ends *************************/
 		i++;
@@ -1842,11 +1840,11 @@ gw_update_all_items (CamelFolder *folder
 		}
 
 		if (!temp) {
-			CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
+			CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
 			camel_folder_summary_remove_uid (folder->summary, info->uid);
 			camel_data_cache_remove (gw_folder->cache, "cache", info->uid, ex);
 			camel_folder_change_info_remove_uid (changes, info->uid);
-			CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
+			CAMEL_GROUPWISE_FOLDER_REC_UNLOCK (folder, cache_lock);
 		} else { 
 			item_list = g_list_delete_link (item_list, temp);
 		}
@@ -1858,9 +1856,9 @@ gw_update_all_items (CamelFolder *folder
 	if (item_list) {
 		CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (folder->parent_store);
 
-		CAMEL_SERVICE_LOCK (gw_store, connect_lock);
+		CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
 		gw_update_cache (folder, item_list, ex, TRUE);	
-		CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 
 		g_list_foreach (item_list, (GFunc)g_free, NULL);	
 		g_list_free (item_list);
@@ -1901,7 +1899,7 @@ groupwise_append_message (CamelFolder *f
 	}
 	cnc = cnc_lookup (priv);
 
-	CAMEL_SERVICE_LOCK (folder->parent_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (folder->parent_store, connect_lock);
 	/*Get the container id*/
 	container_id = camel_groupwise_store_container_id_lookup (gw_store, folder->full_name) ;
 	
@@ -1925,7 +1923,7 @@ groupwise_append_message (CamelFolder *f
 
 		if (appended_uid)
 			*appended_uid = NULL;
-		CAMEL_SERVICE_UNLOCK (folder->parent_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (folder->parent_store, connect_lock);
 		return;
 	}
 
@@ -1938,14 +1936,14 @@ groupwise_append_message (CamelFolder *f
 		if (appended_uid)
 			*appended_uid = NULL;
 
-		CAMEL_SERVICE_UNLOCK (folder->parent_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (folder->parent_store, connect_lock);
 		return;
 	}
 
 	if (appended_uid)
 		*appended_uid = g_strdup (id);	
 	g_free (id);
-	CAMEL_SERVICE_UNLOCK (folder->parent_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (folder->parent_store, connect_lock);
 }
 
 static int
@@ -1995,7 +1993,7 @@ groupwise_transfer_messages_to (CamelFol
 		source_container_id = NULL;
 	dest_container_id = camel_groupwise_store_container_id_lookup (gw_store, destination->full_name) ;
 
-	CAMEL_SERVICE_LOCK (source->parent_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (source->parent_store, connect_lock);
 	/* check for offline operation */
 	if (offline->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
 		CamelGroupwiseJournal *journal = (CamelGroupwiseJournal *) ((CamelGroupwiseFolder *) destination)->journal;
@@ -2022,7 +2020,7 @@ groupwise_transfer_messages_to (CamelFol
 				camel_folder_delete_message(source, camel_message_info_uid (info));
 		}
 
-		CAMEL_SERVICE_UNLOCK (source->parent_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (source->parent_store, connect_lock);
 		return;
 	}
 
@@ -2057,7 +2055,7 @@ groupwise_transfer_messages_to (CamelFol
 
 	gw_store->current_folder = source;
 
-	CAMEL_SERVICE_UNLOCK (source->parent_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (source->parent_store, connect_lock);
 }
 
 static void
@@ -2083,7 +2081,7 @@ groupwise_expunge (CamelFolder *folder, 
 		return;
 
 	if (!strcmp (folder->full_name, "Trash")) {
-		CAMEL_SERVICE_LOCK (groupwise_store, connect_lock);
+		CAMEL_SERVICE_REC_LOCK (groupwise_store, connect_lock);
 		status = e_gw_connection_purge_deleted_items (cnc);
 		if (status == E_GW_CONNECTION_STATUS_OK) {
 			camel_folder_freeze (folder);
@@ -2091,7 +2089,7 @@ groupwise_expunge (CamelFolder *folder, 
 			camel_folder_thaw (folder);
 		} else
 			g_warning ("Could not Empty Trash\n");
-		CAMEL_SERVICE_UNLOCK (groupwise_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
 		return;
 	}
 
@@ -2114,18 +2112,18 @@ groupwise_expunge (CamelFolder *folder, 
 			}
 			if (g_list_length (deleted_items) == GROUPWISE_BULK_DELETE_LIMIT ) {
 				/* Read the FIXME below */
-				CAMEL_SERVICE_LOCK (groupwise_store, connect_lock);
+				CAMEL_SERVICE_REC_LOCK (groupwise_store, connect_lock);
 				status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
-				CAMEL_SERVICE_UNLOCK (groupwise_store, connect_lock);
+				CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
 				if (status == E_GW_CONNECTION_STATUS_OK) {
 					char *uid;
 					while (deleted_items) {
 						uid = (char *)deleted_items->data;
-						CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
+						CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
 						camel_folder_change_info_remove_uid (changes, uid);
 						camel_folder_summary_remove_uid (folder->summary, uid);
 						camel_data_cache_remove(gw_folder->cache, "cache", uid, ex);
-						CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
+						CAMEL_GROUPWISE_FOLDER_REC_UNLOCK (folder, cache_lock);
 						deleted_items = g_list_next (deleted_items);
 						max -= GROUPWISE_BULK_DELETE_LIMIT;
 						i -= GROUPWISE_BULK_DELETE_LIMIT;
@@ -2139,18 +2137,18 @@ groupwise_expunge (CamelFolder *folder, 
 
 	if (deleted_items) {
 		/* FIXME: Put these in a function and reuse it inside the above loop, here and in groupwise_sync*/
-		CAMEL_SERVICE_LOCK (groupwise_store, connect_lock);
+		CAMEL_SERVICE_REC_LOCK (groupwise_store, connect_lock);
 		status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
-		CAMEL_SERVICE_UNLOCK (groupwise_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
 		if (status == E_GW_CONNECTION_STATUS_OK) {
 			char *uid;
 			while (deleted_items) {
 				uid = (char *)deleted_items->data;
-				CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
+				CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
 				camel_folder_change_info_remove_uid (changes, uid);
 				camel_folder_summary_remove_uid (folder->summary, uid);
 				camel_data_cache_remove(gw_folder->cache, "cache", uid, ex);
-				CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
+				CAMEL_GROUPWISE_FOLDER_REC_UNLOCK (folder, cache_lock);
 				deleted_items = g_list_next (deleted_items);
 			}
 		}
@@ -2201,9 +2199,10 @@ camel_groupwise_folder_init (gpointer ob
 	gw_folder->priv = g_malloc0 (sizeof(*gw_folder->priv));
 
 #ifdef ENABLE_THREADS
-	gw_folder->priv->search_lock = e_mutex_new(E_MUTEX_SIMPLE);
-	gw_folder->priv->cache_lock = e_mutex_new(E_MUTEX_REC);
+	g_static_mutex_init(&gw_folder->priv->search_lock);
+	g_static_rec_mutex_init(&gw_folder->priv->cache_lock);
 #endif 
+
 	gw_folder->need_rescan = TRUE;
 }
 
Index: camel/providers/groupwise/camel-groupwise-private.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/groupwise/camel-groupwise-private.h,v
retrieving revision 1.3
diff -u -p -r1.3 camel-groupwise-private.h
--- camel/providers/groupwise/camel-groupwise-private.h	31 Aug 2005 04:26:07 -0000	1.3
+++ camel/providers/groupwise/camel-groupwise-private.h	15 Sep 2006 20:09:14 -0000
@@ -35,16 +35,19 @@ extern "C" {
 #endif
 
 #ifdef ENABLE_THREADS
-#include "libedataserver/e-msgport.h"
-#endif
-
-
-#ifdef ENABLE_THREADS
-#define CAMEL_GROUPWISE_FOLDER_LOCK(f, l) (e_mutex_lock(((CamelGroupwiseFolder *)f)->priv->l))
-#define CAMEL_GROUPWISE_FOLDER_UNLOCK(f, l) (e_mutex_unlock(((CamelGroupwiseFolder *)f)->priv->l))
+#define CAMEL_GROUPWISE_FOLDER_LOCK(f, l) \
+	(g_static_mutex_lock(&((CamelGroupwiseFolder *)f)->priv->l))
+#define CAMEL_GROUPWISE_FOLDER_UNLOCK(f, l) \
+	(g_static_mutex_unlock(&((CamelGroupwiseFolder *)f)->priv->l))
+#define CAMEL_GROUPWISE_FOLDER_REC_LOCK(f, l) \
+	(g_static_rec_mutex_lock(&((CamelGroupwiseFolder *)f)->priv->l))
+#define CAMEL_GROUPWISE_FOLDER_REC_UNLOCK(f, l) \
+	(g_static_rec_mutex_unlock(&((CamelGroupwiseFolder *)f)->priv->l))
 #else
-#define CAMEL_GROUPWISE_FOLDER_LOCK(f, l)
-#define CAMEL_GROUPWISE_FOLDER_UNLOCK(f, l)
+#define GROUPWISE_FOLDER_LOCK(f, l)
+#define GROUPWISE_FOLDER_UNLOCK(f, l)
+#define GROUPWISE_FOLDER_REC_LOCK(f, l)
+#define GROUPWISE_FOLDER_REC_UNLOCK(f, l)
 #endif
 
 
Index: camel/providers/groupwise/camel-groupwise-store.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/groupwise/camel-groupwise-store.c,v
retrieving revision 1.104
diff -u -p -r1.104 camel-groupwise-store.c
--- camel/providers/groupwise/camel-groupwise-store.c	5 Jul 2006 10:15:09 -0000	1.104
+++ camel/providers/groupwise/camel-groupwise-store.c	15 Sep 2006 20:09:15 -0000
@@ -182,7 +182,6 @@ groupwise_auth_loop (CamelService *servi
 	gboolean authenticated = FALSE;
 	char *uri;
 
-	CAMEL_SERVICE_ASSERT_LOCKED (groupwise_store, connect_lock);
 	if (priv->use_ssl && !g_str_equal (priv->use_ssl, "never")) 
 		uri = g_strconcat ("https://", priv->server_name, ":", priv->port, "/soap", NULL);
 	else 
@@ -286,15 +285,15 @@ groupwise_connect (CamelService *service
 		camel_service_construct (service, service->session, service->provider, service->url, ex);
 	}
 
-	CAMEL_SERVICE_LOCK (service, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (service, connect_lock);
 	
 	if (priv->cnc) {
-		CAMEL_SERVICE_UNLOCK (service, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
 		return TRUE;
 	}
 
 	if (!check_for_connection (service, ex) || !groupwise_auth_loop (service, ex)) {
-		CAMEL_SERVICE_UNLOCK (service, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
 		camel_service_disconnect (service, TRUE, NULL);
 		return FALSE;
 	}
@@ -321,7 +320,7 @@ groupwise_connect (CamelService *service
 
 	camel_store_summary_save ((CamelStoreSummary *) store->summary);
 
-	CAMEL_SERVICE_UNLOCK (service, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
 	if (E_IS_GW_CONNECTION (priv->cnc)) {
 		return TRUE;
 	}
@@ -389,12 +388,12 @@ groupwise_disconnect (CamelService *serv
 	CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (service);
 	
 	if (clean) {
-		CAMEL_SERVICE_LOCK (groupwise_store, connect_lock);
+		CAMEL_SERVICE_REC_LOCK (groupwise_store, connect_lock);
 		if (groupwise_store->priv && groupwise_store->priv->cnc) {
 			g_object_unref (groupwise_store->priv->cnc);
 			groupwise_store->priv->cnc = NULL;
 		}
-		CAMEL_SERVICE_UNLOCK (groupwise_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
 	}
 	
 	//groupwise_disconnect_cleanup (service, clean, ex);
@@ -568,10 +567,10 @@ groupwise_get_folder (CamelStore *store,
 
 	camel_exception_clear (ex);
 
-	CAMEL_SERVICE_LOCK (gw_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
 
 	if (!camel_groupwise_store_connected ((CamelGroupwiseStore *)store, ex)) {
-		CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 		return NULL;
 	}
 	
@@ -583,7 +582,7 @@ groupwise_get_folder (CamelStore *store,
 	if (!E_IS_GW_CONNECTION( priv->cnc)) {
 		if (!groupwise_connect (CAMEL_SERVICE(store), ex)) {
 			camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, _("Authentication failed"));
-			CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+			CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 			return NULL;
 		}
 	}
@@ -596,7 +595,7 @@ groupwise_get_folder (CamelStore *store,
 	g_free(storage_path);
 	folder = camel_gw_folder_new (store, folder_name, folder_dir, ex);
 	if (!folder) {
-		CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 		camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
 		g_free (folder_dir);
 		g_free (container_id);
@@ -621,7 +620,7 @@ groupwise_get_folder (CamelStore *store,
 				NULL,
 				&cursor);
 		if (status != E_GW_CONNECTION_STATUS_OK) {
-			CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+			CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 			g_free (container_id);
 			return NULL;
 		}
@@ -637,7 +636,7 @@ groupwise_get_folder (CamelStore *store,
 				all_ok = FALSE;
 				break;
 				/*
-				CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+				CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 				e_gw_connection_destroy_cursor (priv->cnc, container_id, cursor);
 				//camel_folder_summary_clear (folder->summary);
 				camel_folder_summary_save (folder->summary);
@@ -678,7 +677,7 @@ groupwise_get_folder (CamelStore *store,
 	camel_object_ref (folder);
 
 	g_free (container_id);
-	CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 
 	return folder;
 }
@@ -699,17 +698,17 @@ gw_store_reload_folder (CamelGroupwiseSt
 	
 	camel_exception_clear (ex);
 
-	CAMEL_SERVICE_LOCK (gw_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
 
 	if (!camel_groupwise_store_connected (gw_store, ex)) {
-		CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 		return;
 	}
 	
 	if (!E_IS_GW_CONNECTION( priv->cnc)) {
 		if (!groupwise_connect (CAMEL_SERVICE((CamelStore*)gw_store), ex)) {
 			camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, _("Authentication failed"));
-			CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+			CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 			return;
 		}
 	}
@@ -735,7 +734,7 @@ gw_store_reload_folder (CamelGroupwiseSt
 				NULL,
 				&cursor);
 		if (status != E_GW_CONNECTION_STATUS_OK) {
-			CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+			CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 			g_free (container_id);
 			return;
 		}
@@ -747,7 +746,7 @@ gw_store_reload_folder (CamelGroupwiseSt
 							      cursor, FALSE, 
 							      CURSOR_ITEM_LIMIT, position, &list);
 			if (status != E_GW_CONNECTION_STATUS_OK) {
-				CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+				CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 				e_gw_connection_destroy_cursor (priv->cnc, container_id, cursor);
 				camel_folder_summary_save (folder->summary);
 				camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
@@ -786,7 +785,7 @@ gw_store_reload_folder (CamelGroupwiseSt
 	gw_store->current_folder = folder;
 	
 	g_free (container_id);
-	CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
 	return;
 }
 
@@ -1077,7 +1076,7 @@ store_refresh_refresh (CamelSession *ses
 	struct _store_refresh_msg *m = (struct _store_refresh_msg *)msg;
 	CamelGroupwiseStore *groupwise_store = (CamelGroupwiseStore *)m->store;
 	
-	CAMEL_SERVICE_LOCK (m->store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (m->store, connect_lock);
 	if (!camel_groupwise_store_connected ((CamelGroupwiseStore *)m->store, &m->ex))
 		goto done;
 	/*Get the folder list and save it here*/
@@ -1086,7 +1085,7 @@ store_refresh_refresh (CamelSession *ses
 		goto done;
 	camel_store_summary_save ((CamelStoreSummary *)groupwise_store->summary);
 done:
-	CAMEL_SERVICE_UNLOCK (m->store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (m->store, connect_lock);
 }
 
 static void
@@ -1132,17 +1131,17 @@ groupwise_get_folder_info (CamelStore *s
 	 * is used as is here.
 	 */
 	if (camel_store_summary_count ((CamelStoreSummary *)groupwise_store->summary) == 0) {
-		CAMEL_SERVICE_LOCK (store, connect_lock);
+		CAMEL_SERVICE_REC_LOCK (store, connect_lock);
 		if (groupwise_store->list_loaded == 3) {
 			groupwise_folders_sync (groupwise_store, ex);
 			groupwise_store->list_loaded -= 1;
 		}
 		if (camel_exception_is_set (ex)) {
 			camel_store_summary_save ((CamelStoreSummary *) groupwise_store->summary);
-			CAMEL_SERVICE_UNLOCK (store, connect_lock);
+			CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 			return NULL;
 		}
-		CAMEL_SERVICE_UNLOCK (store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 		camel_store_summary_save ((CamelStoreSummary *)groupwise_store->summary);
 		goto end_r;
 	}
@@ -1153,7 +1152,7 @@ groupwise_get_folder_info (CamelStore *s
 		goto end_r;
 	}
 
-	CAMEL_SERVICE_LOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (store, connect_lock);
 	if ((groupwise_store->list_loaded == 1) && check_for_connection((CamelService *)store, ex)) {
 		if (!priv->cnc) {
 			if (groupwise_connect ((CamelService *)store, ex)) {
@@ -1166,14 +1165,14 @@ groupwise_get_folder_info (CamelStore *s
 				CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS (groupwise_store->current_folder))->sync(groupwise_store->current_folder, FALSE, ex);
 			groupwise_folders_sync (groupwise_store, ex);
 			if (camel_exception_is_set (ex)) {
-				CAMEL_SERVICE_UNLOCK (store, connect_lock);
+				CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 				return NULL;
 			}
 			camel_store_summary_touch ((CamelStoreSummary *)groupwise_store->summary);
 			camel_store_summary_save ((CamelStoreSummary *)groupwise_store->summary);
 		}
 	}
-	CAMEL_SERVICE_UNLOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 
 	/*camel_exception_clear (ex);*/
 end_r:
@@ -1196,7 +1195,7 @@ create_junk_folder (CamelStore *store)
 	parent_id = "";
 	/* TODO: check for offlining*/
 		
-	CAMEL_SERVICE_LOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (store, connect_lock);
 	status = e_gw_connection_modify_junk_settings (priv->cnc, JUNK_ENABLE, 0, 0,  JUNK_PERSISTENCE);
 	if (status == E_GW_CONNECTION_STATUS_OK) {
 		root = groupwise_build_folder_info(groupwise_store, parent_name, folder_name);
@@ -1211,7 +1210,7 @@ create_junk_folder (CamelStore *store)
 		g_hash_table_insert (priv->parent_hash, g_strdup(child_container_id), g_strdup(parent_id));
 		camel_object_trigger_event (CAMEL_OBJECT (store), "folder_created", root);
 	}
-	CAMEL_SERVICE_UNLOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 
 	return root;
 }
@@ -1256,7 +1255,7 @@ groupwise_create_folder(CamelStore *stor
 			return NULL;
 		}
 	}
-	CAMEL_SERVICE_LOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (store, connect_lock);
 	status = e_gw_connection_create_folder(priv->cnc,parent_id,folder_name, &child_container_id);
 	if (status == E_GW_CONNECTION_STATUS_OK) {
 		root = groupwise_build_folder_info(groupwise_store, parent_name,folder_name);
@@ -1268,7 +1267,7 @@ groupwise_create_folder(CamelStore *stor
 
 		camel_object_trigger_event (CAMEL_OBJECT (store), "folder_created", root);
 	}
-	CAMEL_SERVICE_UNLOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 	return root;
 }
 
@@ -1282,10 +1281,10 @@ groupwise_delete_folder(CamelStore *stor
 	EGwConnectionStatus status;
 	const char * container; 
 	
-	CAMEL_SERVICE_LOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (store, connect_lock);
 	
 	if (!camel_groupwise_store_connected ((CamelGroupwiseStore *)store, ex)) {
-		CAMEL_SERVICE_UNLOCK (store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 		return;
 	}
 
@@ -1304,7 +1303,7 @@ groupwise_delete_folder(CamelStore *stor
 		
 		g_hash_table_remove (priv->parent_hash, container);
 	}
-	CAMEL_SERVICE_UNLOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 }
 
 static void 
@@ -1325,10 +1324,10 @@ groupwise_rename_folder(CamelStore *stor
 		return;
 	}
 
-	CAMEL_SERVICE_LOCK (groupwise_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (groupwise_store, connect_lock);
 	
 	if (!camel_groupwise_store_connected ((CamelGroupwiseStore *)store, ex)) {
-		CAMEL_SERVICE_UNLOCK (groupwise_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
 		return;
 	}
 	
@@ -1343,7 +1342,7 @@ groupwise_rename_folder(CamelStore *stor
 	{
 		camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot rename Groupwise folder `%s' to `%s'"),
 				      old_name, new_name);
-		CAMEL_SERVICE_UNLOCK (groupwise_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
 		return;
 	}
 
@@ -1366,7 +1365,7 @@ groupwise_rename_folder(CamelStore *stor
 
 	g_free (oldpath);
 	g_free (newpath);
-	CAMEL_SERVICE_UNLOCK (groupwise_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
 }
 
 char * 
Index: camel/providers/imap/camel-imap-command.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/imap/camel-imap-command.c,v
retrieving revision 1.79
diff -u -p -r1.79 camel-imap-command.c
--- camel/providers/imap/camel-imap-command.c	22 May 2006 17:06:45 -0000	1.79
+++ camel/providers/imap/camel-imap-command.c	15 Sep 2006 20:09:15 -0000
@@ -92,7 +92,7 @@ camel_imap_command (CamelImapStore *stor
 	va_list ap;
 	char *cmd;
 	
-	CAMEL_SERVICE_LOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (store, connect_lock);
 	
 	if (fmt) {
 		va_start (ap, fmt);
@@ -108,7 +108,7 @@ camel_imap_command (CamelImapStore *stor
 	
 	if (!imap_command_start (store, folder, cmd, ex)) {
 		g_free (cmd);
-		CAMEL_SERVICE_UNLOCK (store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 		return NULL;
 	}
 	g_free (cmd);
@@ -162,12 +162,12 @@ camel_imap_command_start (CamelImapStore
 	cmd = imap_command_strdup_vprintf (store, fmt, ap);
 	va_end (ap);
 	
-	CAMEL_SERVICE_LOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (store, connect_lock);
 	ok = imap_command_start (store, folder, cmd, ex);
 	g_free (cmd);
 	
 	if (!ok)
-		CAMEL_SERVICE_UNLOCK (store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 	return ok;
 }
 
@@ -266,7 +266,7 @@ camel_imap_command_continuation (CamelIm
 			camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
 					     g_strerror (errno));
 		camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
-		CAMEL_SERVICE_UNLOCK (store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 		return NULL;
 	}
 	
@@ -296,7 +296,7 @@ camel_imap_command_response (CamelImapSt
 	char *respbuf;
 	
 	if (camel_imap_store_readline (store, &respbuf, ex) < 0) {
-		CAMEL_SERVICE_UNLOCK (store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 		return CAMEL_IMAP_RESPONSE_ERROR;
 	}
 	
@@ -345,7 +345,7 @@ camel_imap_command_response (CamelImapSt
 	
 	if (type == CAMEL_IMAP_RESPONSE_ERROR ||
 	    type == CAMEL_IMAP_RESPONSE_TAGGED)
-		CAMEL_SERVICE_UNLOCK (store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 	
 	return type;
 }
@@ -362,7 +362,7 @@ imap_read_response (CamelImapStore *stor
 	 * we're still locked. This lock is owned by response
 	 * and gets unlocked when response is freed.
 	 */
-	CAMEL_SERVICE_LOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (store, connect_lock);
 	
 	response = g_new0 (CamelImapResponse, 1);
 	if (store->current_folder && camel_disco_store_status (CAMEL_DISCO_STORE (store)) != CAMEL_DISCO_STORE_RESYNCING) {
@@ -620,7 +620,7 @@ camel_imap_response_free (CamelImapStore
 	}
 	
 	g_free (response);
-	CAMEL_SERVICE_UNLOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 }
 
 /**
Index: camel/providers/imap/camel-imap-folder.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/imap/camel-imap-folder.c,v
retrieving revision 1.363
diff -u -p -r1.363 camel-imap-folder.c
--- camel/providers/imap/camel-imap-folder.c	2 Sep 2006 10:18:11 -0000	1.363
+++ camel/providers/imap/camel-imap-folder.c	15 Sep 2006 20:09:18 -0000
@@ -191,8 +191,8 @@ camel_imap_folder_init (gpointer object,
 	
 	imap_folder->priv = g_malloc0(sizeof(*imap_folder->priv));
 #ifdef ENABLE_THREADS
-	imap_folder->priv->search_lock = e_mutex_new(E_MUTEX_SIMPLE);
-	imap_folder->priv->cache_lock = e_mutex_new(E_MUTEX_REC);
+	g_static_mutex_init(&imap_folder->priv->search_lock);
+	g_static_rec_mutex_init(&imap_folder->priv->cache_lock);
 #endif
 
 	imap_folder->need_rescan = TRUE;
@@ -296,8 +296,6 @@ camel_imap_folder_selected (CamelFolder 
 	int i, count;
 	char *resp;
 	
-	CAMEL_SERVICE_ASSERT_LOCKED (folder->parent_store, connect_lock);
-	
 	count = camel_folder_summary_count (folder->summary);
 	
 	for (i = 0; i < response->untagged->len; i++) {
@@ -347,9 +345,9 @@ camel_imap_folder_selected (CamelFolder 
 	else if (validity != imap_summary->validity) {
 		imap_summary->validity = validity;
 		camel_folder_summary_clear (folder->summary);
-		CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock);
+		CAMEL_IMAP_FOLDER_REC_LOCK (imap_folder, cache_lock);
 		camel_imap_message_cache_clear (imap_folder->cache);
-		CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock);
+		CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
 		imap_folder->need_rescan = FALSE;
 		camel_imap_folder_changed (folder, exists, NULL, ex);
 		return;
@@ -425,8 +423,8 @@ imap_finalize (CamelObject *object)
 		camel_object_unref (CAMEL_OBJECT (imap_folder->cache));
 
 #ifdef ENABLE_THREADS
-	e_mutex_destroy(imap_folder->priv->search_lock);
-	e_mutex_destroy(imap_folder->priv->cache_lock);
+	g_static_mutex_free(&imap_folder->priv->search_lock);
+	g_static_rec_mutex_free(&imap_folder->priv->cache_lock);
 #endif
 	g_free(imap_folder->priv);
 }
@@ -481,9 +479,9 @@ imap_rename (CamelFolder *folder, const 
 	g_free (folders);
 	summary_path = g_strdup_printf("%s/summary", folder_dir);
 
-	CAMEL_IMAP_FOLDER_LOCK (folder, cache_lock);
+	CAMEL_IMAP_FOLDER_REC_LOCK (folder, cache_lock);
 	camel_imap_message_cache_set_path(imap_folder->cache, folder_dir);
-	CAMEL_IMAP_FOLDER_UNLOCK (folder, cache_lock);
+	CAMEL_IMAP_FOLDER_REC_UNLOCK (folder, cache_lock);
 
 	camel_folder_summary_set_filename(folder->summary, summary_path);
 
@@ -518,7 +516,7 @@ imap_refresh_info (CamelFolder *folder, 
 	 * Also, if this is the INBOX, some servers (cryus) wont tell
 	 * us with a NOOP of new messages, so force a reselect which
 	 * should do it.  */
-	CAMEL_SERVICE_LOCK (imap_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (imap_store, connect_lock);
 
 	if (!camel_imap_store_connected(imap_store, ex))
 		goto done;
@@ -563,7 +561,7 @@ imap_refresh_info (CamelFolder *folder, 
 		camel_store_summary_info_free((CamelStoreSummary *)((CamelImapStore *)folder->parent_store)->summary, si);
 	}
 done:
-	CAMEL_SERVICE_UNLOCK (imap_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
 
 	camel_folder_summary_save(folder->summary);
 	camel_store_summary_save((CamelStoreSummary *)((CamelImapStore *)folder->parent_store)->summary);
@@ -620,7 +618,6 @@ imap_rescan (CamelFolder *folder, int ex
 	gboolean ok;
 	CamelFolderChangeInfo *changes = NULL;
 
-	CAMEL_SERVICE_ASSERT_LOCKED (store, connect_lock);
 	imap_folder->need_rescan = FALSE;
 	
 	summary_len = camel_folder_summary_count (folder->summary);
@@ -834,7 +831,7 @@ imap_sync_online (CamelFolder *folder, C
 	}
 	
 	camel_exception_init (&local_ex);
-	CAMEL_SERVICE_LOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (store, connect_lock);
 	
 	/* Find a message with changed flags, find all of the other
 	 * messages like it, sync them as a group, mark them as
@@ -902,7 +899,7 @@ imap_sync_online (CamelFolder *folder, C
 		g_ptr_array_free (matches, TRUE);
 		
 		/* We unlock here so that other threads can have a chance to grab the connect_lock */
-		CAMEL_SERVICE_UNLOCK (store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 		
 		/* check for an exception */
 		if (camel_exception_is_set (&local_ex)) {
@@ -911,13 +908,13 @@ imap_sync_online (CamelFolder *folder, C
 		}
 		
 		/* Re-lock the connect_lock */
-		CAMEL_SERVICE_LOCK (store, connect_lock);
+		CAMEL_SERVICE_REC_LOCK (store, connect_lock);
 	}
 	
 	/* Save the summary */
 	imap_sync_offline (folder, ex);
 	
-	CAMEL_SERVICE_UNLOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 }
 
 static int
@@ -970,12 +967,12 @@ imap_expunge_uids_online (CamelFolder *f
 	int uid = 0;
 	char *set;
 	
-	CAMEL_SERVICE_LOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (store, connect_lock);
 
 	if ((store->capabilities & IMAP_CAPABILITY_UIDPLUS) == 0) {
 		((CamelFolderClass *)CAMEL_OBJECT_GET_CLASS(folder))->sync(folder, 0, ex);
 		if (camel_exception_is_set(ex)) {
-			CAMEL_SERVICE_UNLOCK (store, connect_lock);
+			CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 			return;
 		}
 	}
@@ -990,7 +987,7 @@ imap_expunge_uids_online (CamelFolder *f
 		if (response)
 			camel_imap_response_free (store, response);
 		if (camel_exception_is_set (ex)) {
-			CAMEL_SERVICE_UNLOCK (store, connect_lock);
+			CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 			g_free (set);
 			return;
 		}
@@ -1005,7 +1002,7 @@ imap_expunge_uids_online (CamelFolder *f
 			camel_imap_response_free (store, response);
 	}
 	
-	CAMEL_SERVICE_UNLOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 }
 
 static void
@@ -1031,22 +1028,22 @@ imap_expunge_uids_resyncing (CamelFolder
 	 * marked un-deleted.
 	 */
 	
-	CAMEL_SERVICE_LOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (store, connect_lock);
 
 	((CamelFolderClass *)CAMEL_OBJECT_GET_CLASS(folder))->sync(folder, 0, ex);
 	if (camel_exception_is_set(ex)) {
-		CAMEL_SERVICE_UNLOCK (store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 		return;
 	}
 
 	response = camel_imap_command (store, folder, ex, "UID SEARCH DELETED");
 	if (!response) {
-		CAMEL_SERVICE_UNLOCK (store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 		return;
 	}
 	result = camel_imap_response_extract (store, response, "SEARCH", ex);
 	if (!result) {
-		CAMEL_SERVICE_UNLOCK (store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 		return;
 	}
 	
@@ -1107,7 +1104,7 @@ imap_expunge_uids_resyncing (CamelFolder
 			if (!response) {
 				g_ptr_array_free (keep_uids, TRUE);
 				g_ptr_array_free (mark_uids, TRUE);
-				CAMEL_SERVICE_UNLOCK (store, connect_lock);
+				CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 				return;
 			}
 			camel_imap_response_free (store, response);
@@ -1131,7 +1128,7 @@ imap_expunge_uids_resyncing (CamelFolder
 			if (!response) {
 				g_ptr_array_free (keep_uids, TRUE);
 				g_ptr_array_free (mark_uids, TRUE);
-				CAMEL_SERVICE_UNLOCK (store, connect_lock);
+				CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 				return;
 			}
 			camel_imap_response_free (store, response);
@@ -1171,7 +1168,7 @@ imap_expunge_uids_resyncing (CamelFolder
 	/* now we can free this, now that we're done with keep_uids */
 	g_free (result);
 	
-	CAMEL_SERVICE_UNLOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 }
 
 static gchar *
@@ -1204,10 +1201,10 @@ imap_append_offline (CamelFolder *folder
 	uid = get_temp_uid ();
 
 	camel_imap_summary_add_offline (folder->summary, uid, message, info);
-	CAMEL_IMAP_FOLDER_LOCK (folder, cache_lock);
+	CAMEL_IMAP_FOLDER_REC_LOCK (folder, cache_lock);
 	camel_imap_message_cache_insert_wrapper (cache, uid, "",
 						 CAMEL_DATA_WRAPPER (message), ex);
-	CAMEL_IMAP_FOLDER_UNLOCK (folder, cache_lock);
+	CAMEL_IMAP_FOLDER_REC_UNLOCK (folder, cache_lock);
 
 	changes = camel_folder_change_info_new ();
 	camel_folder_change_info_add_uid (changes, uid);
@@ -1337,11 +1334,11 @@ imap_append_online (CamelFolder *folder,
 		/* Cache first, since freeing response may trigger a
 		 * summary update that will want this information.
 		 */
-		CAMEL_IMAP_FOLDER_LOCK (folder, cache_lock);
+		CAMEL_IMAP_FOLDER_REC_LOCK (folder, cache_lock);
 		camel_imap_message_cache_insert_wrapper (
 			CAMEL_IMAP_FOLDER (folder)->cache, uid,
 			"", CAMEL_DATA_WRAPPER (message), ex);
-		CAMEL_IMAP_FOLDER_UNLOCK (folder, cache_lock);
+		CAMEL_IMAP_FOLDER_REC_UNLOCK (folder, cache_lock);
 		if (appended_uid)
 			*appended_uid = uid;
 		else
@@ -1352,11 +1349,11 @@ imap_append_online (CamelFolder *folder,
 	camel_imap_response_free (store, response);
 	
 	/* Make sure a "folder_changed" is emitted. */
-	CAMEL_SERVICE_LOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (store, connect_lock);
 	if (store->current_folder != folder ||
 	    camel_folder_summary_count (folder->summary) == count)
 		imap_refresh_info (folder, ex);
-	CAMEL_SERVICE_UNLOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 }
 
 static void
@@ -1376,10 +1373,10 @@ imap_append_resyncing (CamelFolder *fold
 		CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
 		const char *olduid = camel_message_info_uid (info);
 		
-		CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock);
+		CAMEL_IMAP_FOLDER_REC_LOCK (imap_folder, cache_lock);
 		camel_imap_message_cache_copy (imap_folder->cache, olduid,
 					       imap_folder->cache, uid, ex);
-		CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock);
+		CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
 
 		if (appended_uid)
 			*appended_uid = uid;
@@ -1411,10 +1408,10 @@ imap_transfer_offline (CamelFolder *sour
 	 * deadlock in the case where we're simultaneously also trying
 	 * to copy messages in the other direction from another thread.
 	 */
-	CAMEL_SERVICE_LOCK (store, connect_lock);
-	CAMEL_IMAP_FOLDER_LOCK (source, cache_lock);
-	CAMEL_IMAP_FOLDER_LOCK (dest, cache_lock);
-	CAMEL_SERVICE_UNLOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+	CAMEL_IMAP_FOLDER_REC_LOCK (source, cache_lock);
+	CAMEL_IMAP_FOLDER_REC_LOCK (dest, cache_lock);
+	CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 
 	if (transferred_uids) {
 		*transferred_uids = g_ptr_array_new ();
@@ -1452,8 +1449,8 @@ imap_transfer_offline (CamelFolder *sour
 			camel_folder_delete_message (source, uid);
 	}
 
-	CAMEL_IMAP_FOLDER_UNLOCK (dest, cache_lock);
-	CAMEL_IMAP_FOLDER_UNLOCK (source, cache_lock);
+	CAMEL_IMAP_FOLDER_REC_UNLOCK (dest, cache_lock);
+	CAMEL_IMAP_FOLDER_REC_UNLOCK (source, cache_lock);
 
 	camel_object_trigger_event (CAMEL_OBJECT (dest), "folder_changed", changes);
 	camel_folder_change_info_free (changes);
@@ -1496,15 +1493,15 @@ handle_copyuid (CamelImapResponse *respo
 		 * cache locks here, because we've got the store's
 		 * command lock too, so no one else could be here.
 		 */
-		CAMEL_IMAP_FOLDER_LOCK (source, cache_lock);
-		CAMEL_IMAP_FOLDER_LOCK (destination, cache_lock);
+		CAMEL_IMAP_FOLDER_REC_LOCK (source, cache_lock);
+		CAMEL_IMAP_FOLDER_REC_LOCK (destination, cache_lock);
 		for (i = 0; i < src->len; i++) {
 			camel_imap_message_cache_copy (scache, src->pdata[i],
 						       dcache, dest->pdata[i],
 						       NULL);
 		}
-		CAMEL_IMAP_FOLDER_UNLOCK (source, cache_lock);
-		CAMEL_IMAP_FOLDER_UNLOCK (destination, cache_lock);
+		CAMEL_IMAP_FOLDER_REC_UNLOCK (source, cache_lock);
+		CAMEL_IMAP_FOLDER_REC_UNLOCK (destination, cache_lock);
 
 		imap_uid_array_free (src);
 		imap_uid_array_free (dest);
@@ -2095,16 +2092,16 @@ imap_get_message (CamelFolder *folder, c
 				char *body, *found_uid;
 				int i;
 				
-				CAMEL_SERVICE_LOCK(store, connect_lock);
+				CAMEL_SERVICE_REC_LOCK(store, connect_lock);
 				if (!camel_imap_store_connected(store, ex)) {
-					CAMEL_SERVICE_UNLOCK(store, connect_lock);
+					CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
 					camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
 							     _("This message is not currently available"));
 					goto fail;
 				}
 				
 				response = camel_imap_command (store, folder, ex, "UID FETCH %s BODY", uid);
-				CAMEL_SERVICE_UNLOCK(store, connect_lock);
+				CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
 
 				if (response) {
 					for (i = 0, body = NULL; i < response->untagged->len; i++) {
@@ -2346,7 +2343,6 @@ imap_update_summary (CamelFolder *folder
 	char *uid, *resp;
 	GData *data;
 	
-	CAMEL_SERVICE_ASSERT_LOCKED (store, connect_lock);
 	if (store->server_level >= IMAP_LEVEL_IMAP4REV1)
 		header_spec = "HEADER.FIELDS (" CAMEL_MESSAGE_INFO_HEADERS MAILING_LIST_HEADERS ")";
 	else
@@ -2628,8 +2624,6 @@ camel_imap_folder_changed (CamelFolder *
 	CamelMessageInfo *info;
 	int len;
 	
-	CAMEL_SERVICE_ASSERT_LOCKED (folder->parent_store, connect_lock);
-	
 	changes = camel_folder_change_info_new ();
 	if (expunged) {
 		int i, id;
@@ -2644,9 +2638,9 @@ camel_imap_folder_changed (CamelFolder *
 			}
 			
 			camel_folder_change_info_remove_uid (changes, camel_message_info_uid (info));
-			CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock);
+			CAMEL_IMAP_FOLDER_REC_LOCK (imap_folder, cache_lock);
 			camel_imap_message_cache_remove (imap_folder->cache, camel_message_info_uid (info));
-			CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock);
+			CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
 			camel_folder_summary_remove (folder->summary, info);
 			camel_message_info_free(info);
 		}
@@ -2703,27 +2697,27 @@ camel_imap_folder_fetch_data (CamelImapF
 	 * getting the same data from the cache, but that is only
 	 * an inefficiency, and bad luck.
 	 */
-	CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock);
+	CAMEL_IMAP_FOLDER_REC_LOCK (imap_folder, cache_lock);
 	stream = camel_imap_message_cache_get (imap_folder->cache, uid, section_text, ex);
 	if (!stream && (!strcmp (section_text, "HEADER") || !strcmp (section_text, "0"))) {
 		camel_exception_clear (ex);
 		stream = camel_imap_message_cache_get (imap_folder->cache, uid, "", ex);
 	}
-	CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock);
+	CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
 	
 	if (stream || cache_only)
 		return stream;
 
 	camel_exception_clear(ex);
 
-	CAMEL_SERVICE_LOCK (store, connect_lock);
-	CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock);
+	CAMEL_SERVICE_REC_LOCK (store, connect_lock);
+	CAMEL_IMAP_FOLDER_REC_LOCK (imap_folder, cache_lock);
 
 	if (!camel_imap_store_connected(store, ex)) {
 		camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
 				     _("This message is not currently available"));
-		CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock);
-		CAMEL_SERVICE_UNLOCK (store, connect_lock);
+		CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
+		CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 		return NULL;
 	}
 	
@@ -2738,10 +2732,10 @@ camel_imap_folder_fetch_data (CamelImapF
 					       uid, section_text);
 	}
 	/* We won't need the connect_lock again after this. */
-	CAMEL_SERVICE_UNLOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 	
 	if (!response) {
-		CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock);
+		CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
 		return NULL;
 	}
 	
@@ -2756,7 +2750,7 @@ camel_imap_folder_fetch_data (CamelImapF
 		stream = NULL;
 	}
 	camel_imap_response_free (store, response);
-	CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock);
+	CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
 	if (!stream) {
 		camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
 				      _("Could not find message body in FETCH response."));
@@ -2894,11 +2888,11 @@ parse_fetch_response (CamelImapFolder *i
 		if (header && !cache_header) {
 			stream = camel_stream_mem_new_with_buffer (body, body_len);
 		} else {
-			CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock);
+			CAMEL_IMAP_FOLDER_REC_LOCK (imap_folder, cache_lock);
 			stream = camel_imap_message_cache_insert (imap_folder->cache,
 								  uid, part_spec,
 								  body, body_len, NULL);
-			CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock);
+			CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
 			if (stream == NULL)
 				stream = camel_stream_mem_new_with_buffer (body, body_len);
 		}
Index: camel/providers/imap/camel-imap-private.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/imap/camel-imap-private.h,v
retrieving revision 1.14
diff -u -p -r1.14 camel-imap-private.h
--- camel/providers/imap/camel-imap-private.h	2 Sep 2006 10:18:11 -0000	1.14
+++ camel/providers/imap/camel-imap-private.h	15 Sep 2006 20:09:18 -0000
@@ -13,23 +13,27 @@ extern "C" {
 #include <config.h>
 #endif
 
-#ifdef ENABLE_THREADS
-#include "libedataserver/e-msgport.h"
-#endif
-
 struct _CamelImapFolderPrivate {
 #ifdef ENABLE_THREADS
-	EMutex *search_lock;	/* for locking the search object */
-	EMutex *cache_lock;     /* for locking the cache object */
+	GStaticMutex search_lock;	/* for locking the search object */
+	GStaticRecMutex cache_lock;	/* for locking the cache object */
 #endif
 };
 
 #ifdef ENABLE_THREADS
-#define CAMEL_IMAP_FOLDER_LOCK(f, l) (e_mutex_lock(((CamelImapFolder *)f)->priv->l))
-#define CAMEL_IMAP_FOLDER_UNLOCK(f, l) (e_mutex_unlock(((CamelImapFolder *)f)->priv->l))
+#define CAMEL_IMAP_FOLDER_LOCK(f, l) \
+	(g_static_mutex_lock(&((CamelImapFolder *)f)->priv->l))
+#define CAMEL_IMAP_FOLDER_UNLOCK(f, l) \
+	(g_static_mutex_unlock(&((CamelImapFolder *)f)->priv->l))
+#define CAMEL_IMAP_FOLDER_REC_LOCK(f, l) \
+	(g_static_rec_mutex_lock(&((CamelImapFolder *)f)->priv->l))
+#define CAMEL_IMAP_FOLDER_REC_UNLOCK(f, l) \
+	(g_static_rec_mutex_unlock(&((CamelImapFolder *)f)->priv->l))
 #else
-#define CAMEL_IMAP_FOLDER_LOCK(f, l)
-#define CAMEL_IMAP_FOLDER_UNLOCK(f, l)
+#define CAMEL_IMAP_FOLDER_LOCK(obj)
+#define CAMEL_IMAP_FOLDER_UNLOCK(obj)
+#define CAMEL_IMAP_FOLDER_REC_LOCK(obj)
+#define CAMEL_IMAP_FOLDER_REC_UNLOCK(obj)
 #endif
 
 struct _CamelImapWrapperPrivate {
Index: camel/providers/imap/camel-imap-store.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/imap/camel-imap-store.c,v
retrieving revision 1.345
diff -u -p -r1.345 camel-imap-store.c
--- camel/providers/imap/camel-imap-store.c	13 Jun 2006 21:31:01 -0000	1.345
+++ camel/providers/imap/camel-imap-store.c	15 Sep 2006 20:09:20 -0000
@@ -506,8 +506,6 @@ imap_get_capability (CamelService *servi
 	CamelImapResponse *response;
 	char *result;
 	
-	CAMEL_SERVICE_ASSERT_LOCKED (store, connect_lock);
-	
 	/* Find out the IMAP capabilities */
 	/* We assume we have utf8 capable search until a failed search tells us otherwise */
 	store->capabilities = IMAP_CAPABILITY_utf8_search;
@@ -1001,11 +999,11 @@ query_auth_types (CamelService *service,
 	if (!camel_disco_store_check_online (CAMEL_DISCO_STORE (store), ex))
 		return NULL;
 	
-	CAMEL_SERVICE_LOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (store, connect_lock);
 	connected = store->istream != NULL && store->connected;
 	if (!connected)
 		connected = connect_to_server_wrapper (service, ex);
-	CAMEL_SERVICE_UNLOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 	if (!connected)
 		return NULL;
 	
@@ -1233,8 +1231,6 @@ try_auth (CamelImapStore *store, const c
 	char *resp;
 	char *sasl_resp;
 	
-	CAMEL_SERVICE_ASSERT_LOCKED (store, connect_lock);
-	
 	response = camel_imap_command (store, NULL, ex, "AUTHENTICATE %s", mech);
 	if (!response)
 		return FALSE;
@@ -1297,7 +1293,6 @@ imap_auth_loop (CamelService *service, C
 	gboolean authenticated = FALSE;
 	const char *auth_domain;
 	
-	CAMEL_SERVICE_ASSERT_LOCKED (store, connect_lock);
 	auth_domain = camel_url_get_param (service->url, "auth-domain");
 	
 	if (store->preauthed) {
@@ -1414,10 +1409,10 @@ imap_connect_online (CamelService *servi
 	size_t len;
 	CamelImapStoreNamespace *ns;
 
-	CAMEL_SERVICE_LOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (store, connect_lock);
 	if (!connect_to_server_wrapper (service, ex) ||
 	    !imap_auth_loop (service, ex)) {
-		CAMEL_SERVICE_UNLOCK (store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 		camel_service_disconnect (service, TRUE, NULL);
 		return FALSE;
 	}
@@ -1538,7 +1533,7 @@ imap_connect_online (CamelService *servi
 	/* save any changes we had */
 	camel_store_summary_save((CamelStoreSummary *)store->summary);
 
-	CAMEL_SERVICE_UNLOCK (store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 	
 	if (camel_exception_is_set (ex))
 		camel_service_disconnect (service, TRUE, NULL);
@@ -1640,7 +1635,7 @@ imap_noop (CamelStore *store, CamelExcep
 	CamelImapResponse *response;
 	CamelFolder *current_folder;
 	
-	CAMEL_SERVICE_LOCK (imap_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (imap_store, connect_lock);
 
 	if (!camel_imap_store_connected(imap_store, ex))
 		goto done;
@@ -1655,7 +1650,7 @@ imap_noop (CamelStore *store, CamelExcep
 			camel_imap_response_free (imap_store, response);
 	}
 done:
-	CAMEL_SERVICE_UNLOCK (imap_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
 }
 
 static CamelFolder *
@@ -1837,10 +1832,10 @@ get_folder_online (CamelStore *store, co
 		return new_folder;
 	camel_exception_clear(ex);
 
-	CAMEL_SERVICE_LOCK(imap_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK(imap_store, connect_lock);
 
 	if (!camel_imap_store_connected(imap_store, ex)) {
-		CAMEL_SERVICE_UNLOCK(imap_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
 		return NULL;
 	}
 	
@@ -1857,14 +1852,14 @@ get_folder_online (CamelStore *store, co
 		const char *c;
 		
 		if (camel_exception_get_id(ex) == CAMEL_EXCEPTION_USER_CANCEL) {
-			CAMEL_SERVICE_UNLOCK (imap_store, connect_lock);
+			CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
 			return NULL;
 		}
 		
 		camel_exception_clear (ex);
 		
 		if (!(flags & CAMEL_STORE_FOLDER_CREATE)) {
-			CAMEL_SERVICE_UNLOCK (imap_store, connect_lock);
+			CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
 			camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
 					      _("No such folder %s"), folder_name);
 			return NULL;
@@ -1876,7 +1871,7 @@ get_folder_online (CamelStore *store, co
 			c++;
 		
 		if (*c != '\0') {
-			CAMEL_SERVICE_UNLOCK (imap_store, connect_lock);
+			CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
 			camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_PATH,
 					      _("The folder name \"%s\" is invalid because it contains the character \"%c\""),
 					      folder_name, *c);
@@ -1897,7 +1892,7 @@ get_folder_online (CamelStore *store, co
 			int i;
 			
 			if (!(response = camel_imap_command (imap_store, NULL, ex, "LIST \"\" %G", parent_real))) {
-				CAMEL_SERVICE_UNLOCK (imap_store, connect_lock);
+				CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
 				g_free (parent_name);
 				g_free (parent_real);
 				return NULL;
@@ -1942,7 +1937,7 @@ get_folder_online (CamelStore *store, co
 				if (messages > 0) {
 					camel_exception_set (ex, CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
 							     _("The parent folder is not allowed to contain subfolders"));
-					CAMEL_SERVICE_UNLOCK (imap_store, connect_lock);
+					CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
 					g_free (parent_name);
 					g_free (parent_real);
 					return NULL;
@@ -1952,7 +1947,7 @@ get_folder_online (CamelStore *store, co
 				camel_exception_init (&lex);
 				delete_folder (store, parent_name, &lex);
 				if (camel_exception_is_set (&lex)) {
-					CAMEL_SERVICE_UNLOCK (imap_store, connect_lock);
+					CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
 					camel_exception_xfer (ex, &lex);
 					g_free (parent_name);
 					g_free (parent_real);
@@ -1966,7 +1961,7 @@ get_folder_online (CamelStore *store, co
 				g_free (name);
 				
 				if (!response) {
-					CAMEL_SERVICE_UNLOCK (imap_store, connect_lock);
+					CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
 					g_free (parent_name);
 					g_free (parent_real);
 					return NULL;
@@ -1990,7 +1985,7 @@ get_folder_online (CamelStore *store, co
 		}
 		g_free(folder_real);
 		if (!response) {
-			CAMEL_SERVICE_UNLOCK (imap_store, connect_lock);
+			CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
 			return NULL;
 		}
 	} else if (flags & CAMEL_STORE_FOLDER_EXCL) {
@@ -2000,7 +1995,7 @@ get_folder_online (CamelStore *store, co
 		
 		camel_imap_response_free_without_processing (imap_store, response);
 		
-		CAMEL_SERVICE_UNLOCK (imap_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
 		
 		return NULL;
 	}
@@ -2028,7 +2023,7 @@ get_folder_online (CamelStore *store, co
 	}
 	camel_imap_response_free_without_processing (imap_store, response);
 	
-	CAMEL_SERVICE_UNLOCK (imap_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
 	
 	return new_folder;
 }
@@ -2069,7 +2064,7 @@ delete_folder (CamelStore *store, const 
 	CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
 	CamelImapResponse *response;
 
-	CAMEL_SERVICE_LOCK (imap_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (imap_store, connect_lock);
 
 	if (!camel_imap_store_connected(imap_store, ex))
 		goto fail;
@@ -2091,7 +2086,7 @@ delete_folder (CamelStore *store, const 
 		imap_forget_folder (imap_store, folder_name, ex);
 	}
 fail:
-	CAMEL_SERVICE_UNLOCK(imap_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK(imap_store, connect_lock);
 }
 
 static void
@@ -2169,7 +2164,7 @@ rename_folder (CamelStore *store, const 
 	CamelImapResponse *response;
 	char *oldpath, *newpath, *storage_path;
 
-	CAMEL_SERVICE_LOCK (imap_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK (imap_store, connect_lock);
 
 	if (!camel_imap_store_connected(imap_store, ex))
 		goto fail;
@@ -2221,7 +2216,7 @@ rename_folder (CamelStore *store, const 
 	g_free (newpath);
 fail:
 	imap_store->renaming = FALSE;
-	CAMEL_SERVICE_UNLOCK(imap_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK(imap_store, connect_lock);
 }
 
 static CamelFolderInfo *
@@ -2610,7 +2605,7 @@ refresh_refresh(CamelSession *session, C
 	struct _refresh_msg *m = (struct _refresh_msg *)msg;
 	CamelImapStore *store = (CamelImapStore *)m->store;
 
-	CAMEL_SERVICE_LOCK(m->store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK(m->store, connect_lock);
 
 	if (!camel_imap_store_connected((CamelImapStore *)m->store, &m->ex))
 		goto done;
@@ -2632,7 +2627,7 @@ refresh_refresh(CamelSession *session, C
 	}
 	camel_store_summary_save((CamelStoreSummary *)((CamelImapStore *)m->store)->summary);
 done:
-	CAMEL_SERVICE_UNLOCK(m->store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK(m->store, connect_lock);
 }
 
 static void
@@ -2673,7 +2668,7 @@ get_folder_info_online (CamelStore *stor
 		now = time(0);
 		ref = now > imap_store->refresh_stamp+60*60*1;
 		if (ref) {
-			CAMEL_SERVICE_LOCK(store, connect_lock);
+			CAMEL_SERVICE_REC_LOCK(store, connect_lock);
 			ref = now > imap_store->refresh_stamp+60*60*1;
 			if (ref) {
 				struct _refresh_msg *m;
@@ -2686,13 +2681,13 @@ get_folder_info_online (CamelStore *stor
 				camel_exception_init(&m->ex);
 				camel_session_thread_queue(((CamelService *)store)->session, &m->msg, 0);
 			}
-			CAMEL_SERVICE_UNLOCK(store, connect_lock);
+			CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
 		}
 	} else {
 		char *pattern;
 		int i;
 
-		CAMEL_SERVICE_LOCK(store, connect_lock);
+		CAMEL_SERVICE_REC_LOCK(store, connect_lock);
 
 		if (!camel_imap_store_connected((CamelImapStore *)store, ex))
 			goto fail;
@@ -2738,14 +2733,14 @@ get_folder_info_online (CamelStore *stor
 			get_folders_sync(imap_store, pattern, ex);
 		}
 		camel_store_summary_save((CamelStoreSummary *)imap_store->summary);
-		CAMEL_SERVICE_UNLOCK(store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
 	}
 
 	tree = get_folder_info_offline(store, top, flags, ex);
 	return tree;
 
 fail:
-	CAMEL_SERVICE_UNLOCK(store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
 	return NULL;
 }
 
@@ -2868,7 +2863,7 @@ subscribe_folder (CamelStore *store, con
 	CamelFolderInfo *fi;
 	CamelStoreInfo *si;
 
-	CAMEL_SERVICE_LOCK(store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK(store, connect_lock);
 
 	if (!camel_imap_store_connected (imap_store, ex))
 		goto done;
@@ -2902,7 +2897,7 @@ subscribe_folder (CamelStore *store, con
 	camel_object_trigger_event (CAMEL_OBJECT (store), "folder_subscribed", fi);
 	camel_folder_info_free (fi);
 done:
-	CAMEL_SERVICE_UNLOCK(store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
 }
 
 static void
@@ -2912,7 +2907,7 @@ unsubscribe_folder (CamelStore *store, c
 	CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
 	CamelImapResponse *response;
 
-	CAMEL_SERVICE_LOCK(store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK(store, connect_lock);
 	
 	if (!camel_imap_store_connected (imap_store, ex))
 		goto done;
@@ -2925,7 +2920,7 @@ unsubscribe_folder (CamelStore *store, c
 
 	imap_folder_effectively_unsubscribed (imap_store, folder_name, ex);
 done:
-	CAMEL_SERVICE_UNLOCK(store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
 }
 
 #if 0
Index: camel/providers/nntp/camel-nntp-folder.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/nntp/camel-nntp-folder.c,v
retrieving revision 1.56
diff -u -p -r1.56 camel-nntp-folder.c
--- camel/providers/nntp/camel-nntp-folder.c	15 Jun 2006 16:41:57 -0000	1.56
+++ camel/providers/nntp/camel-nntp-folder.c	15 Sep 2006 20:09:21 -0000
@@ -83,7 +83,7 @@ nntp_folder_refresh_info_online (CamelFo
 	nntp_store = (CamelNNTPStore *) folder->parent_store;
 	nntp_folder = (CamelNNTPFolder *) folder;
 	
-	CAMEL_SERVICE_LOCK(nntp_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
 
 	camel_nntp_command(nntp_store, ex, nntp_folder, &line, NULL);
 
@@ -92,7 +92,7 @@ nntp_folder_refresh_info_online (CamelFo
 		nntp_folder->changes = camel_folder_change_info_new();
 	}
 	
-	CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
 	
 	if (changes) {
 		camel_object_trigger_event ((CamelObject *) folder, "folder_changed", changes);
@@ -103,17 +103,17 @@ nntp_folder_refresh_info_online (CamelFo
 static void
 nntp_folder_sync_online (CamelFolder *folder, CamelException *ex)
 {
-	CAMEL_SERVICE_LOCK(folder->parent_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK(folder->parent_store, connect_lock);
 	camel_folder_summary_save (folder->summary);
-	CAMEL_SERVICE_UNLOCK(folder->parent_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK(folder->parent_store, connect_lock);
 }
 
 static void
 nntp_folder_sync_offline (CamelFolder *folder, CamelException *ex)
 {
-	CAMEL_SERVICE_LOCK(folder->parent_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK(folder->parent_store, connect_lock);
 	camel_folder_summary_save (folder->summary);
-	CAMEL_SERVICE_UNLOCK(folder->parent_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK(folder->parent_store, connect_lock);
 }
 
 static gboolean
@@ -177,13 +177,13 @@ nntp_folder_cache_message (CamelDiscoFol
 	}
 	*msgid++ = 0;
 	
-	CAMEL_SERVICE_LOCK(nntp_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
 	
 	stream = nntp_folder_download_message ((CamelNNTPFolder *) disco_folder, article, msgid, ex);
 	if (stream)
 		camel_object_unref (stream);
 
-	CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
 }
 
 static CamelMimeMessage *
@@ -209,7 +209,7 @@ nntp_folder_get_message (CamelFolder *fo
 	}
 	*msgid++ = 0;
 
-	CAMEL_SERVICE_LOCK(nntp_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
 	
 	/* Lookup in cache, NEWS is global messageid's so use a global cache path */
 	stream = camel_data_cache_get (nntp_store->cache, "cache", msgid, NULL);
@@ -244,7 +244,7 @@ fail:
 		changes = NULL;
 	}
 	
-	CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
 	
 	if (changes) {
 		camel_object_trigger_event ((CamelObject *) folder, "folder_changed", changes);
@@ -317,7 +317,7 @@ nntp_folder_append_message_online (Camel
 	struct _camel_header_raw *header, *savedhdrs, *n, *tail;
 	char *group, *line;
 	
-	CAMEL_SERVICE_LOCK(nntp_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
 	
 	/* send 'POST' command */
 	ret = camel_nntp_command (nntp_store, ex, NULL, &line, "post");
@@ -328,7 +328,7 @@ nntp_folder_append_message_online (Camel
 		else if (ret != -1)
 			camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
 					      _("Posting failed: %s"), line);
-		CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
+		CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
 		return;
 	}
 	
@@ -378,7 +378,7 @@ nntp_folder_append_message_online (Camel
 	g_free(group);
 	header->next = savedhdrs;
 
-	CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
 	
 	return;
 }
Index: camel/providers/nntp/camel-nntp-store.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/nntp/camel-nntp-store.c,v
retrieving revision 1.85
diff -u -p -r1.85 camel-nntp-store.c
--- camel/providers/nntp/camel-nntp-store.c	15 Jun 2006 16:41:56 -0000	1.85
+++ camel/providers/nntp/camel-nntp-store.c	15 Sep 2006 20:09:22 -0000
@@ -170,7 +170,7 @@ connect_to_server (CamelService *service
 	unsigned int len;
 	char *path;
 	
-	CAMEL_SERVICE_LOCK(store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK(store, connect_lock);
 
 	if (ssl_mode != MODE_CLEAR) {
 #ifdef HAVE_SSL
@@ -260,7 +260,7 @@ connect_to_server (CamelService *service
 	store->current_folder = NULL;
 	
  fail:
-	CAMEL_SERVICE_UNLOCK(store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
 	return retval;
 }
 
@@ -360,7 +360,7 @@ nntp_disconnect_online (CamelService *se
 	CamelNNTPStore *store = CAMEL_NNTP_STORE (service);
 	char *line;
 	
-	CAMEL_SERVICE_LOCK(store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK(store, connect_lock);
 	
 	if (clean) {
 		camel_nntp_raw_command (store, ex, &line, "quit");
@@ -368,7 +368,7 @@ nntp_disconnect_online (CamelService *se
 	}
 	
 	if (!service_class->disconnect (service, clean, ex)) {
-		CAMEL_SERVICE_UNLOCK(store, connect_lock);	
+		CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
 		return FALSE;
 	}
 	
@@ -377,7 +377,7 @@ nntp_disconnect_online (CamelService *se
 	g_free(store->current_folder);
 	store->current_folder = NULL;
 
-	CAMEL_SERVICE_UNLOCK(store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
 	
 	return TRUE;
 }
@@ -422,11 +422,11 @@ nntp_get_folder(CamelStore *store, const
 	CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (store);
 	CamelFolder *folder;
 	
-	CAMEL_SERVICE_LOCK(nntp_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
 	
 	folder = camel_nntp_folder_new(store, folder_name, ex);
 	
-	CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
 	
 	return folder;
 }
@@ -609,13 +609,13 @@ nntp_store_get_subscribed_folder_info (C
 				if (folder) {
 					CamelFolderChangeInfo *changes = NULL;
 
-					CAMEL_SERVICE_LOCK(store, connect_lock);
+					CAMEL_SERVICE_REC_LOCK(store, connect_lock);
 					camel_nntp_command(store, ex, folder, &line, NULL);
 					if (camel_folder_change_info_changed(folder->changes)) {
 						changes = folder->changes;
 						folder->changes = camel_folder_change_info_new();
 					}
-					CAMEL_SERVICE_UNLOCK(store, connect_lock);
+					CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
 					if (changes) {
 						camel_object_trigger_event((CamelObject *) folder, "folder_changed", changes);
 						camel_folder_change_info_free(changes);
@@ -751,7 +751,7 @@ nntp_store_get_folder_info_all(CamelNNTP
 	int ret = -1;
 	CamelFolderInfo *fi = NULL;
 
-	CAMEL_SERVICE_LOCK(nntp_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
 	
 	if (top == NULL)
 		top = "";
@@ -821,7 +821,7 @@ nntp_store_get_folder_info_all(CamelNNTP
 	
 	fi = nntp_store_get_cached_folder_info (nntp_store, top, flags, ex);
  error:
-	CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
 
 	return fi;
 }
@@ -883,7 +883,7 @@ nntp_store_subscribe_folder (CamelStore 
 	CamelStoreInfo *si;
 	CamelFolderInfo *fi;
 	
-	CAMEL_SERVICE_LOCK(nntp_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
 	
 	si = camel_store_summary_path(CAMEL_STORE_SUMMARY(nntp_store->summary), folder_name);
 	if (!si) {
@@ -897,14 +897,14 @@ nntp_store_subscribe_folder (CamelStore 
 			fi->flags |= CAMEL_FOLDER_NOINFERIORS | CAMEL_FOLDER_NOCHILDREN;
 			camel_store_summary_touch ((CamelStoreSummary *) nntp_store->summary);
 			camel_store_summary_save ((CamelStoreSummary *) nntp_store->summary);
-			CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
+			CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
 			camel_object_trigger_event ((CamelObject *) nntp_store, "folder_subscribed", fi);
 			camel_folder_info_free (fi);
 			return;
 		}
 	}
 	
-	CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
 }
 
 static void
@@ -914,7 +914,7 @@ nntp_store_unsubscribe_folder (CamelStor
 	CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE(store);
 	CamelFolderInfo *fi;
 	CamelStoreInfo *fitem;
-	CAMEL_SERVICE_LOCK(nntp_store, connect_lock);
+	CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
 	
 	fitem = camel_store_summary_path(CAMEL_STORE_SUMMARY(nntp_store->summary), folder_name);
 	
@@ -928,14 +928,14 @@ nntp_store_unsubscribe_folder (CamelStor
 			fi = nntp_folder_info_from_store_info (nntp_store, nntp_store->do_short_folder_notation, fitem);
 			camel_store_summary_touch ((CamelStoreSummary *) nntp_store->summary);
 			camel_store_summary_save ((CamelStoreSummary *) nntp_store->summary);
-			CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
+			CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
 			camel_object_trigger_event ((CamelObject *) nntp_store, "folder_unsubscribed", fi);
 			camel_folder_info_free (fi);
 			return;
 		}
 	}
 	
-	CAMEL_SERVICE_UNLOCK(nntp_store, connect_lock);
+	CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
 }
 
 /* stubs for various folder operations we're not implementing */
@@ -1200,7 +1200,6 @@ camel_nntp_raw_commandv (CamelNNTPStore 
 	int d;
 	unsigned int u, u2;
 	
-	e_mutex_assert_locked(((CamelService *)store)->priv->connect_lock);
 	g_assert(store->stream->mode != CAMEL_NNTP_STREAM_DATA);
 
 	camel_nntp_stream_set_mode(store->stream, CAMEL_NNTP_STREAM_LINE);
@@ -1322,8 +1321,6 @@ camel_nntp_command (CamelNNTPStore *stor
 	int ret, retry;
 	unsigned int u;
 	
-	e_mutex_assert_locked(((CamelService *)store)->priv->connect_lock);
-
 	if (((CamelDiscoStore *)store)->status == CAMEL_DISCO_STORE_OFFLINE) {
 		camel_exception_setv(ex, CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED,
 				     _("Not connected."));
Index: libedataserver/e-msgport.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserver/e-msgport.c,v
retrieving revision 1.10
diff -u -p -r1.10 e-msgport.c
--- libedataserver/e-msgport.c	26 Jul 2006 18:12:08 -0000	1.10
+++ libedataserver/e-msgport.c	15 Sep 2006 20:09:26 -0000
@@ -1150,157 +1174,6 @@ void e_thread_put(EThread *e, EMsg *msg)
 	if (dmsg) {
 		thread_lost_msg(e, dmsg);
 		thread_destroy_msg(e, dmsg);
-	}
-}
-
-/* yet-another-mutex interface */
-struct _EMutex {
-	int type;
-	pthread_t owner;
-	int have_owner;
-	short waiters;
-	short depth;
-	pthread_mutex_t mutex;
-	pthread_cond_t cond;
-};
-
-/* sigh, this is just painful to have to need, but recursive
-   read/write, etc mutexes just aren't very common in thread
-   implementations */
-/* TODO: Just make it use recursive mutexes if they are available */
-EMutex *e_mutex_new(e_mutex_t type)
-{
-	struct _EMutex *m;
-
-	m = g_malloc(sizeof(*m));
-	m->type = type;
-	m->waiters = 0;
-	m->depth = 0;
-	m->have_owner = FALSE;
-
-	switch (type) {
-	case E_MUTEX_SIMPLE:
-		pthread_mutex_init(&m->mutex, 0);
-		break;
-	case E_MUTEX_REC:
-		pthread_mutex_init(&m->mutex, 0);
-		pthread_cond_init(&m->cond, 0);
-		break;
-		/* read / write ?  flags for same? */
-	}
-
-	return m;
-}
-
-int e_mutex_destroy(EMutex *m)
-{
-	int ret = 0;
-
-	switch (m->type) {
-	case E_MUTEX_SIMPLE:
-		ret = pthread_mutex_destroy(&m->mutex);
-		if (ret == -1)
-			g_warning("EMutex destroy failed: %s", strerror(errno));
-		g_free(m);
-		break;
-	case E_MUTEX_REC:
-		ret = pthread_mutex_destroy(&m->mutex);
-		if (ret == -1)
-			g_warning("EMutex destroy failed: %s", strerror(errno));
-		ret = pthread_cond_destroy(&m->cond);
-		if (ret == -1)
-			g_warning("EMutex destroy failed: %s", strerror(errno));
-		g_free(m);
-
-	}
-	return ret;
-}
-
-int e_mutex_lock(EMutex *m)
-{
-	pthread_t id;
-	int err;
-
-	switch (m->type) {
-	case E_MUTEX_SIMPLE:
-		return pthread_mutex_lock(&m->mutex);
-	case E_MUTEX_REC:
-		id = pthread_self();
-		if ((err = pthread_mutex_lock(&m->mutex)) != 0)
-			return err;
-		while (1) {
-			if (!m->have_owner) {
-				m->owner = id;
-				m->have_owner = TRUE;
-				m->depth = 1;
-				break;
-			} else if (pthread_equal (id, m->owner)) {
-				m->depth++;
-				break;
-			} else {
-				m->waiters++;
-				if ((err = pthread_cond_wait(&m->cond, &m->mutex)) != 0)
-					return err;
-				m->waiters--;
-			}
-		}
-		return pthread_mutex_unlock(&m->mutex);
-	}
-
-	return EINVAL;
-}
-
-int e_mutex_unlock(EMutex *m)
-{
-	int err;
-
-	switch (m->type) {
-	case E_MUTEX_SIMPLE:
-		return pthread_mutex_unlock(&m->mutex);
-	case E_MUTEX_REC:
-		if ((err = pthread_mutex_lock(&m->mutex)) != 0)
-			return err;
-		g_assert(m->have_owner && pthread_equal(m->owner, pthread_self()));
-
-		m->depth--;
-		if (m->depth == 0) {
-			m->have_owner = FALSE;
-			if (m->waiters > 0)
-				pthread_cond_signal(&m->cond);
-		}
-		return pthread_mutex_unlock(&m->mutex);
-	}
-
-	errno = EINVAL;
-	return -1;
-}
-
-void e_mutex_assert_locked(EMutex *m)
-{
-	g_return_if_fail (m->type == E_MUTEX_REC);
-	pthread_mutex_lock(&m->mutex);
-	g_assert(m->have_owner && pthread_equal(m->owner, pthread_self()));
-	pthread_mutex_unlock(&m->mutex);
-}
-
-int e_mutex_cond_wait(void *vcond, EMutex *m)
-{
-	int ret;
-	pthread_cond_t *cond = vcond;
-
-	switch(m->type) {
-	case E_MUTEX_SIMPLE:
-		return pthread_cond_wait(cond, &m->mutex);
-	case E_MUTEX_REC:
-		if ((ret = pthread_mutex_lock(&m->mutex)) != 0)
-			return ret;
-		g_assert(m->have_owner && pthread_equal(m->owner, pthread_self()));
-		ret = pthread_cond_wait(cond, &m->mutex);
-		g_assert(m->have_owner && pthread_equal(m->owner, pthread_self()));
-		pthread_mutex_unlock(&m->mutex);
-		return ret;
-	default:
-		g_return_val_if_reached(-1);
 	}
 }
 
Index: libedataserver/e-msgport.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserver/e-msgport.h,v
retrieving revision 1.3
diff -u -p -r1.3 e-msgport.h
--- libedataserver/e-msgport.h	3 Dec 2004 03:33:06 -0000	1.3
+++ libedataserver/e-msgport.h	15 Sep 2006 20:09:26 -0000
@@ -91,21 +91,5 @@ void e_thread_set_reply_port(EThread *e,
 void e_thread_set_msg_received(EThread *e, EThreadFunc received, void *data);
 void e_thread_put(EThread *e, EMsg *msg);
 int e_thread_busy(EThread *e);
-
-/* sigh, another mutex interface, this one allows different mutex types, portably */
-typedef struct _EMutex EMutex;
-
-typedef enum _e_mutex_t {
-	E_MUTEX_SIMPLE,		/* == pthread_mutex */
-	E_MUTEX_REC,		/* recursive mutex */
-} e_mutex_t;
-
-EMutex *e_mutex_new(e_mutex_t type);
-int e_mutex_destroy(EMutex *m);
-int e_mutex_lock(EMutex *m);
-int e_mutex_unlock(EMutex *m);
-void e_mutex_assert_locked(EMutex *m);
-/* this uses pthread cond's */
-int e_mutex_cond_wait(void *cond, EMutex *m);
 
 #endif
