[PATCH] talloc with threads tutorial and tests

Simo simo at samba.org
Mon Mar 16 15:04:33 MDT 2015


On Mon, 2015-03-16 at 12:49 -0700, Jeremy Allison wrote:
> On Mon, Mar 16, 2015 at 12:46:58PM -0700, Jeremy Allison wrote:
> > On Mon, Mar 16, 2015 at 03:36:11PM -0400, Simo wrote:
> > > On Mon, 2015-03-16 at 12:28 -0700, Jeremy Allison wrote:
> > > > So one of the things that came up at the Vault
> > > > conference in conversations with Jeff was the
> > > > real lack of a guide on how to use talloc in
> > > > pthreaded code.
> > > > 
> > > > Here is an attempt to fix that, plus a test
> > > > case added to smbtorture local.talloc to ensure
> > > > talloc works correctly in a threaded environment.
> > > > 
> > > > Please review and comment/push !
> > > > 
> > > > Thanks,
> > > > 
> > > > 	Jeremy.
> > > 
> > > +10!
> > > 
> > > Very nice to see this.
> > > 
> > > Aside:
> > > Jeremy would you like a method of passing a context that avoids shared
> > > variables and mutexes and uses instead a pipe for synchronization ?
> > > I think it's be neat and simpler to use, perhaps even more performant as
> > > you do not get many threads contending on a single variable, but with
> > > the downside of requiring a pipe between main thread and each sub
> > > thread.
> > 
> > Maybe as a second example. I really want to keep a simple,
> > threads-only solution as the first example so people don't
> > have to think about all the issues you get with pipes
> > (sync/async send, signal handling, partial writes etc.
> > etc. etc.).
> > 
> > I'm sure it would perform better, but this is about
> > correctness initially, not performance.
> 
> Also, I'm eventually planning to tie this in with
> a tevent+threads tutorial, showing how to have each
> thread run a seprate event loop, and then synchronise
> talloced memory passing between them when they need
> to communicate. That's a perfect place to use the
> sync-pipe example as it ties into the thread-local
> tevent code.

Excellent, and you get a reviewed-by too.

Simo.

-- 
Simo Sorce



More information about the samba-technical mailing list