Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=4ab... Commit: 4ab2a3a55eb164a65f361b7d9bbbf186e88cf247 Parent: c751d1894640b096808d2f13e331bee4c536f96a Author: Lon Hohberger lhh@redhat.com AuthorDate: Wed Sep 28 10:56:54 2011 -0400 Committer: Lon Hohberger lhh@redhat.com CommitterDate: Tue Oct 18 23:24:47 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@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;
cluster-commits@lists.stg.fedorahosted.org