Fix removing the watch when network session is freed.
This fixes bluetoothd taking a lot of CPU when local
NAP role connection is disconnected.
Change-Id: I8be15622d4dc3bb1a33867e6472b899928473d40
diff --git a/network/server.c b/network/server.c
index 1646eb0..8af1b71 100644
--- a/network/server.c
+++ b/network/server.c
@@ -59,6 +59,7 @@
bdaddr_t dst; /* Remote Bluetooth Address */
GIOChannel *io; /* Pending connect channel */
guint watch; /* BNEP socket watch */
+ guint io_watch;
};
struct network_adapter {
@@ -302,6 +303,9 @@
if (session->watch)
g_source_remove(session->watch);
+ if (session->io_watch)
+ g_source_remove(session->io_watch);
+
if (session->io)
g_io_channel_unref(session->io);
@@ -372,7 +376,7 @@
DBUS_TYPE_UINT16, &dst_role,
DBUS_TYPE_INVALID);
- g_io_add_watch(session->io, G_IO_ERR | G_IO_HUP,
+ session->io_watch = g_io_add_watch(session->io, G_IO_ERR | G_IO_HUP,
(GIOFunc) bnep_watchdog_cb, ns);
return 0;