diff --git a/gobex/gobex.c b/gobex/gobex.c
index e684628..463ac3d 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
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
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
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)