pthreadpool: Fix fork behaviour
commitefcd9eed9882a98e9ecd80ba773138f705d228f6
authorVolker Lendecke <vl@samba.org>
Mon, 28 Aug 2017 14:38:19 +0000 (28 16:38 +0200)
committerKarolin Seeger <kseeger@samba.org>
Fri, 8 Sep 2017 19:21:16 +0000 (8 21:21 +0200)
tree2c2ea17ceb57885c57038518b53ddd65fa5e0b85
parent4cc6517a170f075a14375d64c56d7690c93a1e29
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)
lib/pthreadpool/pthreadpool.c