From 72e865345c700650889ceb35c391e2222c46e082 Mon Sep 17 00:00:00 2001 From: Deokhyun Kim Date: Fri, 14 Feb 2020 14:51:53 +0900 Subject: [PATCH] Disconnect RFCOMM & return false in case g_io_channel returns G_IO_STATUS_EOF // Repeats infinitely 02-14 11:48:12.591+0900 E/BLUETOOTH_FRWK_API(P 4373, T 4373): bt-rfcomm-client.c: __client_data_received_cb(353) > IO Channel read is failed with 2 02-14 11:48:13.667+0900 E/BLUETOOTH_FRWK_API(P 4373, T 4373): bt-rfcomm-client.c: __client_data_received_cb(353) > IO Channel read is failed with 2 ........... 02-14 11:48:24.251+0900 E/BLUETOOTH_FRWK_API(P 4373, T 4373): bt-rfcomm-client.c: __client_data_received_cb(353) > IO Channel read is failed with 2 02-14 11:48:24.251+0900 E/BLUETOOTH_FRWK_API(P 4373, T 4373): bt-rfcomm-client.c: __client_data_received_cb(353) > IO Channel read is failed with 2 Change-Id: Ifb630b340a8eabbe4781239b580e9242c99bf899 Signed-off-by: Deokhyun Kim --- bt-api/bt-rfcomm-client.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/bt-api/bt-rfcomm-client.c b/bt-api/bt-rfcomm-client.c index 3a16891..5a3aebf 100644 --- a/bt-api/bt-rfcomm-client.c +++ b/bt-api/bt-rfcomm-client.c @@ -352,12 +352,16 @@ static gboolean __client_data_received_cb(GIOChannel *chan, GIOCondition cond, BT_ERR("IO Channel read is failed with %d", status); g_free(buffer); - if (err) { - BT_ERR("IO Channel read error [%s]", err->message); - if (status == G_IO_STATUS_ERROR && - __is_error_by_disconnect(err)) { + if (err || status == G_IO_STATUS_EOF) { + if (err) + BT_ERR("IO Channel read error [%s]", err->message); + if ((status == G_IO_STATUS_EOF) || + (status == G_IO_STATUS_ERROR && + __is_error_by_disconnect(err))) { + BT_ERR("cond : %d", cond); - g_error_free(err); + if (err) + g_error_free(err); conn_info = __get_conn_info_from_fd(info, fd); if (conn_info == NULL) { @@ -372,7 +376,8 @@ static gboolean __client_data_received_cb(GIOChannel *chan, GIOCondition cond, __rfcomm_client_disconnect(info); return FALSE; } - g_error_free(err); + if (err) + g_error_free(err); } return TRUE; } -- 2.7.4