pthreadpool: Fix fork behaviour
commit7b1c746fe2c7e954f422a759ed9c392348a74327
authorVolker Lendecke <vl@samba.org>
Mon, 28 Aug 2017 14:38:19 +0000 (28 16:38 +0200)
committerKarolin Seeger <kseeger@samba.org>
Sun, 10 Sep 2017 13:35:13 +0000 (10 15:35 +0200)
tree889e37fa647dacc8278104b53c581d9e72b2bdc1
parenta379231ffb1ba5bf5ef5b041c9aa30f5251ad462
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>
(cherry picked from commit ff98e3fb666b57b56a1427aa1196948ceebdec66)
source3/lib/pthreadpool/pthreadpool.c