summaryrefslogtreecommitdiff
path: root/lib/util/smb_threads.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2009-04-14 12:23:22 -0700
committerJeremy Allison <jra@samba.org>2009-04-14 12:23:22 -0700
commit27a3118bcf6105848e8200c15ebab910831f73c6 (patch)
treeba082a0cfd2f6e7f664bd016ba3fe14d12fda676 /lib/util/smb_threads.c
parent48f14949b1b9a377c2af489032de02a0fe4d118b (diff)
downloadsamba-27a3118bcf6105848e8200c15ebab910831f73c6.tar.gz
samba-27a3118bcf6105848e8200c15ebab910831f73c6.tar.bz2
samba-27a3118bcf6105848e8200c15ebab910831f73c6.zip
Make talloc_stack threadsafe using TLS. Volker please
check. Passes make test and basic valgrind testing. Jeremy.
Diffstat (limited to 'lib/util/smb_threads.c')
-rw-r--r--lib/util/smb_threads.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/util/smb_threads.c b/lib/util/smb_threads.c
index 84dec4d874..8e0e1cd915 100644
--- a/lib/util/smb_threads.c
+++ b/lib/util/smb_threads.c
@@ -50,8 +50,19 @@ int smb_thread_set_functions(const struct smb_thread_functions *tf)
global_tfp = tf;
+#if defined(PARANOID_MALLOC_CHECKER)
+#ifdef malloc
+#undef malloc
+#endif
+#endif
+
/* Here we initialize any static locks we're using. */
- global_lock_array = (void **)SMB_MALLOC_ARRAY(void *, NUM_GLOBAL_LOCKS);
+ global_lock_array = (void **)malloc(sizeof(void *) *NUM_GLOBAL_LOCKS);
+
+#if defined(PARANOID_MALLOC_CHECKER)
+#define malloc(s) __ERROR_DONT_USE_MALLOC_DIRECTLY
+#endif
+
if (global_lock_array == NULL) {
return ENOMEM;
}
@@ -62,9 +73,11 @@ int smb_thread_set_functions(const struct smb_thread_functions *tf)
SAFE_FREE(global_lock_array);
return ENOMEM;
}
- global_tfp->create_mutex(name,
+ if (global_tfp->create_mutex(name,
&global_lock_array[i],
- __location__);
+ __location__)) {
+ smb_panic("smb_thread_set_functions: create mutexes failed");
+ }
SAFE_FREE(name);
}