aboutsummaryrefslogtreecommitdiff
path: root/contrib/otshell_utils/utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/otshell_utils/utils.cpp')
-rw-r--r--contrib/otshell_utils/utils.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/contrib/otshell_utils/utils.cpp b/contrib/otshell_utils/utils.cpp
index 1d26075c4..043260807 100644
--- a/contrib/otshell_utils/utils.cpp
+++ b/contrib/otshell_utils/utils.cpp
@@ -112,7 +112,22 @@ std::string get_current_time() {
cNullstream g_nullstream; // extern a stream that does nothing (eats/discards data)
-std::mutex gLoggerGuard; // extern
+std::recursive_mutex gLoggerGuard; // extern
+std::atomic<int> gLoggerGuardDepth; // extern
+
+std::atomic<int> & gLoggerGuardDepth_Get() {
+ // TODO std::once would be nicer here
+
+ static bool once=0;
+
+ if (!once) { // initialize it once
+ once=1;
+ gLoggerGuardDepth=0;
+ }
+
+ return gLoggerGuardDepth; // global, atomic counter
+}
+
// ====================================================================