diff options
author | Colin Walters <walters@verbum.org> | 2008-05-30 20:25:36 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2008-05-30 20:25:36 -0400 |
commit | 0e2a099b55a50b9b5a0f948e134b5a88e2924262 (patch) | |
tree | 6394550e4478877f735d59016f1d950475962779 | |
parent | fd32a72b2f3855ef551d0063ea1e6bea4554be08 (diff) |
Bug 15571: Clean up GUID-less connections correctly (Scott James Remnant)
* dbus/dbus-connection.c (connection_forget_shared_unlocked):
Remove shared connections which lack a GUID from the list that
caches those, otherwise references to them will remain after
they have been freed.
* test/name-test/test-privserver-client.c: Update test to
try GUID-less connections too.
-rw-r--r-- | dbus/dbus-connection.c | 11 | ||||
-rw-r--r-- | test/name-test/test-privserver-client.c | 26 |
2 files changed, 29 insertions, 8 deletions
diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 7b13b249..1f427dd3 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -1678,21 +1678,26 @@ connection_forget_shared_unlocked (DBusConnection *connection) if (!connection->shareable) return; + _DBUS_LOCK (shared_connections); + if (connection->server_guid != NULL) { _dbus_verbose ("dropping connection to %s out of the shared table\n", connection->server_guid); - _DBUS_LOCK (shared_connections); - if (!_dbus_hash_table_remove_string (shared_connections, connection->server_guid)) _dbus_assert_not_reached ("connection was not in the shared table"); dbus_free (connection->server_guid); connection->server_guid = NULL; - _DBUS_UNLOCK (shared_connections); } + else + { + _dbus_list_remove (&shared_connections_no_guid, connection); + } + + _DBUS_UNLOCK (shared_connections); /* remove our reference held on all shareable connections */ _dbus_connection_unref_unlocked (connection); diff --git a/test/name-test/test-privserver-client.c b/test/name-test/test-privserver-client.c index 5a3f399b..239b7bdf 100644 --- a/test/name-test/test-privserver-client.c +++ b/test/name-test/test-privserver-client.c @@ -27,7 +27,7 @@ filter_private_message (DBusConnection *connection, } static void -open_shutdown_private_connection () +open_shutdown_private_connection (dbus_bool_t use_guid) { DBusError error; DBusLoop *loop; @@ -35,7 +35,8 @@ open_shutdown_private_connection () DBusMessage *msg; DBusMessage *reply; DBusConnection *privconn; - const char *addr; + char *addr; + char *comma; dbus_error_init (&error); @@ -55,8 +56,15 @@ open_shutdown_private_connection () if (!dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &addr, DBUS_TYPE_INVALID)) die ("couldn't parse message replym\n"); printf ("got private temp address %s\n", addr); - + addr = strdup (addr); + if (!use_guid) + { + char *comma = strrchr (addr, ','); + if (comma) + *comma = '\0'; + } privconn = dbus_connection_open (addr, &error); + free (addr); if (!privconn) die ("couldn't connect to server direct connection: %s\n", error.message); dbus_message_unref (reply); @@ -88,11 +96,19 @@ open_shutdown_private_connection () int main (int argc, char *argv[]) { - open_shutdown_private_connection (); + open_shutdown_private_connection (TRUE); + + dbus_shutdown (); + + open_shutdown_private_connection (TRUE); + + dbus_shutdown (); + + open_shutdown_private_connection (FALSE); dbus_shutdown (); - open_shutdown_private_connection (); + open_shutdown_private_connection (FALSE); dbus_shutdown (); |