Remove talloc from libwbclient

simo idra at
Sun Feb 7 07:44:50 MST 2010

On Sun, 2010-02-07 at 12:48 +0100, Volker Lendecke wrote:
> On Sat, Feb 06, 2010 at 07:40:47PM -0500, simo wrote:
> > > The problem is that you can't use talloc in a thread-safe
> > > way from within a library where you don't control access to
> > > the NULL context at all.
> > > 
> > > A different way to do this would be to have a thread-safe
> > > version of talloc_init() that we could use as a shared
> > > talloc parent in libwbclient, where we could control and
> > > mutex the access to it.
> > 
> > Yes this could very possibly be useful not just for libwbclient, but for
> > any user that wants to use talloc and also needs to use threads.
> > I think it's really worth considering.
> Just brainstorming here without much experience in
> thread-programming, so excuse me if I'm talking rubbish:
> Looking at the existing users of talloc_init() and
> talloc_xx(NULL) I would say that almost all should replaced
> by something like talloc_tos() (which itself needs to use
> thread-local storage eventually) or talloc_new(), they are
> just temporary contexts. The valid uses of a NULL context
> are rare enough that it might be possible to mutex that
> properly without noticable performance impact.

Another possibility is to add an explicit thread safe call.
Something like talloc_ts_new(), and make sure it is used where

> Libwbclient could then go and continue using talloc as it
> does right now.
> Any flaws in this approach?

I guess the only problem with making every NULL allocation a thread safe
one is to understand how many of them there are and how many would need
to be changed. But otherwise it looks a perfectly valid approach to me.


Simo Sorce
Samba Team GPL Compliance Officer <simo at>
Principal Software Engineer at Red Hat, Inc. <simo at>

More information about the samba-technical mailing list