summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2008-02-26 14:41:57 +0000
committerMilan Crha <mcrha@src.gnome.org>2008-02-26 14:41:57 +0000
commitc2a0ada3f8b3b3bd216c4122fd5db350b479e4db (patch)
treecad283ca05c3b3992ba7facbf61794912c9454a2
parentb5a6eb8ded1be2d9b7d6be63da8e5c5d9d45ba6c (diff)
downloadevolution-data-server-c2a0ada3f8b3b3bd216c4122fd5db350b479e4db.tar.gz
** Fix for bug #475616
2008-02-26 Milan Crha <mcrha@redhat.com> ** Fix for bug #475616 * libedataserver/e-component-listener.c: (connection_listen_cb), (e_component_listener_finalize), (e_component_listener_new): Guard global static variable with mutex lock. svn path=/trunk/; revision=8536
-rw-r--r--ChangeLog8
-rw-r--r--libedataserver/e-component-listener.c14
2 files changed, 22 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 801b60ec7..4793ee936 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-02-26 Milan Crha <mcrha@redhat.com>
+
+ ** Fix for bug #475616
+
+ * libedataserver/e-component-listener.c: (connection_listen_cb),
+ (e_component_listener_finalize), (e_component_listener_new):
+ Guard global static variable with mutex lock.
+
2008-02-26 Kjartan Maraas <kmaraas@gnome.org>
* src/Makefile.am: Add E_DATA_SERVER_CFLAGS/LIBS to make it build.
diff --git a/libedataserver/e-component-listener.c b/libedataserver/e-component-listener.c
index 1ef9cf232..9cd720e0a 100644
--- a/libedataserver/e-component-listener.c
+++ b/libedataserver/e-component-listener.c
@@ -24,6 +24,7 @@ struct _EComponentListenerPrivate {
static void e_component_listener_finalize (GObject *object);
static GList *watched_connections = NULL;
+static GStaticMutex watched_lock = G_STATIC_MUTEX_INIT;
enum {
COMPONENT_DIED,
@@ -38,6 +39,8 @@ connection_listen_cb (gpointer object, gpointer user_data)
GList *l, *next = NULL;
EComponentListener *cl;
+ g_static_mutex_lock (&watched_lock);
+
for (l = watched_connections; l != NULL; l = next) {
next = l->next;
cl = l->data;
@@ -49,12 +52,17 @@ connection_listen_cb (gpointer object, gpointer user_data)
g_object_ref (cl);
g_signal_emit (cl, comp_listener_signals[COMPONENT_DIED], 0);
cl->priv->component = CORBA_OBJECT_NIL;
+ /* because the finalize method uses the lock too */
+ g_static_mutex_unlock (&watched_lock);
g_object_unref (cl);
+ g_static_mutex_lock (&watched_lock);
break;
default :
break;
}
}
+
+ g_static_mutex_unlock (&watched_lock);
}
G_DEFINE_TYPE (EComponentListener, e_component_listener, G_TYPE_OBJECT);
@@ -92,7 +100,9 @@ e_component_listener_finalize (GObject *object)
g_return_if_fail (E_IS_COMPONENT_LISTENER (cl));
+ g_static_mutex_lock (&watched_lock);
watched_connections = g_list_remove (watched_connections, cl);
+ g_static_mutex_unlock (&watched_lock);
if (cl->priv->component != CORBA_OBJECT_NIL)
cl->priv->component = CORBA_OBJECT_NIL;
@@ -121,6 +131,8 @@ e_component_listener_new (Bonobo_Unknown comp)
g_return_val_if_fail (comp != NULL, NULL);
+ g_static_mutex_lock (&watched_lock);
+
cl = g_object_new (E_COMPONENT_LISTENER_TYPE, NULL);
cl->priv->component = comp;
@@ -128,6 +140,8 @@ e_component_listener_new (Bonobo_Unknown comp)
ORBit_small_listen_for_broken (comp, G_CALLBACK (connection_listen_cb), cl);
watched_connections = g_list_prepend (watched_connections, cl);
+ g_static_mutex_unlock (&watched_lock);
+
return cl;
}