diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2017-01-31 18:07:55 +0100 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2017-03-11 15:41:40 +0100 |
commit | aa668f74e95617fd0544327a2b57bf654a6f9a2d (patch) | |
tree | 1dd7e6b16cf6d88f3a64757fc4f9289e4b41a359 /NitrokeyManager.cc | |
parent | 48ec48d2c680b9f40d2b038fda9555bfd024bb97 (diff) | |
download | libnitrokey-aa668f74e95617fd0544327a2b57bf654a6f9a2d.tar.gz libnitrokey-aa668f74e95617fd0544327a2b57bf654a6f9a2d.tar.bz2 |
Be tread-safe on initializing instance
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'NitrokeyManager.cc')
-rw-r--r-- | NitrokeyManager.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc index dc58e4d..ee7ca92 100644 --- a/NitrokeyManager.cc +++ b/NitrokeyManager.cc @@ -88,7 +88,8 @@ namespace nitrokey{ } shared_ptr<NitrokeyManager> NitrokeyManager::instance() { - //FIXME check thread safety - add atomic for instance, add lock guard + static std::mutex mutex; + std::lock_guard<std::mutex> lock(mutex); if (_instance == nullptr){ _instance = make_shared<NitrokeyManager>(); } |