GIOStatus status = G_IO_STATUS_NORMAL;
GError *err = NULL;
int fd;
+ static int resource_unavailable_cnt = 0;
retv_if(info == NULL, FALSE);
fd = g_io_channel_unix_get_fd(chan);
BT_ERR("IO Channel read is failed with %d", status);
g_free(buffer);
- 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))) {
+
+ if (err) {
+ BT_ERR("IO Channel read error [%s]", err->message);
+ if (status == G_IO_STATUS_ERROR &&
+ __is_error_by_disconnect(err)) {
BT_ERR("cond : %d", cond);
- if (err)
- g_error_free(err);
-
- conn_info = __get_conn_info_from_fd(info, fd);
- if (conn_info == NULL) {
- BT_ERR("No Connection info found with FD [%d]", fd);
- return FALSE;
- }
-
- if (conn_info->disconnected == FALSE) {
- close(conn_info->fd);
- conn_info->disconnected = TRUE;
- }
- __rfcomm_client_disconnect(info);
- return FALSE;
- }
- if (err)
g_error_free(err);
+ goto fail;
+ }
+ 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;
event_info = _bt_event_get_cb_data(BT_RFCOMM_CLIENT_EVENT);
if (event_info == NULL) {
if (bluetooth_get_battery_monitor_state()) {
if (rx_tag == 0) {
- BT_INFO("Adding rfcomm rx timeout function for battery monitor");
+ BT_DBG("Adding rfcomm rx timeout function for battery monitor");
rx_tag = g_timeout_add_seconds(BATTERY_MONITOR_RFCOMM_INTERVAL, (GSourceFunc)__rfcomm_record_rx_data, NULL);
}
rx_data += len;
g_free(buffer);
return TRUE;
+
+fail:
+ conn_info = __get_conn_info_from_fd(info, fd);
+ if (conn_info == NULL) {
+ BT_ERR("No Connection info found with FD [%d]", fd);
+ return FALSE;
+ }
+
+ if (conn_info->disconnected == FALSE) {
+ close(conn_info->fd);
+ conn_info->disconnected = TRUE;
+ }
+ __rfcomm_client_disconnect(info);
+
+ return FALSE;
}
static void __client_connected_cb(rfcomm_cb_data_t *cb_data, char *dev_address,
length, written, length - written); */
if (written > 0 && bluetooth_get_battery_monitor_state()) {
if (tx_tag == 0) {
- BT_INFO("Adding rfcomm tx timeout function for battery monitor");
+ BT_DBG("Adding rfcomm tx timeout function for battery monitor");
tx_tag = g_timeout_add_seconds(BATTERY_MONITOR_RFCOMM_INTERVAL, (GSourceFunc)__rfcomm_record_tx_data, NULL);
}
- tx_data += length;
+ tx_data += written;
}
return written;
#else
result = __write_all(fd, buf, length);
if (result > 0 && bluetooth_get_battery_monitor_state()) {
if (tx_tag == 0) {
- BT_INFO("Adding rfcomm tx timeout function for battery monitor");
+ BT_DBG("Adding rfcomm tx timeout function for battery monitor");
tx_tag = g_timeout_add_seconds(BATTERY_MONITOR_RFCOMM_INTERVAL, (GSourceFunc)__rfcomm_record_tx_data, NULL);
}
- tx_data += length;
+ tx_data += written;
}
return result;
#endif