Fix infinite callback issue in EOF status
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-l2cap-le-server.c
index c961f42..a4e767c 100644 (file)
@@ -408,9 +408,6 @@ static int __sock_read(int server_fd, char *buf, unsigned int len,
 static gboolean __data_received_cb(GIOChannel *chan, GIOCondition cond,
                                                gpointer data)
 {
-#ifdef TIZEN_BLUEDROID_PORTING
-       char len_buf[2] = {0, 0};
-#endif
        char *buffer = NULL;
        gsize len = 0;
        int result = BLUETOOTH_ERROR_NONE;
@@ -430,56 +427,22 @@ static gboolean __data_received_cb(GIOChannel *chan, GIOCondition cond,
                goto fail;
        }
 
-#ifdef TIZEN_BLUEDROID_PORTING
-       /* Read buffer length from socket */
-       status = g_io_channel_read_chars(chan, len_buf, sizeof(len_buf), &len, &err);
-       if (status != G_IO_STATUS_NORMAL) {
-               BT_ERR("IO Channel read is failed with %d", status);
-               if (err) {
-                       BT_ERR("IO Channel read error [%s]", err->message);
-                       if (status == G_IO_STATUS_ERROR &&
-                                       !g_strcmp0(err->message,
-                                               "Connection reset by peer"))
-                               BT_ERR("cond : %d", cond);
-
-                       g_error_free(err);
-               }
-               goto fail;
-       }
-
-       if (len == 0) {
-               BT_ERR("Length is zero, remote end hang up");
-               goto fail;
-       }
-
-       len = (unsigned char)len_buf[0] + ((unsigned char)len_buf[1] << 8);
-       BT_INFO("Recieved buffer len: %d", len);
-
-       /* Read len bytes in buffer from socket */
-       buffer = g_malloc0(len + 1);
-       status = g_io_channel_read_chars(chan, buffer, len, &len, &err);
-#else
        buffer = g_malloc0(BT_L2CAP_LE_BUFFER_LEN + 1);
        g_io_channel_set_buffer_size(chan, BT_L2CAP_LE_BUFFER_LEN);
        status = g_io_channel_read_chars(chan, buffer,
                        BT_L2CAP_LE_BUFFER_LEN, &len, &err);
-#endif
-
        if (status != G_IO_STATUS_NORMAL) {
-               BT_ERR("IO Channel read is failed with %d", status);
+               BT_ERR("IO Channel read is failed with %d(%s)", status, _bt_print_gio_status(status));
                g_free(buffer);
+
+               if (status == G_IO_STATUS_AGAIN)
+                       return TRUE;
+
                if (err) {
                        BT_ERR("IO Channel read error [%s]", err->message);
-                       if (status == G_IO_STATUS_ERROR &&
-                                       !g_strcmp0(err->message, "Connection reset by peer")) {
-                               BT_ERR("cond : %d", cond);
-                               g_error_free(err);
-                               goto fail;
-                       }
                        g_error_free(err);
                }
-
-               return TRUE;
+               goto fail;
        }
 
        if (len == 0) {