Skip to contentSkip to conversation

rgmanager: Fix race in shutdown vs. notification [RHEL6]

PATCH New Lon Hohberger 2 participants 2 messages Aug 2, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rgmanager: Fix race in shutdown vs. notification [RHEL6]

The check of db prior to taking the mutex was done as a tiny performance gain in the event that there was no dbus connection, but causes dbus_connection_get_is_connected() to crash the program if db is NULL.

Resolves: rhbz#697446

---
 rgmanager/src/daemons/update-dbus.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
rgmanager/src/daemons/update-dbus.c +3 -3
index f465d1d..bff1644 100644
@@ -149,12 +149,12 @@ _rgm_dbus_notify(const char *svcname,
 	DBusMessage *msg = NULL;
 	int ret = -1;
 
+	pthread_mutex_lock(&mu);
+
 	if (!db) {
-		goto out_free;
+		goto out_unlock;
 	}
 
-	pthread_mutex_lock(&mu);
-
 	/* Check to ensure the connection is still valid. If it
 	 * isn't, clean up and shut down the dbus connection.
 	 *
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH 1/1 rgmanager: Fix race in shutdown vs. notification [RHEL6]

ACK

Fabio

Quoted 31 lines · Lon Hohberger

The check of db prior to taking the mutex was done as a tiny performance gain in the event that there was no dbus connection, but causes dbus_connection_get_is_connected() to crash the program if db is NULL.

Resolves: rhbz#697446

---
 rgmanager/src/daemons/update-dbus.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
rgmanager/src/daemons/update-dbus.c +3 -3
index f465d1d..bff1644 100644
@@ -149,12 +149,12 @@ _rgm_dbus_notify(const char *svcname,
 	DBusMessage *msg = NULL;
 	int ret = -1;
 
+	pthread_mutex_lock(&mu);
+
 	if (!db) {
-		goto out_free;
+		goto out_unlock;
 	}
 
-	pthread_mutex_lock(&mu);
-
 	/* Check to ensure the connection is still valid. If it
 	 * isn't, clean up and shut down the dbus connection.
 	 *