File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change 55
55
56
56
namespace modsecurity {
57
57
58
+ std::once_flag UniqueId::onceFlag;
59
+
58
60
void UniqueId::fillUniqueId () {
59
61
std::string macAddress;
60
62
std::string name;
Original file line number Diff line number Diff line change 15
15
16
16
#ifdef __cplusplus
17
17
#include < string>
18
+ #include < mutex>
18
19
#endif
19
20
20
21
#ifndef SRC_UNIQUE_ID_H_
@@ -37,9 +38,9 @@ class UniqueId {
37
38
}
38
39
39
40
static std::string uniqueId () {
40
- if (UniqueId::getInstance (). uniqueId_str . empty () ) {
41
+ std::call_once (UniqueId::onceFlag,[]( ) {
41
42
UniqueId::getInstance ().fillUniqueId ();
42
- }
43
+ });
43
44
44
45
return UniqueId::getInstance ().uniqueId_str ;
45
46
}
@@ -59,6 +60,8 @@ class UniqueId {
59
60
// C++ 11
60
61
// UniqueId(UniqueId const&) = delete;
61
62
// void operator=(UniqueId const&) = delete;
63
+
64
+ static std::once_flag onceFlag;
62
65
};
63
66
64
67
} // namespace modsecurity
You can’t perform that action at this time.
0 commit comments