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

Jeremy Allison jra at samba.org
Mon Sep 14 19:16:07 UTC 2015


On Mon, Sep 14, 2015 at 12:09:30PM -0700, Jeremy Allison wrote:
> On Mon, Sep 14, 2015 at 07:26:56PM +0200, Ralph Böhme wrote:
> > 
> > yes on both, feel free to squash and add my signed-off and
> > reviewed-by.
> 
> Unfortunately - remember:
> 
> http://bholley.net/blog/2015/must-be-this-tall-to-write-multi-threaded-code.html
> 
> :-).
> 
> The optimization change you added:
> 
> Reverse order of unlocking and notifying in
> tevent_thread_proxy_schedule(): unlocking before notifying avoids a
> potential wakeup of the signalled thread with the mutex still locked.
> 
> introduces valgrind --tool=drd and --tool =helgrind errors
> that are not there with the original code path.
> 
> It's OK to wake up the signalled thread with the mutex still locked,
> it'll just wait on the mutex until it gets unlocked. No big deal :-).
> 
> The reason the mutex must be held until after the signaling
> is done is that in the second test code there may be a destructor
> waiting to remove the proxy object once the mutex gets released,
> and if that happens you get conflicting write errors.
> 
> Another proof of the old adage premature optimization is
> the root of all evil :-).
> 
> Everything else was OK though - squashed into the patch !
> 
> Updated patchset with your signed-off-by's attached.

Gah, posted the wrong patchset. Delete that email.
Corrected patchset to follow shortly once I've
confirmed all tests...



More information about the samba-technical mailing list