Patch: fix deathlock in imap store get_folder_info_online
- From: José Dapena Paz <jdapena igalia com>
- To: tinymail-devel-list <tinymail-devel-list gnome org>
- Subject: Patch: fix deathlock in imap store get_folder_info_online
- Date: Thu, 17 Sep 2009 11:45:01 +0200
Hi,
This patch fixes a deathlock caused by holding summary lock and then
connection lock, when the rule is the opposite.
This can cause deathlocks, i.e., when more than one thread is accesing
the store. The case I got the hang was when I had one thread with
standard access to the account (the one with the store queue), and other
thread moving messages from a different queue.
Changelog entry would be:
* libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c
(get_folder_info_online): now we lock summary inside the connect lock and
not the opposite, to avoid deathlocks (fixes NB#138625).
--
José Dapena Paz <jdapena igalia com>
Igalia
diff --git a/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c b/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c
index aaa5764..14e9be8 100644
--- a/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c
+++ b/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c
@@ -4226,13 +4226,13 @@ get_folder_info_online (CamelStore *store, const char *top, guint32 flags, Camel
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelFolderInfo *tree = NULL;
- g_static_rec_mutex_lock (imap_store->sum_lock);
-
if (top == NULL)
top = "";
camel_imap_store_stop_idle_connect_lock (imap_store);
+ g_static_rec_mutex_lock (imap_store->sum_lock);
+
if (imap_store->going_online || !imap_store->got_online)
goto fail;
@@ -4340,19 +4340,19 @@ get_folder_info_online (CamelStore *store, const char *top, guint32 flags, Camel
camel_store_summary_save((CamelStoreSummary *)imap_store->summary, ex);
}
+ g_static_rec_mutex_unlock (imap_store->sum_lock);
camel_imap_store_connect_unlock_start_idle (imap_store);
tree = get_folder_info_offline(store, top, flags, ex);
- g_static_rec_mutex_unlock (imap_store->sum_lock);
return tree;
fail:
+ g_static_rec_mutex_unlock (imap_store->sum_lock);
camel_imap_store_connect_unlock_start_idle (imap_store);
tree = get_folder_info_offline (store, top, flags, ex);
- g_static_rec_mutex_unlock (imap_store->sum_lock);
return tree;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]