Gitweb:
http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: a8cca57d6dd0026ac49c87b0dd9e9906cc7872cb
Parent: 0fac6d9e86424411289bf7926bc6f8c6805082e9
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Wed Sep 28 10:56:54 2011 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Wed Oct 19 09:05:42 2011 -0400
rgmanager: Clean up DBus concurrency
This centralizes creation/deletion of the DBus
dispatch thread.
Resolves: rhbz#741607
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
Reviewed-By: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
rgmanager/src/daemons/update-dbus.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/rgmanager/src/daemons/update-dbus.c b/rgmanager/src/daemons/update-dbus.c
index b45113c..29ecaca 100644
--- a/rgmanager/src/daemons/update-dbus.c
+++ b/rgmanager/src/daemons/update-dbus.c
@@ -18,6 +18,8 @@
#define DBUS_RGM_IFACE "com.redhat.cluster.rgmanager"
#define DBUS_RGM_PATH "/com/redhat/cluster/rgmanager"
+static void * _dbus_auto_flush(void *arg);
+
static DBusConnection *db = NULL;
static pthread_mutex_t mu = PTHREAD_MUTEX_INITIALIZER;
static pthread_t th = 0;
@@ -58,6 +60,9 @@ rgm_dbus_init(void)
dbus_connection_set_exit_on_disconnect(dbc, FALSE);
db = dbc;
+
+ pthread_create(&th, NULL, _dbus_auto_flush, NULL);
+
pthread_mutex_unlock(&mu);
logt_print(LOG_DEBUG, "DBus Notifications Initialized\n");
return 0;
@@ -169,8 +174,7 @@ _rgm_dbus_notify(const char *svcname,
}
if (!th) {
- /* start auto-flush thread if needed */
- pthread_create(&th, NULL, _dbus_auto_flush, NULL);
+ goto out_unlock;
}
if (!(msg = dbus_message_new_signal(DBUS_RGM_PATH,
@@ -226,6 +230,12 @@ rgm_dbus_update(char *key, uint64_t view, void *data, uint32_t size)
pthread_mutex_unlock(&mu);
goto out_free;
}
+ if (!th) {
+ /* Dispatch thread died. */
+ _rgm_dbus_release();
+ pthread_mutex_unlock(&mu);
+ goto out_free;
+ }
pthread_mutex_unlock(&mu);
st = (rg_state_t *)data;