Threading libsmbclient - a proposal.

Jeremy Allison jra at
Tue Apr 7 22:53:05 GMT 2009

On Sat, Apr 04, 2009 at 05:33:15PM -0700, Jeremy Allison wrote:
> I'm thinking of something like :
> SMB_PTHREAD_DEFINE_FNS(log_fn, var);
> Which expands into definitions of all the functions
> (using pthreads) we need to pass in to initialize,
> and a definition and declaration of the struct to
> pass (the logging function is optional and can be
> NULL if not needed). var becomes the name of the
> declared struct containing the vectors.
> The main() function would then call
> to actually cause the library to initialize the
> thread functions, mutexes and TLS.
> There's also functions for TLS we have to add, but I'll
> look at that next week.

Ok, after talking with tridge here is the template
I'll be using to start adding threads to the lower
level code.

There are a couple of files - smb_threads.h
smb_threads_internal.h which sets up the definitions
of the pthread implemenations of these functions as
a macro, and the struct containing the function vectors,
and smb_threads.c which initializes the function
vectors and right now contains a sample of the
the way we'd use these functions.

I didn't add the logging function, as that
really should be left inside the implementations
I think.

So the locking primitives we'll be using in the code

SMB_THREAD_LOCK(plock, type)

To lock a mutex use : SMB_THREAD_LOCK(plock, SMB_THREAD_LOCK)
and to unlock the mutex use : SMB_THREAD_LOCK(plock, SMB_THREAD_UNLOCK)

For thread local storage we'll use :


Let me know what you think ! If eveyone is ok I'll
start adding this into the master branch.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smb_threads.h
Type: text/x-chdr
Size: 3731 bytes
Desc: not available
Url :
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smb_threads_internal.h
Type: text/x-chdr
Size: 1637 bytes
Desc: not available
Url :
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smb_threads.c
Type: text/x-csrc
Size: 2741 bytes
Desc: not available
Url :

More information about the samba-technical mailing list