mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-12-22 18:34:25 +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:
parent
368a22b9b1
commit
026d2bdd10
@ -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);
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user