diff options
author | Jeremy Allison <jra@samba.org> | 2009-04-14 15:19:39 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2009-04-14 15:19:39 -0700 |
commit | 8e06e945b6b03db825862f2f057f0dfe13ade3a2 (patch) | |
tree | d95c239803eec9626c9da3b16f5bc0c71672b523 /lib/util/smb_threads.c | |
parent | 4721be488ceb8229d564e4b63ca9937603394e51 (diff) | |
download | samba-8e06e945b6b03db825862f2f057f0dfe13ade3a2.tar.gz |
Ensure a tls key is only generated once - wrap create & destroy in a mutex.
Change the function names to add _once to the tls_create & tls_destroy to
make this obvious.
Jeremy.
Diffstat (limited to 'lib/util/smb_threads.c')
-rw-r--r-- | lib/util/smb_threads.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/util/smb_threads.c b/lib/util/smb_threads.c index 8e0e1cd915..fa2d8da186 100644 --- a/lib/util/smb_threads.c +++ b/lib/util/smb_threads.c @@ -25,8 +25,6 @@ #include "includes.h" -#define NUM_GLOBAL_LOCKS 1 - /********************************************************* Functions to vector the locking primitives used internally by libsmbclient. @@ -94,14 +92,18 @@ int smb_thread_set_functions(const struct smb_thread_functions *tf) SMB_THREADS_DEF_PTHREAD_IMPLEMENTATION(tf); +void *pkey = NULL; + /* Test function. */ int test_threads(void) { int ret; void *plock = NULL; - smb_thread_set_functions(&tf); + if ((ret = SMB_THREAD_CREATE_TLS_ONCE("test_tls", pkey)) != 0) { + printf("Create tls once error: %d\n", ret); + } if ((ret = SMB_THREAD_CREATE_MUTEX("test", plock)) != 0) { printf("Create lock error: %d\n", ret); } @@ -112,6 +114,7 @@ int test_threads(void) printf("unlock error: %d\n", ret); } SMB_THREAD_DESTROY_MUTEX(plock); + SMB_THREAD_DESTROY_TLS_ONCE(pkey); return 0; } |