OSDN Git Service

Cleanup L2CAP socket properly on close
authorSrinu Jella <sjella@codeaurora.org>
Thu, 7 Apr 2016 13:35:44 +0000 (19:05 +0530)
committerAjay Panicker <apanicke@google.com>
Fri, 14 Oct 2016 17:41:49 +0000 (17:41 +0000)
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.

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 BTIF layer.

Fix:
1. Close the request properly from BTIF 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.

3. Close the socket for all valid handles including handle 0.

Change-Id: I4e37dcd858af258fbd64fbfb2fbf0083bd743e06

btif/src/btif_sock_l2cap.cc

index 60c06b6..73cc7e0 100644 (file)
@@ -283,6 +283,11 @@ static void btsock_l2cap_free_l(l2cap_socket *sock)
                 BTA_JvFreeChannel(sock->channel, BTA_JV_CONN_TYPE_L2CAP_LE);
             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));
+            }
         }
     }