aboutsummaryrefslogtreecommitdiff
path: root/include/device_proto.h
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2017-01-13 10:43:15 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2017-03-11 15:41:37 +0100
commit90e626b52c75e9e117494f15f57177aaf912468c (patch)
treef9328aaa8dcd8adc14d62b8c4b9ce100b670cbdd /include/device_proto.h
parent73eac5050abad1b8f0ddbc7e94a11170a640e130 (diff)
downloadlibnitrokey-90e626b52c75e9e117494f15f57177aaf912468c.tar.gz
libnitrokey-90e626b52c75e9e117494f15f57177aaf912468c.tar.bz2
Add lock_guard for complete send-receive cycle
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'include/device_proto.h')
-rw-r--r--include/device_proto.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/include/device_proto.h b/include/device_proto.h
index 667b8db..31bfe11 100644
--- a/include/device_proto.h
+++ b/include/device_proto.h
@@ -32,6 +32,8 @@
#define PWS_SEND_TAB 2
#define PWS_SEND_CR 3
+#include <mutex>
+
namespace nitrokey {
namespace proto {
/*
@@ -204,13 +206,15 @@ namespace nitrokey {
bzero(&st, sizeof(st));
}
-
static ClearingProxy<ResponsePacket, response_payload> run(device::Device &dev,
const command_payload &payload) {
using namespace ::nitrokey::device;
using namespace ::nitrokey::log;
using namespace std::chrono_literals;
+ static std::mutex send_receive_mtx;
+ std::lock_guard<std::mutex> guard(send_receive_mtx);
+
Log::instance()(__PRETTY_FUNCTION__, Loglevel::DEBUG_L2);
int status;