diff options
author | Dan Winship <danw@src.gnome.org> | 2001-07-02 03:59:02 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2001-07-02 03:59:02 +0800 |
commit | 82351a952651260ee912c491c7b05b6160c4646b (patch) | |
tree | 31615e86e98f14ea6fad358228e004464103bbea /mail | |
parent | 6eb77485e73d131f7c68a17193bcb73793dd06d1 (diff) | |
download | gsoc2013-evolution-82351a952651260ee912c491c7b05b6160c4646b.tar.gz gsoc2013-evolution-82351a952651260ee912c491c7b05b6160c4646b.tar.zst gsoc2013-evolution-82351a952651260ee912c491c7b05b6160c4646b.zip |
Ref the folder before proxying the event, in case there's only one
* mail-tools.c (update_unread_count): Ref the folder before
proxying the event, in case there's only one reference to it and
it gets unreffed before the other end of the event handler runs.
(update_unread_count_main): And unref it when we're done.
(mail_tool_uri_to_folder): Only hold the lock around the hash
table operations, not the entire function. Holding the lock the
whole time can cause deadlock when resolving vfolders, and the
CamelSession and CamelStore locks ensure that multiple threads
calling this function will end up with the same CamelFolder object
at the end anyway, so we just need to lock and re-check the cache
at the end before adding the folder to the cache.
svn path=/trunk/; revision=10661
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 14 | ||||
-rw-r--r-- | mail/mail-tools.c | 12 |
2 files changed, 23 insertions, 3 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index def5296a7c..d181b145d6 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,17 @@ +2001-07-01 Dan Winship <danw@ximian.com> + + * mail-tools.c (update_unread_count): Ref the folder before + proxying the event, in case there's only one reference to it and + it gets unreffed before the other end of the event handler runs. + (update_unread_count_main): And unref it when we're done. + (mail_tool_uri_to_folder): Only hold the lock around the hash + table operations, not the entire function. Holding the lock the + whole time can cause deadlock when resolving vfolders, and the + CamelSession and CamelStore locks ensure that multiple threads + calling this function will end up with the same CamelFolder object + at the end anyway, so we just need to lock and re-check the cache + at the end before adding the folder to the cache. + 2001-06-30 Ettore Perazzoli <ettore@ximian.com> * folder-browser-ui.c: Get MailNext/MailPrevious to use diff --git a/mail/mail-tools.c b/mail/mail-tools.c index 5c458e0b2a..578ba96026 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -270,6 +270,7 @@ update_unread_count_main (CamelObject *object, gpointer event_data, fci->unread != 0); g_free (name); gtk_object_unref (GTK_OBJECT (storage)); + camel_object_unref (object); } static void @@ -284,6 +285,7 @@ update_unread_count (CamelObject *object, gpointer event_data, if (unread == fci->unread) return; fci->unread = unread; + camel_object_ref (object); mail_proxy_event (update_unread_count_main, object, event_data, user_data); } @@ -344,13 +346,15 @@ mail_tool_uri_to_folder (const char *uri, CamelException *ex) struct folder_cache_info *fci; fci = g_hash_table_lookup (folders, uri); + g_static_mutex_unlock (&folders_lock); if (fci) { camel_object_ref (CAMEL_OBJECT (fci->folder)); - g_static_mutex_unlock (&folders_lock); return fci->folder; } - } else + } else { folders = g_hash_table_new (g_str_hash, g_str_equal); + g_static_mutex_unlock (&folders_lock); + } if (!strncmp (uri, "vtrash:", 7)) offset = 7; @@ -396,7 +400,9 @@ mail_tool_uri_to_folder (const char *uri, CamelException *ex) } camel_url_free (url); - cache_folder (folder, uri); + g_static_mutex_lock (&folders_lock); + if (!g_hash_table_lookup (folders, uri)) + cache_folder (folder, uri); g_static_mutex_unlock (&folders_lock); return folder; |