From 91230965304bc323a96ced0527d560aacb606415 Mon Sep 17 00:00:00 2001 From: Srinu Jella Date: Mon, 21 Sep 2015 12:00:48 +0530 Subject: [PATCH] Cleanup L2CAP socket properly on close Use case: 1. Sometimes pairing pop up occurs during Android beam transfer though it is not required. 2. No OPP Tx request over OBEX if we cancel during file transfer. Precondition 1. WIFI ON and conneted with AP. Steps: 1. Pair and connect from DUT to remote. 2. Go to gallery and send a file. 3. Accept same file and stop it from remote during transfer. 4. Repeat step 2-4 10 times. Failure: OPP Tx should not fail. Root cause: Close request was not properly handled from BT-IF layer. Fix: 1. Handled the close request properly from BT-IF layer to close the socket variables and instruct the BTA layer close from there as well. 2. Clean up L2CAP socket properly on closure to free the entry registered with security manager to avoid leak in security manager records. Change-Id: I4f5d6ac92317bcaee5f9285ba71d13eea84c737c --- bta/jv/bta_jv_act.c | 1 + btif/src/btif_sock_l2cap.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bta/jv/bta_jv_act.c b/bta/jv/bta_jv_act.c index 52c548119..55ac25e24 100644 --- a/bta/jv/bta_jv_act.c +++ b/bta/jv/bta_jv_act.c @@ -393,6 +393,7 @@ tBTA_JV_STATUS bta_jv_free_l2c_cb(tBTA_JV_L2C_CB *p_cb) } p_cb->psm = 0; p_cb->state = BTA_JV_ST_NONE; + p_cb->cong = FALSE; bta_jv_free_sec_id(&p_cb->sec_id); p_cb->p_cback = NULL; return status; diff --git a/btif/src/btif_sock_l2cap.c b/btif/src/btif_sock_l2cap.c index a0cc3cbdc..2a63b8a26 100644 --- a/btif/src/btif_sock_l2cap.c +++ b/btif/src/btif_sock_l2cap.c @@ -275,9 +275,14 @@ static void btsock_l2cap_free_l(l2cap_socket *sock) } else { BTA_JvFreeChannel(sock->channel, BTA_JV_CONN_TYPE_L2CAP); } + + if (!sock->fixed_chan) { + APPL_TRACE_DEBUG("%s stopping L2CAP server channel %d", __func__, sock->channel); + BTA_JvL2capStopServer(sock->channel, UINT_TO_PTR(sock->id)); + } } - APPL_TRACE_DEBUG("SOCK_LIST: free(id = %d)", sock->id); + APPL_TRACE_DEBUG("%s: free(id = %d)", __func__, sock->id); osi_free(sock); } @@ -598,7 +603,6 @@ static void on_l2cap_close(tBTA_JV_L2CAP_CLOSE * p_close, uint32_t id) APPL_TRACE_DEBUG("on_l2cap_close, slot id:%d, fd:%d, %s:%d, server:%d", sock->id, sock->our_fd, sock->fixed_chan ? "fixed_chan" : "PSM", sock->channel, sock->server); - sock->handle = 0; // TODO: This does not seem to be called... // I'm not sure if this will be called for non-server sockets? if(!sock->fixed_chan && (sock->server == TRUE)) { -- 2.11.0