summaryrefslogtreecommitdiff
path: root/android/ipc.c
diff options
context:
space:
mode:
authorMarcin Kraglak <marcin.kraglak@tieto.com>2014-01-16 11:04:59 +0100
committerSzymon Janc <szymon.janc@tieto.com>2014-02-03 14:15:00 +0100
commite648a5bd68a474bf97acfeb6e5bbdc6c64641ea5 (patch)
tree181cc2483885e9e495fbc85a4937f694d8a25ddf /android/ipc.c
parent981459271df31b8ed9f20b67a310bb32c7471e00 (diff)
downloadbluez-e648a5bd68a474bf97acfeb6e5bbdc6c64641ea5.tar.gz
android/ipc: Remove watches on cleanup
Remove watches on cleanup. It will avoid receiving events after cleanup.
Diffstat (limited to 'android/ipc.c')
-rw-r--r--android/ipc.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/android/ipc.c b/android/ipc.c
index deeeafb31..ab0f1a4aa 100644
--- a/android/ipc.c
+++ b/android/ipc.c
@@ -45,6 +45,9 @@ static struct service_handler services[HAL_SERVICE_ID_MAX + 1];
static GIOChannel *cmd_io = NULL;
static GIOChannel *notif_io = NULL;
+static guint cmd_watch = 0;
+static guint notif_watch = 0;
+
int ipc_handle_msg(struct service_handler *handlers, size_t max_index,
const void *buf, ssize_t len)
{
@@ -188,11 +191,11 @@ static gboolean notif_connect_cb(GIOChannel *io, GIOCondition cond,
cond = G_IO_ERR | G_IO_HUP | G_IO_NVAL;
- g_io_add_watch(io, cond, notif_watch_cb, NULL);
+ notif_watch = g_io_add_watch(io, cond, notif_watch_cb, NULL);
cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
- g_io_add_watch(cmd_io, cond, cmd_watch_cb, NULL);
+ cmd_watch = g_io_add_watch(cmd_io, cond, cmd_watch_cb, NULL);
info("IPC: successfully connected");
@@ -228,12 +231,22 @@ void ipc_init(void)
void ipc_cleanup(void)
{
+ if (cmd_watch) {
+ g_source_remove(cmd_watch);
+ cmd_watch = 0;
+ }
+
if (cmd_io) {
g_io_channel_shutdown(cmd_io, TRUE, NULL);
g_io_channel_unref(cmd_io);
cmd_io = NULL;
}
+ if (notif_watch) {
+ g_source_remove(notif_watch);
+ notif_watch = 0;
+ }
+
if (notif_io) {
g_io_channel_shutdown(notif_io, TRUE, NULL);
g_io_channel_unref(notif_io);