aboutsummaryrefslogtreecommitdiff
path: root/src/device/device_ledger.hpp
diff options
context:
space:
mode:
authorcslashm <cslashm@gmail.com>2018-03-26 12:38:38 +0200
committercslashm <cslashm@gmail.com>2018-03-31 18:00:33 +0200
commit100b7bc10dcb83f81d6bbd37eca1c8708c4dfbb6 (patch)
treede26f5d5de0f90bc98bb78c66642b5ded53e5faa /src/device/device_ledger.hpp
parentAutomatic height setup when creating/restoring hw device. (diff)
downloadmonero-100b7bc10dcb83f81d6bbd37eca1c8708c4dfbb6.tar.xz
Change mutex lock model to avoid dead lock and ensure locks are always released.
Additional cosmetic fixes: move 'name' as protected remove unnecessary local var Fix debug log
Diffstat (limited to '')
-rw-r--r--src/device/device_ledger.hpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/device/device_ledger.hpp b/src/device/device_ledger.hpp
index e06c5f72c..2053067bd 100644
--- a/src/device/device_ledger.hpp
+++ b/src/device/device_ledger.hpp
@@ -36,7 +36,8 @@
#include "device.hpp"
#include <PCSC/winscard.h>
#include <PCSC/wintypes.h>
-
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/recursive_mutex.hpp>
namespace hw {
@@ -80,13 +81,11 @@ namespace hw {
class device_ledger : public hw::device {
private:
- mutable std::mutex device_locker;
- mutable std::mutex tx_locker;
- void lock_device() ;
- void unlock_device() ;
- void lock_tx() ;
- void unlock_tx() ;
-
+ // Locker for concurrent access
+ mutable boost::recursive_mutex device_locker;
+ mutable boost::mutex command_locker;
+
+ //PCSC management
std::string full_name;
SCARDCONTEXT hContext;
SCARDHANDLE hCard;
@@ -130,6 +129,14 @@ namespace hw {
bool connect(void) override;
bool disconnect() override;
+
+ /* ======================================================================= */
+ /* LOCKER */
+ /* ======================================================================= */
+ void lock(void) override;
+ void unlock(void) override;
+ bool try_lock(void) override;
+
/* ======================================================================= */
/* WALLET & ADDRESS */
/* ======================================================================= */