When rfcomm incoming queue is not empty, waiting for app ready to drain the data
Fixed the issue that rfcomm inbound packets could be out of order when host
flow control is activating.
bug 11031800
Change-Id: Idc1eb6633bb070f1ab2b33a9751fd7d714764d45
diff --git a/btif/src/btif_sock_rfc.c b/btif/src/btif_sock_rfc.c
index 0669557..cdc51a9 100644
--- a/btif/src/btif_sock_rfc.c
+++ b/btif/src/btif_sock_rfc.c
@@ -939,25 +939,29 @@
rfc_slot_t* rs = find_rfc_slot_by_id(id);
if(rs)
{
-
- int sent = send_data_to_app(rs->fd, p_buf);
- switch(sent)
+ if(!GKI_queue_is_empty(&rs->incoming_que))
+ GKI_enqueue(&rs->incoming_que, p_buf);
+ else
{
- case SENT_NONE:
- case SENT_PARTIAL:
- //add it to the end of the queue
- GKI_enqueue(&rs->incoming_que, p_buf);
- //monitor the fd to get callback when app is ready to receive data
- btsock_thread_add_fd(pth, rs->fd, BTSOCK_RFCOMM, SOCK_THREAD_FD_WR, rs->id);
- break;
- case SENT_ALL:
- GKI_freebuf(p_buf);
- ret = 1;//enable the data flow
- break;
- case SENT_FAILED:
- GKI_freebuf(p_buf);
- cleanup_rfc_slot(rs);
- break;
+ int sent = send_data_to_app(rs->fd, p_buf);
+ switch(sent)
+ {
+ case SENT_NONE:
+ case SENT_PARTIAL:
+ //add it to the end of the queue
+ GKI_enqueue(&rs->incoming_que, p_buf);
+ //monitor the fd to get callback when app is ready to receive data
+ btsock_thread_add_fd(pth, rs->fd, BTSOCK_RFCOMM, SOCK_THREAD_FD_WR, rs->id);
+ break;
+ case SENT_ALL:
+ GKI_freebuf(p_buf);
+ ret = 1;//enable the data flow
+ break;
+ case SENT_FAILED:
+ GKI_freebuf(p_buf);
+ cleanup_rfc_slot(rs);
+ break;
+ }
}
}
unlock_slot(&slot_lock);