From 72aeb5ed299712dd4a31e871e7d77574a8eb194c Mon Sep 17 00:00:00 2001 From: Sathya Laufer Date: Sun, 13 May 2018 12:09:35 +0200 Subject: [PATCH] Small changes --- src/HomeMaticCentral.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/HomeMaticCentral.cpp b/src/HomeMaticCentral.cpp index 4ed81a2..e1e48d7 100644 --- a/src/HomeMaticCentral.cpp +++ b/src/HomeMaticCentral.cpp @@ -4017,11 +4017,14 @@ PVariable HomeMaticCentral::addDevice(BaseLib::PRpcClientInfo clientInfo, std::s while(!peer && i < 3) { packet->setMessageCounter(getMessageCounter()); - _sendPacketThreadMutex.lock(); - _bl->threadManager.join(_sendPacketThread); - _bl->threadManager.start(_sendPacketThread, false, &HomeMaticCentral::sendPacket, this, GD::defaultPhysicalInterface, packet, false); - _sendPacketThreadMutex.unlock(); - std::this_thread::sleep_for(std::chrono::milliseconds(3000)); + + { + std::lock_guard sendPacketThreadGuard(_sendPacketThreadMutex); + _bl->threadManager.join(_sendPacketThread); + _bl->threadManager.start(_sendPacketThread, false, &HomeMaticCentral::sendPacket, this, GD::defaultPhysicalInterface, packet, false); + } + + std::this_thread::sleep_for(std::chrono::milliseconds(3000)); peer = getPeer(serialNumber); i++; }