From 7afc5a6f90a729a458731f36c7d55a2de0c93c1e Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 4 Jul 2011 11:17:48 +0300 Subject: [PATCH] gobex: g_obex_new should create its own GIOChannel ref --- gobex/gobex.c | 2 +- tools/obex-server-tool.c | 3 +++ unit/test-gobex.c | 6 +++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gobex/gobex.c b/gobex/gobex.c index e684628b1..463ac3d01 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 3d93b92b4..b446a87e4 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 6aae16f12..84006c94c 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) -- 2.47.3