[evolution-kolab/ek-wip-porting: 12/15] CamelIMAPXExtdServer: serialized handler registration, init fixup
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-porting: 12/15] CamelIMAPXExtdServer: serialized handler registration, init fixup
- Date: Sat, 8 Sep 2012 16:46:23 +0000 (UTC)
commit 0055609aab570e0a681c6741536937256c944f46
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Sat Sep 8 18:39:06 2012 +0200
CamelIMAPXExtdServer: serialized handler registration, init fixup
* made registration of untagged annotation handler registration
thread-safe
* removed G_ONCE from handler registration in init(), so
multiple instances of CamelIMAPXExtdServer can each
register their handlers
* re-registering the same handler for the same server
instance does currently occur and needs fixing
src/libekolab/camel-imapx-extd-server.c | 23 ++++++++++++-----------
1 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/src/libekolab/camel-imapx-extd-server.c b/src/libekolab/camel-imapx-extd-server.c
index 90e6fca..85abdde 100644
--- a/src/libekolab/camel-imapx-extd-server.c
+++ b/src/libekolab/camel-imapx-extd-server.c
@@ -63,6 +63,7 @@ imapx_extd_server_register_desc_list (CamelIMAPXServer *is,
static gpointer
imapx_extd_server_register_untagged_fn (gpointer data)
{
+ static GMutex reg_lock;
CamelIMAPXServer *is = CAMEL_IMAPX_SERVER (data);
const CamelIMAPXUntaggedRespHandlerDesc *prev = NULL;
KolabGConstList *desc_lst = NULL;
@@ -75,6 +76,8 @@ imapx_extd_server_register_untagged_fn (gpointer data)
* are registered here.
*/
+ g_mutex_lock (®_lock);
+
/* METADATA handlers */
desc_lst = camel_imapx_extd_server_metadata_get_handler_descriptors ();
prev = imapx_extd_server_register_desc_list (is, desc_lst);
@@ -88,6 +91,7 @@ imapx_extd_server_register_untagged_fn (gpointer data)
kolab_util_glib_gconstlist_free (desc_lst);
#endif
exit:
+ g_mutex_unlock (®_lock);
return (gpointer) prev;
}
@@ -98,22 +102,19 @@ camel_imapx_extd_server_init (CamelIMAPXServer *is,
GCancellable *cancellable,
GError **err)
{
- static GOnce my_once = G_ONCE_INIT;
-
+ gpointer prev = NULL;
+
g_assert (CAMEL_IS_IMAPX_SERVER (is));
(void)cancellable; /* cancellable may be NULL */
g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
- g_once (&my_once,
- imapx_extd_server_register_untagged_fn,
- is);
+ prev = imapx_extd_server_register_untagged_fn (is);
- if (my_once.retval != NULL) {
- g_set_error (err,
- CAMEL_IMAPX_ERROR,
- 1, /* define and set a sensible code here */
- _("A CamelIMAPXServer extended untagged response handler has been registered twice"));
- return FALSE;
+ if (prev != NULL) {
+ g_warning ("%s()[%u] %s",
+ __func__,
+ __LINE__,
+ _("A CamelIMAPXServer extended untagged response handler has been registered twice"));
}
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]