• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/bt


Commit MetaInfo

Revision98eeab03cf9eb7530f617684e5f32ceb25934855 (tree)
Time2020-02-12 10:19:17
AuthorJack He <siyuanh@goog...>
Commiterandroid-build-team Robot

Log Message

L2CAP Socket: Keep track of last allocated socket ID

* Keep track of last allocated socket ID in L2CAP socket stack
* Use last_sock_id + 1 as new IDs when allocating new socket blocks
* The de-dupe and overflow detection mechanism in btsock_l2cap_alloc_l()

would handle the uint32_t overflow and duplicate ID cases

Test: CtsBluetoothTestCases
Bug: 144148429
Change-Id: Ieb9791ffa34eef919a32e4aff6f4b514859c69c0
(cherry picked from commit 79eda3270bbd23814b5ec73ee3fd96ac80222db8)
(cherry picked from commit eb4e9162b91995ae8318745c42dad32e972a8bbd)

Change Summary

Incremental Difference

--- a/btif/src/btif_sock_l2cap.cc
+++ b/btif/src/btif_sock_l2cap.cc
@@ -97,6 +97,7 @@ static void btsock_l2cap_server_listen(l2cap_socket* sock);
9797 static std::mutex state_lock;
9898
9999 l2cap_socket* socks = NULL;
100+static uint32_t last_sock_id = 0;
100101 static uid_set_t* uid_set = NULL;
101102 static int pth = -1;
102103
@@ -327,7 +328,7 @@ static l2cap_socket* btsock_l2cap_alloc_l(const char* name,
327328 sock->next = socks;
328329 sock->prev = NULL;
329330 if (socks) socks->prev = sock;
330- sock->id = (socks ? socks->id : 0) + 1;
331+ sock->id = last_sock_id + 1;
331332 sock->tx_bytes = 0;
332333 sock->rx_bytes = 0;
333334 socks = sock;
@@ -345,6 +346,7 @@ static l2cap_socket* btsock_l2cap_alloc_l(const char* name,
345346 if (!++sock->id) /* no zero IDs allowed */
346347 sock->id++;
347348 }
349+ last_sock_id = sock->id;
348350 DVLOG(2) << __func__ << " SOCK_LIST: alloc id:" << sock->id;
349351 return sock;
350352