summaryrefslogtreecommitdiff
path: root/dbus/dbus-bus.c
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-02-22 18:49:29 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2011-07-28 18:22:17 +0100
commit150f1c1862a56f05303d4cabfccbd98bd866146d (patch)
treeac379f1926bc60350195ded37ac5f68aa1d7b9ee /dbus/dbus-bus.c
parent72ee30d43b1316269545b00ca8ebd3ef129c0d40 (diff)
downloaddbus-150f1c1862a56f05303d4cabfccbd98bd866146d.tar.gz
dbus_bus_register: don't unref the messages with the lock held
Finalizing a message can call out to user code via dbus_message_set_data (or to internal code not expecting locks to be held, via DBusCounter). Reviewed-by: Colin Walters <walters@verbum.org> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34393
Diffstat (limited to 'dbus/dbus-bus.c')
-rw-r--r--dbus/dbus-bus.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/dbus/dbus-bus.c b/dbus/dbus-bus.c
index ea4b1482..f05ddea4 100644
--- a/dbus/dbus-bus.c
+++ b/dbus/dbus-bus.c
@@ -661,6 +661,8 @@ dbus_bus_register (DBusConnection *connection,
_dbus_return_val_if_error_is_set (error, FALSE);
retval = FALSE;
+ message = NULL;
+ reply = NULL;
_DBUS_LOCK (bus_datas);
@@ -668,18 +670,16 @@ dbus_bus_register (DBusConnection *connection,
if (bd == NULL)
{
_DBUS_SET_OOM (error);
- _DBUS_UNLOCK (bus_datas);
- return FALSE;
+ goto out;
}
if (bd->unique_name != NULL)
{
_dbus_verbose ("Ignoring attempt to register the same DBusConnection %s with the message bus a second time.\n",
bd->unique_name);
- _DBUS_UNLOCK (bus_datas);
-
/* Success! */
- return TRUE;
+ retval = TRUE;
+ goto out;
}
message = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
@@ -690,15 +690,11 @@ dbus_bus_register (DBusConnection *connection,
if (!message)
{
_DBUS_SET_OOM (error);
-
- _DBUS_UNLOCK (bus_datas);
- return FALSE;
+ goto out;
}
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, error);
- dbus_message_unref (message);
-
if (reply == NULL)
goto out;
else if (dbus_set_error_from_message (error, reply))
@@ -718,14 +714,17 @@ dbus_bus_register (DBusConnection *connection,
retval = TRUE;
out:
+ _DBUS_UNLOCK (bus_datas);
+
+ if (message)
+ dbus_message_unref (message);
+
if (reply)
dbus_message_unref (reply);
if (!retval)
_DBUS_ASSERT_ERROR_IS_SET (error);
- _DBUS_UNLOCK (bus_datas);
-
return retval;
}