1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 02:14: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 368a22b9b1
commit 026d2bdd10
2 changed files with 6 additions and 0 deletions

View File

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

View File

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