[evolution-kolab/ek-wip-porting] CamelIMAPXExtdServer: register untagged handlers once per server instance
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-porting] CamelIMAPXExtdServer: register untagged handlers once per server instance
- Date: Mon, 10 Sep 2012 08:50:38 +0000 (UTC)
commit 6689289f1139f19c87da5787da9c947805191901
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Mon Sep 10 10:47:47 2012 +0200
CamelIMAPXExtdServer: register untagged handlers once per server instance
* make sure we do register the untagged handler functions
only once per CamelIMAPXServer instance
* using a G_ONCE here would not work, since there would
be handler registration only once per process (not
once per server instance), which leads to arbitrary
folders not being down-synced (since for one or the
other server instance, there's no untagged handler
function (metadata, ACL) registered)
src/libekolab/camel-imapx-extd-server.c | 27 +++++++++++++++++++++------
1 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/src/libekolab/camel-imapx-extd-server.c b/src/libekolab/camel-imapx-extd-server.c
index 85abdde..25de9fb 100644
--- a/src/libekolab/camel-imapx-extd-server.c
+++ b/src/libekolab/camel-imapx-extd-server.c
@@ -103,20 +103,35 @@ camel_imapx_extd_server_init (CamelIMAPXServer *is,
GError **err)
{
gpointer prev = NULL;
+ static GMutex init_lock;
+ static GHashTable *inited_tbl = NULL;
g_assert (CAMEL_IS_IMAPX_SERVER (is));
(void)cancellable; /* cancellable may be NULL */
g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
- prev = imapx_extd_server_register_untagged_fn (is);
+ g_mutex_lock (&init_lock);
- if (prev != NULL) {
- g_warning ("%s()[%u] %s",
- __func__,
- __LINE__,
- _("A CamelIMAPXServer extended untagged response handler has been registered twice"));
+ if (inited_tbl == NULL) {
+ inited_tbl = g_hash_table_new_full (g_direct_hash,
+ g_direct_equal,
+ NULL,
+ NULL);
}
+ if (g_hash_table_lookup (inited_tbl, (gpointer) is) == NULL) {
+ prev = imapx_extd_server_register_untagged_fn (is);
+ g_hash_table_insert (inited_tbl, (gpointer) is, (gpointer) is);
+ if (prev != NULL) {
+ g_warning ("%s()[%u] %s",
+ __func__,
+ __LINE__,
+ _("A CamelIMAPXServer extended untagged response handler has been registered twice"));
+ }
+ }
+
+ g_mutex_unlock (&init_lock);
+
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]