1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 10:24:26 +01:00

Added mutex to door.cpp to prevent lock collissions

Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
This commit is contained in:
Ralf Ramsauer 2015-08-31 19:01:37 +02:00
parent 3a50f596b5
commit 392763f720
2 changed files with 6 additions and 0 deletions

View File

@ -39,6 +39,8 @@ Door::State Door::state() const
void Door::lock() void Door::lock()
{ {
std::lock_guard<std::mutex> l(_mutex);
_l(LogLevel::notice, "Executing Pre Lock Script"); _l(LogLevel::notice, "Executing Pre Lock Script");
system(PRE_LOCK_SCRIPT); system(PRE_LOCK_SCRIPT);

View File

@ -3,6 +3,7 @@
#include <string> #include <string>
#include <thread> #include <thread>
#include <mutex>
#include "logger.h" #include "logger.h"
@ -52,6 +53,9 @@ private:
// Read by the Heartbeat thread if it should klacker the schnapper or not // Read by the Heartbeat thread if it should klacker the schnapper or not
bool _schnapper = { false }; bool _schnapper = { false };
// Mutex to avoid concurrent locks
std::mutex _mutex = { };
// WiringPi GPIO Pins // WiringPi GPIO Pins
static constexpr int _HEARTBEATPIN = 10; static constexpr int _HEARTBEATPIN = 10;
static constexpr int _SCHNAPPERPIN = 7; static constexpr int _SCHNAPPERPIN = 7;