aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-03-29 14:29:43 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-03-29 14:29:43 +0800
commit07de64a309717703ac6bbb6845f5b2d31372d6f7 (patch)
treeb7ede2c0126c876f1810ee472836af7ebd6ebf73
parentfa9c9db0a6b3281b62b2fd38c536872df4206c60 (diff)
downloadgsoc2013-evolution-07de64a309717703ac6bbb6845f5b2d31372d6f7.tar.gz
gsoc2013-evolution-07de64a309717703ac6bbb6845f5b2d31372d6f7.tar.zst
gsoc2013-evolution-07de64a309717703ac6bbb6845f5b2d31372d6f7.zip
use object_bag_peek instead of _get, since we dont want to clash/wait for
2004-03-29 Not Zed <NotZed@Ximian.com> * providers/imap/camel-imap-store.c (get_folder_counts): use object_bag_peek instead of _get, since we dont want to clash/wait for reservations. More #56045 related fixes. (get_folder_counts): revert the lookup/hashtable stuff for the folder, and use object_bag_peek. * camel-object.c (camel_object_bag_peek): new method to get an object bag entry without worrying about if its reserved or not. svn path=/trunk/; revision=25220
-rw-r--r--camel/ChangeLog9
-rw-r--r--camel/camel-object.c32
-rw-r--r--camel/camel-object.h1
-rw-r--r--camel/providers/imap/camel-imap-store.c32
4 files changed, 51 insertions, 23 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 9f7ea67b15..d8eeab1a19 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,14 @@
2004-03-29 Not Zed <NotZed@Ximian.com>
+ * providers/imap/camel-imap-store.c (get_folder_counts): use
+ object_bag_peek instead of _get, since we dont want to clash/wait
+ for reservations. More #56045 related fixes.
+ (get_folder_counts): revert the lookup/hashtable stuff for the
+ folder, and use object_bag_peek.
+
+ * camel-object.c (camel_object_bag_peek): new method to get an
+ object bag entry without worrying about if its reserved or not.
+
* camel-gpg-context.c (gpg_verify): get the content-type off of
the multipart-signed, not its container. This seems wrong
... but might fix #56084.
diff --git a/camel/camel-object.c b/camel/camel-object.c
index 4875774652..f4469f8d9d 100644
--- a/camel/camel-object.c
+++ b/camel/camel-object.c
@@ -1812,6 +1812,38 @@ camel_object_bag_get(CamelObjectBag *bag, const void *key)
}
/**
+ * camel_object_bag_peek:
+ * @bag:
+ * @key:
+ *
+ * Lookup the object @key in @bag, ignoring any reservations. If it
+ * isn't committed, then it isn't considered. This should only be
+ * used where reliable transactional-based state is not required.
+ *
+ * Unlike other 'peek' operations, the object is still reffed if
+ * found.
+ *
+ * Return value: A referenced object, or NULL if @key is not
+ * present in the bag.
+ **/
+void *
+camel_object_bag_peek(CamelObjectBag *bag, const void *key)
+{
+ CamelObject *o;
+
+ E_LOCK(type_lock);
+
+ o = g_hash_table_lookup(bag->object_table, key);
+ if (o) {
+ /* we use the same lock as the refcount */
+ o->ref_count++;
+ }
+ E_UNLOCK(type_lock);
+
+ return o;
+}
+
+/**
* camel_object_bag_reserve:
* @bag:
* @key:
diff --git a/camel/camel-object.h b/camel/camel-object.h
index cb5a5470aa..9b7b62f624 100644
--- a/camel/camel-object.h
+++ b/camel/camel-object.h
@@ -254,6 +254,7 @@ typedef void *(*CamelCopyFunc)(const void *vo);
CamelObjectBag *camel_object_bag_new(GHashFunc hash, GEqualFunc equal, CamelCopyFunc keycopy, GFreeFunc keyfree);
void *camel_object_bag_get(CamelObjectBag *bag, const void *key);
+void *camel_object_bag_peek(CamelObjectBag *bag, const void *key);
void *camel_object_bag_reserve(CamelObjectBag *bag, const void *key);
void camel_object_bag_add(CamelObjectBag *bag, const void *key, void *o);
void camel_object_bag_abort(CamelObjectBag *bag, const void *key);
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index bf8a3152c5..4120c3303c 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -2358,7 +2358,7 @@ fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
fi->unread = -1;
fi->total = -1;
- folder = camel_object_bag_get(store->folders, fi->full_name);
+ folder = camel_object_bag_peek(store->folders, fi->full_name);
if (folder) {
if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0)
/* we use connect lock for everything, so this should be safe */
@@ -2394,19 +2394,7 @@ static void
get_folder_counts(CamelImapStore *imap_store, CamelFolderInfo *fi, CamelException *ex)
{
GSList *q;
- GPtrArray *folders;
- GHashTable *folders_table;
CamelFolder *folder;
- int i;
-
- /* We list rather than use get here, and manage our own lookups outside of the bag,
- since get will wait if someone has reserved the name - can cause deadlock */
- folders = camel_object_bag_list(CAMEL_STORE(imap_store)->folders);
- folders_table = g_hash_table_new(g_str_hash, g_str_equal);
- for (i=0; i<folders->len;i++) {
- folder = folders->pdata[i];
- g_hash_table_insert(folders_table, folder->full_name, folder);
- }
/* non-recursive breath first search */
@@ -2437,11 +2425,14 @@ get_folder_counts(CamelImapStore *imap_store, CamelFolderInfo *fi, CamelExceptio
fi->unread = get_folder_status (imap_store, fi->full_name, "UNSEEN");
fi->total = get_folder_status(imap_store, fi->full_name, "MESSAGES");
/* if we have this folder open, and the unread count has changed, update */
- folder = g_hash_table_lookup(folders_table, fi->full_name);
- if (folder && fi->unread != camel_folder_get_unread_message_count(folder)) {
- CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(folder))->refresh_info(folder, ex);
- fi->unread = camel_folder_get_unread_message_count(folder);
- fi->total = camel_folder_get_message_count(folder);
+ folder = camel_object_bag_peek(CAMEL_STORE(imap_store)->folders, fi->full_name);
+ if (folder) {
+ if (fi->unread != camel_folder_get_unread_message_count(folder)) {
+ CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(folder))->refresh_info(folder, ex);
+ fi->unread = camel_folder_get_unread_message_count(folder);
+ fi->total = camel_folder_get_message_count(folder);
+ }
+ camel_object_unref(folder);
}
}
} else {
@@ -2454,11 +2445,6 @@ get_folder_counts(CamelImapStore *imap_store, CamelFolderInfo *fi, CamelExceptio
fi = fi->next;
}
}
-
- g_hash_table_destroy(folders_table);
- for (i=0; i<folders->len;i++)
- camel_object_unref(folders->pdata[i]);
- g_ptr_array_free(folders, TRUE);
}
/* imap needs to treat inbox case insensitive */