[PATCH] tevent and threads - infrastructure improvements.

Jeremy Allison jra at samba.org
Thu Jul 23 16:08:24 UTC 2015


On Wed, Jul 22, 2015 at 08:08:39PM -0400, Jeff Layton wrote:
> 
> That was a nice feature of libev, but in the end Jeremy was quite right
> to point out that that function just writes to a pipe to trigger the
> event (very similar to the equivalent code that we ended up with before
> we switched to libev). The ev_async_* stuff is really just syntactic
> sugar, but it does neatly hide the pipe handlers.
> 
> For the record, the _main_ reason we ended up dropping tevent was
> actually problems in using talloc. tevent relies heavily on talloc and
> we hit a number of problems when trying to tear down talloc objects in
> threaded code.
> 
> I strongly considered keeping tevent and just trying hard(er) to ensure
> that we didn't end up mucking with any talloc contexts from multiple
> threads, but it was pretty difficult to ensure that, given the way that
> talloc destructors get called and the way that we needed to do
> allocations.
> 
> So, while I think adding this to tevent is a very good idea, it
> probably wouldn't have been sufficient for us to keep it. A threadsafe
> talloc would probably have helped considerably however.

The concept of "ownership" is really important to talloc,
but as it's mostly used in single-threaded code people
tend to ignore it.

If you treat passing ownership of talloc'ed objects between
threads with the same care you have to take for locking
data races then existing talloc is managable in MT-safe
code I think.

Problem is talloc *looks* easier than that, but it isn't
really :-).



More information about the samba-technical mailing list