[glib: 1/2] gio, tests: fix leak of dbus connection.
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] gio, tests: fix leak of dbus connection.
- Date: Mon, 12 Nov 2018 12:14:13 +0000 (UTC)
commit bf1a2d707928e129c96af365330b3ac26b04ad15
Author: INSUN PYO <insun pyo samsung com>
Date: Mon Nov 12 15:45:20 2018 +0900
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
gio/tests/gdbus-example-peer.c | 11 +++++++++++
1 file changed, 11 insertions(+)
---
diff --git a/gio/tests/gdbus-example-peer.c b/gio/tests/gdbus-example-peer.c
old mode 100644
new mode 100755
index 179aabb7f..bf151cfcf
--- a/gio/tests/gdbus-example-peer.c
+++ b/gio/tests/gdbus-example-peer.c
@@ -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
on_new_connection (GDBusServer *server,
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_object_ref (connection);
+ g_signal_connect (connection, "closed", G_CALLBACK (connection_closed), NULL);
registration_id = g_dbus_connection_register_object (connection,
"/org/gtk/GDBus/TestObject",
introspection_data->interfaces[0],
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]