mirror of
https://github.com/monero-project/monero.git
synced 2025-06-28 14:07:11 -04:00
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
This commit is contained in:
parent
641dfc991f
commit
100b7bc10d
5 changed files with 202 additions and 385 deletions
|
@ -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 */
|
||||
/* ======================================================================= */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue