summaryrefslogtreecommitdiff
path: root/lib/util/smb_threads_internal.h
AgeCommit message (Collapse)AuthorFilesLines
2009-05-13Make the thread functions a bit easier to useDerrell Lipman1-3/+9
- Create separate macros for lock and unlock so that it's easier to identify which request is being made. - Initialize *ponce in the SMB_THREAD_ONCE macro in the non-thread-safe case, rather than requiring each init function to determine if it's in the non-thread-safe case and manually initialize. Derrell
2009-05-13Allow a parameter to smb_thread_once's initialization functionDerrell Lipman1-6/+6
- This should make life easier for ourselves. We're no longer constrained to the semantics of pthread_once, so let's allow passing a parameter to the initialization function. Some of Samba's init functions return a value. Although I haven't searched, I suspect that some of the init functions require in input parameters. The parameter added here can be used for input, output, or both, as necessary... or ignored, as is now done in talloc_stackframe_init(). Derrell
2009-05-10Optimize smb_thread_once usage by not calling it if known already calledDerrell Lipman1-2/+6
- The macro SMB_THREAD_ONCE now tests whether the "once" variable is already set, and if so avoids calling smb_thread_once(). Derrell
2009-05-10Replace external thread "once" with an internal implementationDerrell Lipman1-1/+1
Jeremy, please check... - I'm in the process of providing an interface in libsmbclient to the recently-added threading capabilities. In the process, I discovered that different thread implementations have varying types for the variable passed to the thread_impl_once() function. pthreads, for example, uses type pthread_once_t. Since Samba needs to internally declare these variables, it would need to know the exact type required by each thread implementation's function. After considering multiple methods of obtaining an appropriately sized variable, I decided that for the basic "once" functionality required by Samba, it would be much simpler to just implement our own "once" functionality. We don't require cancellation points et all. This commit adds an smb_thread_once() function that is implemented using an internal mutex. The mutex itself uses the implementation's create_mutex function. This eliminates the need for the user to provide a smb_thread_once function pointer and the entire issue of that function's first parameter. Derrell
2009-04-20Fix the pthread_once initialization issue. Make talloc_stackframe useJeremy Allison1-4/+7
this. Jeremy.
2009-04-14Ensure a tls key is only generated once - wrap create & destroy in a mutex.Jeremy Allison1-4/+12
Change the function names to add _once to the tls_create & tls_destroy to make this obvious. Jeremy.
2009-04-14Make talloc_stack threadsafe using TLS. Volker pleaseJeremy Allison1-2/+3
check. Passes make test and basic valgrind testing. Jeremy.
2009-04-08Add the thread functions to top level lib/util.Jeremy Allison1-0/+52
Not yet used, that's the next step. Jeremy.