summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/util/smb_threads.h5
-rw-r--r--lib/util/talloc_stack.c4
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/util/smb_threads.h b/lib/util/smb_threads.h
index f4ed1fcb9aa..682e142c5bc 100644
--- a/lib/util/smb_threads.h
+++ b/lib/util/smb_threads.h
@@ -33,8 +33,11 @@
#if defined(HAVE_PTHREAD_H)
#define SMB_THREAD_ONCE_INIT PTHREAD_ONCE_INIT
+#define SMB_THREAD_ONCE_IS_INITIALIZED(val) (true)
+#define SMB_THREAD_ONCE_INITIALIZE(val)
#else
-#define SMB_THREAD_ONCE_INIT false
+#define SMB_THREAD_ONCE_IS_INITIALIZED(val) ((val) == true)
+#define SMB_THREAD_ONCE_INITIALIZE(val) ((val) = true)
#endif
enum smb_thread_lock_type {
diff --git a/lib/util/talloc_stack.c b/lib/util/talloc_stack.c
index f5ca9d21d54..2ed18fa1139 100644
--- a/lib/util/talloc_stack.c
+++ b/lib/util/talloc_stack.c
@@ -62,10 +62,10 @@ static void talloc_stackframe_init(void)
{
if (!global_tfp) {
/* Non-thread safe init case. */
- if (ts_initialized) {
+ if (SMB_THREAD_ONCE_IS_INITIALIZED(ts_initialized)) {
return;
}
- ts_initialized = true;
+ SMB_THREAD_ONCE_INITIALIZE(ts_initialized);
}
if (SMB_THREAD_CREATE_TLS("talloc_stackframe", global_ts)) {