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

Jeremy Allison jra at samba.org
Mon Jul 27 16:32:00 UTC 2015


On Mon, Jul 27, 2015 at 08:54:24AM -0700, Jeremy Allison wrote:
> On Mon, Jul 27, 2015 at 05:02:43AM -0400, Simo Sorce wrote:
> 
> > if we are unlucky it may cause flailing test failures on
> > some architectures. Also if I read it right 'finished' is on the stack
> > and you have a timeout that can make the thread terminate before the
> > master writes to it, this could cause the test to write on freed/reused
> > stack or segfault or similar causing also undebuggable testing failures.
> 
> See above - master never writes to it, only child
> thread (who owns it for the lifetime) does.

Just to be completely clear, master thread neither
reads nor writes to 'finished', only child thread
which owns it completely.

All the master thread does is schedules thread_callback()
to be run in child thread from within child thread
event loop. That's why I really like this pattern,
it makes it easy to avoid having to lock stuff
as it doesn't facilitate sharing data across threads.



More information about the samba-technical mailing list