Disconnect RFCOMM & return false in case g_io_channel returns G_IO_STATUS_EOF 17/224917/2
authorDeokhyun Kim <dukan.kim@samsung.com>
Fri, 14 Feb 2020 05:51:53 +0000 (14:51 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Tue, 18 Feb 2020 04:05:43 +0000 (13:05 +0900)
// 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 <dukan.kim@samsung.com>
bt-api/bt-rfcomm-client.c

index 3a16891..5a3aebf 100644 (file)
@@ -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;
        }