diff options
author | Sven Gothel <[email protected]> | 2022-04-15 01:31:52 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2022-04-15 01:31:52 +0200 |
commit | 0b9dfd8403d0c38dfc40215a8ae88d7b56e60f4d (patch) | |
tree | 054dc1387d1ba8013b294f5f611b752836b4a99c /api | |
parent | a32747398685d5392ff17c00e338d23a177a175f (diff) |
Bump jaulib's service_runner change, adapt and fix BTGattHandler's l2capReader data race (use after free)
BTGattHandler::disconnect():
- If disconnected, ensure to wait until l2cap_reader_service has ended via join(),
otherwise BTDevice could dtor the BTGattHandler!
- Call BTDevice::disconnect() as the last command, since it leads to dtor of this BTGattHandler!
- removed l2capReaderEndFinal() post lock due to data leak (removed from service_runner API as well)
- Have l2capReaderEndLocked() call BTDevice::disconnect() off-thread in case of io-error only,
this is a safe compromise w/o missing a disconnect.
Diffstat (limited to 'api')
-rw-r--r-- | api/direct_bt/BTGattHandler.hpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/api/direct_bt/BTGattHandler.hpp b/api/direct_bt/BTGattHandler.hpp index c2458402..29ed24dd 100644 --- a/api/direct_bt/BTGattHandler.hpp +++ b/api/direct_bt/BTGattHandler.hpp @@ -459,6 +459,7 @@ namespace direct_bt { /** Pass through user Gatt-Server database, non-nullptr if ::GATTRole::Server */ DBGattServerRef gattServerData; + /** Always set, never nullptr */ std::unique_ptr<GattServerHandler> gattServerHandler; static std::unique_ptr<GattServerHandler> selectGattServerHandler(BTGattHandler& gh, DBGattServerRef gattServerData) noexcept; @@ -473,7 +474,6 @@ namespace direct_bt { void l2capReaderWork(jau::service_runner& sr) noexcept; void l2capReaderEndLocked(jau::service_runner& sr) noexcept; - void l2capReaderEndFinal(jau::service_runner& sr) noexcept; /** * BT Core Spec v5.2: Vol 3, Part G GATT: 3.4.2 MTU Exchange @@ -567,7 +567,7 @@ namespace direct_bt { bool isConnected() const noexcept { return is_connected ; } bool hasIOError() const noexcept { return has_ioerror; } - std::string getStateString() const noexcept { return L2CAPComm::getStateString(is_connected, has_ioerror); } + std::string getStateString() const noexcept; /** * Disconnect this BTGattHandler and optionally the associated device |