mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-25 03:32:12 +01:00
gio, tests: fix leak of dbus connection.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1- Start server gio/tests/.libs/gdbus-example-peer --server --address unix:abstract=/tmp/peer/myaddr 2- Check the open fds for server process lsof -a -p 8253 .................. gdbus-exa 8253 imran 0u CHR 136,1 0t0 4 /dev/pts/1 gdbus-exa 8253 imran 1u CHR 136,1 0t0 4 /dev/pts/1 gdbus-exa 8253 imran 2u CHR 136,1 0t0 4 /dev/pts/1 gdbus-exa 8253 imran 3u 0000 0,9 0 6602 anon_inode gdbus-exa 8253 imran 4u unix 0xf1005680 0t0 966830 @/tmp/peer/myaddr 3- Run the client gio/tests/.libs/gdbus-example-peer --address unix:abstract=/tmp/peer/myaddr 4- Check the open fds for server process again lsof -a -p 8253 .................. gdbus-exa 8253 imran 0u CHR 136,1 0t0 4 /dev/pts/1 gdbus-exa 8253 imran 1u CHR 136,1 0t0 4 /dev/pts/1 gdbus-exa 8253 imran 2u CHR 136,1 0t0 4 /dev/pts/1 gdbus-exa 8253 imran 3u 0000 0,9 0 6602 anon_inode gdbus-exa 8253 imran 4u unix 0xf1005680 0t0 966830 @/tmp/peer/myaddr gdbus-exa 8253 imran 5u unix 0xf1004280 0t0 965811 @/tmp/peer/myaddr gdbus-exa 8253 imran 6u 0000 0,9 0 6602 anon_inode 5- Please note the fd '5u' which is created when client makes connection but even when the client goes down, the descriptor is still there.. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// https://bugzilla.gnome.org/show_bug.cgi?id=734281
This commit is contained in:
parent
fcda663165
commit
bf1a2d7079
11
gio/tests/gdbus-example-peer.c
Normal file → Executable file
11
gio/tests/gdbus-example-peer.c
Normal file → Executable file
@ -121,6 +121,16 @@ static const GDBusInterfaceVTable interface_vtable =
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static void
|
||||||
|
connection_closed (GDBusConnection *connection,
|
||||||
|
gboolean remote_peer_vanished,
|
||||||
|
GError *Error,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
g_print ("Client disconnected.\n");
|
||||||
|
g_object_unref (connection);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
on_new_connection (GDBusServer *server,
|
on_new_connection (GDBusServer *server,
|
||||||
GDBusConnection *connection,
|
GDBusConnection *connection,
|
||||||
@ -144,6 +154,7 @@ on_new_connection (GDBusServer *server,
|
|||||||
g_dbus_connection_get_capabilities (connection) & G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING);
|
g_dbus_connection_get_capabilities (connection) & G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING);
|
||||||
|
|
||||||
g_object_ref (connection);
|
g_object_ref (connection);
|
||||||
|
g_signal_connect (connection, "closed", G_CALLBACK (connection_closed), NULL);
|
||||||
registration_id = g_dbus_connection_register_object (connection,
|
registration_id = g_dbus_connection_register_object (connection,
|
||||||
"/org/gtk/GDBus/TestObject",
|
"/org/gtk/GDBus/TestObject",
|
||||||
introspection_data->interfaces[0],
|
introspection_data->interfaces[0],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user