From b9af80de90c8d4c13024718cca403017cf91cf97 Mon Sep 17 00:00:00 2001 From: Deokhyun Kim Date: Fri, 7 Aug 2020 15:50:34 +0900 Subject: [PATCH] Skip error handling in case of G_IO_NVAL, because the channel is invalid Change-Id: I554ff309e0291b2e014e8e1d88eeaf957030019f Signed-off-by: Deokhyun Kim Signed-off-by: Wootak Jung --- bt-api/bt-gatt-service.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/bt-api/bt-gatt-service.c b/bt-api/bt-gatt-service.c index ae26396..d848399 100644 --- a/bt-api/bt-gatt-service.c +++ b/bt-api/bt-gatt-service.c @@ -400,8 +400,13 @@ static gboolean bluetooth_gatt_write_channel_watch_cb(GIOChannel *gio, return FALSE; } - if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) { - BT_ERR("Error : GIOCondition %d, []", cond);; + if (cond & G_IO_NVAL) { + BT_ERR("Invalid channel"); + return FALSE; + } + + if (cond & (G_IO_HUP | G_IO_ERR)) { + BT_ERR("Error : GIOCondition %d", cond); g_io_channel_shutdown(gio, TRUE, NULL); g_io_channel_unref(gio); @@ -3058,6 +3063,19 @@ static gboolean bluetooth_gatt_server_acquire_channel_write_cb(GIOChannel *gio, BT_DBG("FD io write data received [%s]", write_data->address); + if (cond & G_IO_NVAL) { + BT_ERR("Invalid channel"); + return FALSE; + } + + if (cond & (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; + } + if (cond & G_IO_IN) { GIOStatus status = G_IO_STATUS_NORMAL; GError *err = NULL; -- 2.7.4