From: Dan Winship Date: Tue, 26 Jun 2001 19:20:01 +0000 (+0000) Subject: lock the cache around accesses X-Git-Tag: upstream/3.7.4~10859 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=499d62b129f3ce4c88e9d68014be8c3b83981de5;p=platform%2Fupstream%2Fevolution-data-server.git lock the cache around accesses * providers/imap/camel-imap-folder.c (camel_imap_folder_selected, imap_append_offline, imap_append_online, camel_imap_folder_changed): lock the cache around accesses * providers/imap/camel-imap-store.c (get_folder_online): ref the newly-created folder (as current_folder) before calling camel_imap_folder_selected, in case that needs to do something that causes another folder to become current... --- diff --git a/camel/ChangeLog b/camel/ChangeLog index 3bfbaf2..89c56e8 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,6 +1,16 @@ 2001-06-26 Dan Winship - * camel-url.c (camel_url_encode): constify args + * providers/imap/camel-imap-folder.c (camel_imap_folder_selected, + imap_append_offline, imap_append_online, + camel_imap_folder_changed): lock the cache around accesses + + * providers/imap/camel-imap-store.c (get_folder_online): ref the + newly-created folder (as current_folder) before calling + camel_imap_folder_selected, in case that needs to do something + that causes another folder to become current... + + * camel-service.c (camel_service_get_url): D'oh. + s/FALSE/CAMEL_URL_HIDE_PASSWORD/ 2001-06-25 Jeffrey Stedfast diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index d9f6e66..bf839a4 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -41,6 +41,7 @@ #include "camel-imap-folder.h" #include "camel-imap-command.h" #include "camel-imap-message-cache.h" +#include "camel-imap-private.h" #include "camel-imap-search.h" #include "camel-imap-store.h" #include "camel-imap-summary.h" @@ -49,7 +50,6 @@ #include "camel-data-wrapper.h" #include "camel-disco-diary.h" #include "camel-exception.h" -#include "camel-imap-private.h" #include "camel-mime-filter-crlf.h" #include "camel-mime-filter-from.h" #include "camel-mime-message.h" @@ -277,7 +277,9 @@ camel_imap_folder_selected (CamelFolder *folder, CamelImapResponse *response, 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_message_cache_clear (imap_folder->cache); + CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock); imap_folder->need_rescan = FALSE; camel_imap_folder_changed (folder, exists, NULL, ex); return; @@ -862,8 +864,10 @@ imap_append_offline (CamelFolder *folder, CamelMimeMessage *message, CAMEL_IMAP_STORE_UNLOCK (imap_store, command_lock); camel_imap_summary_add_offline (folder->summary, uid, message, info); + CAMEL_IMAP_FOLDER_LOCK (folder, cache_lock); camel_imap_message_cache_insert_wrapper (cache, uid, "", CAMEL_DATA_WRAPPER (message)); + CAMEL_IMAP_FOLDER_UNLOCK (folder, cache_lock); changes = camel_folder_change_info_new (); camel_folder_change_info_add_uid (changes, uid); @@ -966,9 +970,11 @@ imap_append_online (CamelFolder *folder, CamelMimeMessage *message, /* Cache first, since freeing response may trigger a * summary update that will want this information. */ + CAMEL_IMAP_FOLDER_LOCK (folder, cache_lock); camel_imap_message_cache_insert_wrapper ( CAMEL_IMAP_FOLDER (folder)->cache, uid, "", CAMEL_DATA_WRAPPER (message)); + CAMEL_IMAP_FOLDER_UNLOCK (folder, cache_lock); g_free (uid); } @@ -1625,8 +1631,9 @@ camel_imap_folder_changed (CamelFolder *folder, int exists, id = g_array_index (expunged, int, i); info = camel_folder_summary_index (folder->summary, id - 1); camel_folder_change_info_remove_uid (changes, camel_message_info_uid (info)); - /* It's safe to not lock around this. */ + CAMEL_IMAP_FOLDER_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_folder_summary_remove (folder->summary, info); camel_folder_summary_info_free(folder->summary, info); } diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index eecc7b0..a86a3b5 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -872,12 +872,14 @@ get_folder_online (CamelStore *store, const char *folder_name, g_free (folder_dir); if (new_folder) { imap_store->current_folder = new_folder; + camel_object_ref (CAMEL_OBJECT (new_folder)); camel_imap_folder_selected (new_folder, response, ex); if (camel_exception_is_set (ex)) { + camel_object_unref (CAMEL_OBJECT (imap_store->current_folder)); + imap_store->current_folder = NULL; camel_object_unref (CAMEL_OBJECT (new_folder)); - new_folder = imap_store->current_folder = NULL; - } else - camel_object_ref (CAMEL_OBJECT (imap_store->current_folder)); + new_folder = NULL; + } } camel_imap_response_free_without_processing (imap_store, response);