[PATCH] tevent and threads - infrastructure improvements - version #2

Jeremy Allison jra at samba.org
Tue Sep 15 19:01:53 UTC 2015


On Tue, Sep 15, 2015 at 02:27:12PM -0400, Ira Cooper wrote:
> Jeremy Allison <jra at samba.org> writes:
> 
> > On Tue, Sep 15, 2015 at 09:46:30AM -0700, Jeremy Allison wrote:
> >> 
> >> Yes, that's a good idea. I'll update the docs to add this and
> >> post a new patchset so we have something complete to discuss
> >> next week at SDC.
> >
> > New patchset with expanded comments and expanded docs explaining
> > the issue.
> >
> > From 735e9534ad1da712a9460ad97837d0252c044920 Mon Sep 17 00:00:00 2001
> > From: Jeremy Allison <jra at samba.org>
> > Date: Wed, 22 Jul 2015 11:52:06 -0700
> > Subject: [PATCH 4/4] lib: tevent: docs: Add tutorial on thread usage.
> >
> > Signed-off-by: Jeremy Allison <jra at samba.org>
> > Signed-off-by: Ralph Boehme <slow at samba.org>
> > ---
> >  lib/tevent/doc/tevent_thread.dox   | 322 +++++++++++++++++++++++++++++++++++++
> >  lib/tevent/doc/tevent_tutorial.dox |   2 +
> >  2 files changed, 324 insertions(+)
> >  create mode 100644 lib/tevent/doc/tevent_thread.dox
> >
> > diff --git a/lib/tevent/doc/tevent_thread.dox b/lib/tevent/doc/tevent_thread.dox
> > new file mode 100644
> > index 0000000..8bf181c
> > --- /dev/null
> > +++ b/lib/tevent/doc/tevent_thread.dox
> > @@ -0,0 +1,322 @@
> > +/**
> > + at page tevent_context Chapter 6: Tevent with threads
> > +
> > + at section context Tevent with threads
> > +
> > +In order to use tevent with threads, you must first understand
> > +how to use the talloc library in threaded programs. For more
> > +information about working with talloc, please visit <a
> > +href="http://talloc.samba.org/">talloc website</a> where tutorial and
> > +documentation are located.
> > +
> > +If a tevent context structure is talloced from a NULL, thread-safe talloc
> > +context, then it can be safe to use in a threaded program. The function
> > +<code>talloc_disable_null_tracking()</code> <b>must</b> be called from the initial
> > +program thread before any talloc calls are made to ensure talloc is
> > thread-safe.
> 
> I don't understand the first sentence of the paragraph above.

Do you mean this:

"If a tevent context structure is talloced from a NULL, thread-safe talloc
context, then it can be safe to use in a threaded program."

?

If so, it just means that you have to have called:

talloc_disable_null_tracking();

and when you create the tevent context via:

tevent_context_init() the passed in talloc context must be NULL
(or you have appropriate thread-safe locking around any access
to the talloc heirarcy).



More information about the samba-technical mailing list