return FALSE;
}
-static gboolean __is_error_by_disconnect(GError *err)
-{
- return !g_strcmp0(err->message, "Connection reset by peer") ||
- !g_strcmp0(err->message, "Connection timed out") ||
- !g_strcmp0(err->message, "Software caused connection abort");
-}
-
static gboolean __data_received_cb(GIOChannel *chan, GIOCondition cond,
gpointer data)
{
}
buffer = g_malloc0(BT_RFCOMM_BUFFER_LEN + 1);
-
status = g_io_channel_read_chars(chan, buffer, BT_RFCOMM_BUFFER_LEN,
&len, &err);
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 (!err)
+
+ if (status == G_IO_STATUS_AGAIN)
return TRUE;
- 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) {
+ BT_ERR("IO Channel read error [%s]", err->message);
g_error_free(err);
+ }
- if (info->disconnect_idle_id > 0) {
- BT_INFO("Disconnect idle still not process remove source");
- g_source_remove(info->disconnect_idle_id);
- info->disconnect_idle_id = 0;
- }
-
- conn = __find_rfcomm_conn_with_fd(info, fd);
- if (conn == NULL) {
- BT_ERR("No Connection info found with FD [%d]", fd);
- return FALSE;
- }
+ if (info->disconnect_idle_id > 0) {
+ BT_INFO("Disconnect idle still not process remove source");
+ g_source_remove(info->disconnect_idle_id);
+ info->disconnect_idle_id = 0;
+ }
- if (conn->disconnected == FALSE) {
- close(conn->fd);
- conn->disconnected = TRUE;
- }
- __rfcomm_server_disconnect(info);
+ conn = __find_rfcomm_conn_with_fd(info, fd);
+ if (conn == NULL) {
+ BT_ERR("No Connection info found with FD [%d]", fd);
return FALSE;
}
- g_error_free(err);
- return TRUE;
+
+ if (conn->disconnected == FALSE) {
+ close(conn->fd);
+ conn->disconnected = TRUE;
+ }
+ __rfcomm_server_disconnect(info);
+ return FALSE;
}
if (len == 0)
status = g_io_channel_read_chars(chan, buffer,
BT_RFCOMM_BUFFER_LEN, &len, &err);
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) {