bt_event_info_t *event_info;
bluetooth_l2cap_le_received_data_t data_r;
l2cap_le_client_conn_info_t *conn_info;
-
int fd;
-#ifdef TIZEN_BLUEDROID_PORTING
- char len_buf[2] = {0, 0};
-#endif
gsize len = 0;
char *buffer;
GError *err = NULL;
GIOStatus status = G_IO_STATUS_NORMAL;
+ static int resource_unavailable_cnt = 0;
BT_DBG("+");
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("lecap_le 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);
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);
g_free(buffer);
g_error_free(err);
}
+ if (status == G_IO_STATUS_ERROR ||
+ status == G_IO_STATUS_EOF) {
+ goto fail;
+ } else if (status == G_IO_STATUS_AGAIN) {
+ resource_unavailable_cnt++;
+ if (resource_unavailable_cnt > 10)
+ goto fail;
+ }
+
return TRUE;
}
+ resource_unavailable_cnt = 0;
if (len == 0) {
BT_ERR("Length is zero, remote end hang up");