mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-01-04 20:10:19 +01:00
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.
This commit is contained in:
parent
fd32a72b2f
commit
0e2a099b55
2 changed files with 29 additions and 8 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 ();
|
||||
open_shutdown_private_connection (TRUE);
|
||||
|
||||
dbus_shutdown ();
|
||||
|
||||
open_shutdown_private_connection (FALSE);
|
||||
|
||||
dbus_shutdown ();
|
||||
|
||||
open_shutdown_private_connection (FALSE);
|
||||
|
||||
dbus_shutdown ();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue