From 751ea82bda0105b6ee820279ff358b9dd1765e8a Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Tue, 31 Jan 2017 22:19:17 +0100 Subject: [PATCH] bluez5: Replaced 'g_io_add_watch_full' by 'gattlib_watch_connection_full' --- bluez5/btio/btio.c | 7 ++++--- bluez5/src/shared/io-glib.c | 21 +++++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/bluez5/btio/btio.c b/bluez5/btio/btio.c index f127ce2..39bb95d 100644 --- a/bluez5/btio/btio.c +++ b/bluez5/btio/btio.c @@ -42,6 +42,7 @@ #include "lib/sco.h" #include "btio.h" +#include "gattlib_internal.h" #ifndef BT_FLUSHABLE #define BT_FLUSHABLE 8 @@ -283,7 +284,7 @@ static void server_add(GIOChannel *io, BtIOConnect connect, server->destroy = destroy; cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL; - g_io_add_watch_full(io, G_PRIORITY_DEFAULT, cond, server_cb, server, + gattlib_watch_connection_full(io, cond, server_cb, server, (GDestroyNotify) server_remove); } @@ -299,7 +300,7 @@ static void connect_add(GIOChannel *io, BtIOConnect connect, conn->destroy = destroy; cond = G_IO_OUT | G_IO_ERR | G_IO_HUP | G_IO_NVAL; - g_io_add_watch_full(io, G_PRIORITY_DEFAULT, cond, connect_cb, conn, + gattlib_watch_connection_full(io, cond, connect_cb, conn, (GDestroyNotify) connect_remove); } @@ -315,7 +316,7 @@ static void accept_add(GIOChannel *io, BtIOConnect connect, gpointer user_data, accept->destroy = destroy; cond = G_IO_OUT | G_IO_ERR | G_IO_HUP | G_IO_NVAL; - g_io_add_watch_full(io, G_PRIORITY_DEFAULT, cond, accept_cb, accept, + gattlib_watch_connection_full(io, cond, accept_cb, accept, (GDestroyNotify) accept_remove); } diff --git a/bluez5/src/shared/io-glib.c b/bluez5/src/shared/io-glib.c index 6687a6b..4c747b6 100644 --- a/bluez5/src/shared/io-glib.c +++ b/bluez5/src/shared/io-glib.c @@ -30,10 +30,11 @@ #include #include "src/shared/io.h" +#include "gattlib_internal.h" struct io_watch { struct io *io; - guint id; + GSource* id; io_callback_func_t callback; io_destroy_func_t destroy; void *user_data; @@ -114,17 +115,17 @@ void io_destroy(struct io *io) return; if (io->read_watch) { - g_source_remove(io->read_watch->id); + g_source_destroy(io->read_watch->id); io->read_watch = NULL; } if (io->write_watch) { - g_source_remove(io->write_watch->id); + g_source_destroy(io->write_watch->id); io->write_watch = NULL; } if (io->disconnect_watch) { - g_source_remove(io->disconnect_watch->id); + g_source_destroy(io->disconnect_watch->id); io->disconnect_watch = NULL; } @@ -189,11 +190,11 @@ static struct io_watch *watch_new(struct io *io, GIOCondition cond, watch->destroy = destroy; watch->user_data = user_data; - watch->id = g_io_add_watch_full(io->channel, G_PRIORITY_DEFAULT, - cond | G_IO_ERR | G_IO_NVAL, - watch_callback, watch, - watch_destroy); - if (watch->id == 0) { + watch->id = gattlib_watch_connection_full(io->channel, + cond | G_IO_ERR | G_IO_NVAL, + watch_callback, watch, + watch_destroy); + if (watch->id == NULL) { watch_destroy(watch); return NULL; } @@ -228,7 +229,7 @@ static bool io_set_handler(struct io *io, GIOCondition cond, } if (*watch) { - g_source_remove((*watch)->id); + g_source_destroy((*watch)->id); *watch = NULL; }