From ed5d621b6db1ab269db125ddab338b48b824a737 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Tue, 14 Aug 2001 19:42:40 +0000 Subject: After talking to NotZed, it turns out I was wrong after all. (store_sync): 2001-08-13 Jeffrey Stedfast * camel-store.c (camel_store_get_folder): After talking to NotZed, it turns out I was wrong after all. (store_sync): Create a copy of the folder-cache that owns a ref on each of the folders so that if one of the folders get's finalized inside store_sync(), we don't run into any locking issues. This is mostly meant to solve a problem in IMAP (#6089). svn path=/trunk/; revision=12032 --- camel/camel-store.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'camel/camel-store.c') diff --git a/camel/camel-store.c b/camel/camel-store.c index 7abea71392..0a0132e543 100644 --- a/camel/camel-store.c +++ b/camel/camel-store.c @@ -227,7 +227,6 @@ camel_store_get_folder (CamelStore *store, const char *folder_name, guint32 flag CAMEL_STORE_LOCK(store, cache_lock); g_hash_table_insert (store->folders, g_strdup (folder_name), folder); - camel_object_ref (CAMEL_OBJECT (folder)); camel_object_hook_event (CAMEL_OBJECT (folder), "finalize", folder_finalize, store); CAMEL_STORE_UNLOCK(store, cache_lock); @@ -439,6 +438,16 @@ sync_folder (gpointer key, gpointer folder, gpointer ex) { if (!camel_exception_is_set (ex)) camel_folder_sync (folder, FALSE, ex); + + camel_object_unref (CAMEL_OBJECT (folder)); + g_free (key); +} + +static void +copy_folder_cache (gpointer key, gpointer folder, gpointer hash) +{ + g_hash_table_insert ((GHashTable *) hash, g_strdup (key), folder); + camel_object_ref (CAMEL_OBJECT (folder)); } static void @@ -446,12 +455,19 @@ store_sync (CamelStore *store, CamelException *ex) { if (store->folders) { CamelException internal_ex; - + GHashTable *hash; + + hash = g_hash_table_new (CS_CLASS (store)->hash_folder_name, + CS_CLASS (store)->compare_folder_name); + camel_exception_init (&internal_ex); CAMEL_STORE_LOCK(store, cache_lock); - g_hash_table_foreach (store->folders, sync_folder, &internal_ex); + g_hash_table_foreach (store->folders, copy_folder_cache, hash); CAMEL_STORE_UNLOCK(store, cache_lock); camel_exception_xfer (ex, &internal_ex); + + g_hash_table_foreach (hash, sync_folder, &internal_ex); + g_hash_table_destroy (hash); } } -- cgit v1.2.3