OSDN Git Service

android/socket: Avoid double close of file descriptor
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Thu, 28 Nov 2013 14:38:05 +0000 (16:38 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Fri, 29 Nov 2013 08:30:11 +0000 (10:30 +0200)
Since we close all file descriptors in cleanup_rfsock do not close it also
during iochannel cleaning up. The flag was setup in bt_io_listen and
bt_io_connect calls.

android/socket.c

index 6e3ef26..8ffa530 100644 (file)
@@ -641,6 +641,7 @@ static void accept_cb(GIOChannel *io, GError *err, gpointer user_data)
        /* Handle rfcomm events */
        cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
        id = g_io_add_watch(io, cond, sock_rfcomm_event_cb, rfsock_acc);
+       g_io_channel_set_close_on_unref(io, FALSE);
 
        rfsock_acc->rfcomm_watch = id;
 
@@ -777,6 +778,7 @@ static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
        /* Handle rfcomm events */
        cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
        id = g_io_add_watch(io, cond, sock_rfcomm_event_cb, rfsock);
+       g_io_channel_set_close_on_unref(io, FALSE);
 
        rfsock->rfcomm_watch = id;