Threading libsmbclient - a proposal.

simo idra at samba.org
Wed Apr 8 00:56:04 GMT 2009


On Tue, 2009-04-07 at 17:44 -0700, Jeremy Allison wrote:
> On Wed, Apr 08, 2009 at 12:41:23AM +0000, simo wrote:
> > 
> > No, you have barriers in the include:
> > #ifndef _smb_threads_h_
> > #define _smb_threads_h_
> > 
> > So multiple inclusion shouldn't really happen.
> 
> Multiple includes in the same module can't happen,
> but inclusion in *different* modules can.
> 
> > I am trying to understand in which case this would make a difference.
> 
> Imagine we have module a.c which #define SMB_USE_THREADS
> and includes smb_threads.h, and then module b.c which
> also (by accident in an include header) also defines
> SMB_USE_THREADS and includes smb_threads.h. In your
> methed we get duplicate definitions of the sample
> functions.

Right, I thought about that just *after* I clicked send ...

> With the instantiation macro method you can
> include "smb_threads.h" as many times as you
> like but the implementation only gets defined
> in the module where you have :
> 
> SMB_THREADS_DEF_PTHREAD_IMPLEMENTATION(var);
> 
> That's defined in a .c file, not in or before 
> a header, so it's much easier for a user of 
> the library to control and remember.

Right, but thinking about that I am wondering if you shouldn't mark all
functions as static ?

Simo.

-- 
Simo Sorce
Samba Team GPL Compliance Officer <simo at samba.org>
Principal Software Engineer at Red Hat, Inc. <simo at redhat.com>



More information about the samba-technical mailing list