From c69555a4642e3d74a192c45500a0424bf0fa6ccc Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 25 Feb 2009 15:20:40 +0200 Subject: Default to close_on_unref = TRUE to avoid descriptor leaks --- common/btio.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'common/btio.c') diff --git a/common/btio.c b/common/btio.c index dbbc4287..9ff407fd 100644 --- a/common/btio.c +++ b/common/btio.c @@ -148,10 +148,8 @@ static gboolean connect_cb(GIOChannel *io, GIOCondition cond, conn->connect(io, gerr, conn->user_data); - if (gerr) { - g_io_channel_shutdown(io, FALSE, NULL); + if (gerr) g_error_free(gerr); - } return FALSE; } @@ -177,6 +175,9 @@ static gboolean server_cb(GIOChannel *io, GIOCondition cond, cli_io = g_io_channel_unix_new(cli_sock); + g_io_channel_set_close_on_unref(cli_io, TRUE); + g_io_channel_set_flags(cli_io, G_IO_FLAG_NONBLOCK, NULL); + if (server->confirm) server->confirm(cli_io, server->user_data); else @@ -1138,6 +1139,7 @@ static GIOChannel *create_io(BtIOType type, gboolean server, io = g_io_channel_unix_new(sock); + g_io_channel_set_close_on_unref(io, TRUE); g_io_channel_set_flags(io, G_IO_FLAG_NONBLOCK, NULL); return io; -- cgit