diff options
author | Sven Gothel <[email protected]> | 2020-07-26 05:43:13 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-07-26 05:43:13 +0200 |
commit | 86eef03c262a0e93800c1558ce81e32e0d899ab1 (patch) | |
tree | 4ba181d740891b832ce9c24ff02d779f5422b7f8 | |
parent | ce4481eaf4856ab2d2e2c4a9f39093888b34617f (diff) |
GATTHandler: connect/disconnect: Lock mtx_command.
-rw-r--r-- | src/direct_bt/GATTHandler.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/direct_bt/GATTHandler.cpp b/src/direct_bt/GATTHandler.cpp index a3bcbb74..08ea2683 100644 --- a/src/direct_bt/GATTHandler.cpp +++ b/src/direct_bt/GATTHandler.cpp @@ -274,6 +274,8 @@ GATTHandler::~GATTHandler() { } bool GATTHandler::connect() { + const std::lock_guard<std::recursive_mutex> lock(mtx_command); // RAII-style acquire and relinquish via destructor + bool expConn = false; // C++11, exp as value since C++20 if( !isConnected.compare_exchange_strong(expConn, true) ) { // already connected @@ -321,6 +323,8 @@ bool GATTHandler::connect() { } bool GATTHandler::disconnect(const bool disconnectDevice, const bool ioErrorCause) { + const std::lock_guard<std::recursive_mutex> lock(mtx_command); // RAII-style acquire and relinquish via destructor + bool expConn = true; // C++11, exp as value since C++20 if( !isConnected.compare_exchange_strong(expConn, false) ) { // not connected |