From 61757e498b4146755051e304622aac3cb17182e2 Mon Sep 17 00:00:00 2001 From: Deokhyun Kim Date: Fri, 3 Jul 2020 15:17:44 +0900 Subject: [PATCH] G_IO_HUP should be checked before G_IO_IN Change-Id: Id9a4ca2bd1fa59160723b831c97687df36db2d39 Signed-off-by: Deokhyun Kim Signed-off-by: Wootak Jung --- bt-api/bt-gatt-client.c | 23 ++++++++++++----------- bt-api/bt-gatt-service.c | 10 ---------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/bt-api/bt-gatt-client.c b/bt-api/bt-gatt-client.c index 539f543..07daf0b 100644 --- a/bt-api/bt-gatt-client.c +++ b/bt-api/bt-gatt-client.c @@ -2119,6 +2119,18 @@ static gboolean bluetooth_gatt_client_notify_channel_watch_cb(GIOChannel *gio, BT_ERR("chr_info is invalid"); return FALSE; } + + if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) { + BT_ERR("Error : GIOCondition %d, [%s]", cond, chr_info->UUID); + g_io_channel_shutdown(gio, TRUE, NULL); + g_io_channel_unref(gio); + + gatt_characteristic_notify_list = g_slist_remove(gatt_characteristic_notify_list, chr_info); + g_free(chr_info); + + return FALSE; + } + if (cond & G_IO_IN) { GIOStatus status = G_IO_STATUS_NORMAL; GError *err = NULL; @@ -2177,17 +2189,6 @@ static gboolean bluetooth_gatt_client_notify_channel_watch_cb(GIOChannel *gio, return TRUE; } - if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) { - BT_ERR("Error : GIOCondition %d, [%s]", cond, chr_info->UUID); - g_io_channel_shutdown(gio, TRUE, NULL); - g_io_channel_unref(gio); - - gatt_characteristic_notify_list = g_slist_remove(gatt_characteristic_notify_list, chr_info); - g_free(chr_info); - - return FALSE; - } - return TRUE; } diff --git a/bt-api/bt-gatt-service.c b/bt-api/bt-gatt-service.c index 9ba2742..c65bf82 100644 --- a/bt-api/bt-gatt-service.c +++ b/bt-api/bt-gatt-service.c @@ -3085,22 +3085,12 @@ static gboolean bluetooth_gatt_server_acquire_channel_write_cb(GIOChannel *gio, } else { BT_ERR("eventinfo failed"); } - - } g_free(buffer); return TRUE; } - if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) { - BT_ERR("Error : GIOCondition %d, ]", cond); - g_io_channel_shutdown(gio, TRUE, NULL); - g_io_channel_unref(gio); - - return FALSE; - } - return TRUE; } -- 2.7.4