Diff between 0b362843b0b27db4d46b23295bb335431e64f332 and 7afc5a6f90a729a458731f36c7d55a2de0c93c1e

Changed Files

File Additions Deletions Status
gobex/gobex.c +1 -1 modified
tools/obex-server-tool.c +3 -0 modified
unit/test-gobex.c +5 -1 modified

Full Patch

diff --git a/gobex/gobex.c b/gobex/gobex.c
index e684628..463ac3d 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -663,7 +663,7 @@ GObex *g_obex_new(GIOChannel *io, GObexTransportType transport_type,
 
 	obex = g_new0(GObex, 1);
 
-	obex->io = io;
+	obex->io = g_io_channel_ref(io);
 	obex->ref_count = 1;
 
 	obex->io_rx_mtu = io_rx_mtu;
diff --git a/tools/obex-server-tool.c b/tools/obex-server-tool.c
index 3d93b92..b446a87 100644
--- a/tools/obex-server-tool.c
+++ b/tools/obex-server-tool.c
@@ -80,9 +80,12 @@ static gboolean unix_accept(GIOChannel *chan, GIOCondition cond, gpointer data)
 								cli_sk);
 
 	io = g_io_channel_unix_new(cli_sk);
+
 	g_io_channel_set_flags(io, G_IO_FLAG_NONBLOCK, NULL);
+	g_io_channel_set_close_on_unref(io, TRUE);
 
 	obex = g_obex_new(io, G_OBEX_TRANSPORT_STREAM, -1, -1);
+	g_io_channel_unref(io);
 	g_obex_set_disconnect_function(obex, disconn_func, NULL);
 	clients = g_slist_append(clients, obex);;
 
diff --git a/unit/test-gobex.c b/unit/test-gobex.c
index 6aae16f..84006c9 100644
--- a/unit/test-gobex.c
+++ b/unit/test-gobex.c
@@ -65,13 +65,17 @@ static GObex *create_gobex(int fd, GObexTransportType transport_type,
 						gboolean close_on_unref)
 {
 	GIOChannel *io;
+	GObex *obex;
 
 	io = g_io_channel_unix_new(fd);
 	g_assert(io != NULL);
 
 	g_io_channel_set_close_on_unref(io, close_on_unref);
 
-	return g_obex_new(io, transport_type, -1, -1);
+	obex = g_obex_new(io, transport_type, -1, -1);
+	g_io_channel_unref(io);
+
+	return obex;
 }
 
 static void create_endpoints(GObex **obex, GIOChannel **io, int sock_type)