pthreadpool: Fix fork behaviour
authorVolker Lendecke <vl@samba.org>
Mon, 28 Aug 2017 14:38:19 +0000 (16:38 +0200)
committerVolker Lendecke <vl@samba.org>
Thu, 31 Aug 2017 15:44:22 +0000 (17:44 +0200)
commitff98e3fb666b57b56a1427aa1196948ceebdec66
tree234cda476ebdb96d565d28c12f24978c34caab99
parentcc639765ffa4c91e7bc03e7ba85747d48ea7b725
pthreadpool: Fix fork behaviour

glibc's pthread_cond_wait(&c, &m) increments m.__data.__nusers, making
pthread_mutex_destroy return EBUSY. Thus we can't allow any thread waiting for
a job across a fork. Also, the state of the condvar itself is unclear across a
fork. Right now to me it looks like an initialized but unused condvar can be
used in the child. Busy worker threads don't cause any trouble here, they don't
hold mutexes or condvars. Also, they can't reach the condvar because _prepare
holds all mutexes.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13006
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/pthreadpool/pthreadpool.c