aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-09-19 03:44:07 +0200
committerSven Gothel <[email protected]>2020-09-19 03:44:07 +0200
commit8092f1bcf0edcdfb8cd3cb842bab2a23dce0fc2e (patch)
tree7a014e9b61abbd66bb95d033f428dad5f8af9934
parent60151ef8fdacfb2d8a1aaf6d6df6c51b65c3fe70 (diff)
GATTHandler::ioErrorCause: Use in l2capReaderThreadImpl (drop local var) and in sendWithReply(..) like in send(..)v2.1.24
validateConnected() propagates l2capHasIOError -> has_ioerror We might just drop this atomic state, however, it is still relevant in validateConnected(), being called concurrently. It is cleared within disconnect(..).
-rw-r--r--src/direct_bt/GATTHandler.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/direct_bt/GATTHandler.cpp b/src/direct_bt/GATTHandler.cpp
index 14543e2f..18fa45b4 100644
--- a/src/direct_bt/GATTHandler.cpp
+++ b/src/direct_bt/GATTHandler.cpp
@@ -83,6 +83,7 @@ bool GATTHandler::validateConnected() noexcept {
bool l2capHasIOError = l2cap.hasIOError();
if( has_ioerror || l2capHasIOError ) {
+ has_ioerror = true; // propagate l2capHasIOError -> has_ioerror
ERR_PRINT("IOError state: GattHandler %s, l2cap %s: %s",
getStateString().c_str(), l2cap.getStateString().c_str(), deviceString.c_str());
return false;
@@ -176,7 +177,6 @@ bool GATTHandler::getSendIndicationConfirmation() noexcept {
}
void GATTHandler::l2capReaderThreadImpl() {
- bool ioErrorCause = false;
{
const std::lock_guard<std::mutex> lock(mtx_l2capReaderInit); // RAII-style acquire and relinquish via destructor
l2capReaderShallStop = false;
@@ -257,14 +257,14 @@ void GATTHandler::l2capReaderThreadImpl() {
} else if( ETIMEDOUT != errno && !l2capReaderShallStop ) { // expected exits
IRQ_PRINT("GATTHandler::l2capReaderThread: l2cap read error -> Stop");
l2capReaderShallStop = true;
- ioErrorCause = true;
+ has_ioerror = true;
}
}
WORDY_PRINT("l2capReaderThreadImpl Ended. Ring has %d entries flushed", attPDURing.getSize());
l2capReaderRunning = false;
attPDURing.clear();
- disconnect(true /* disconnectDevice */, ioErrorCause);
+ disconnect(true /* disconnectDevice */, has_ioerror);
}
GATTHandler::GATTHandler(const std::shared_ptr<DBTDevice> &device) noexcept
@@ -415,6 +415,7 @@ std::shared_ptr<const AttPDUMsg> GATTHandler::sendWithReply(const AttPDUMsg & ms
if( nullptr == res ) {
errno = ETIMEDOUT;
IRQ_PRINT("GATTHandler::sendWithReply: nullptr result (timeout %d): req %s to %s", timeout, msg.toString().c_str(), deviceString.c_str());
+ has_ioerror = true;
disconnect(true /* disconnectDevice */, true /* ioErrorCause */);
throw BluetoothException("GATTHandler::sendWithReply: nullptr result (timeout "+std::to_string(timeout)+"): req "+msg.toString()+" to "+deviceString, E_FILE_LINE);
}