summaryrefslogtreecommitdiffstats
path: root/source3/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2014-03-03 12:20:41 +0100
committerMichael Adam <obnox@samba.org>2014-03-03 14:29:24 +0100
commitccc187ff5e6cbc411476c5f5e68cc6bb1fe35818 (patch)
tree6dfaf1e3ce9c0a3d44bd4eed9640dbb8fb4bef1f /source3/lib
parent925625b52886d40b50fc631bad8bdc81970f7598 (diff)
downloadsamba-ccc187ff5e6cbc411476c5f5e68cc6bb1fe35818.tar.gz
samba-ccc187ff5e6cbc411476c5f5e68cc6bb1fe35818.tar.xz
samba-ccc187ff5e6cbc411476c5f5e68cc6bb1fe35818.zip
pthreadpool: Fix pthreadpools with fork
The current could would crash if a pthreadpool was created, deleted and the process then fork()s. "pthreadpools" is NULL in this case, but the pthread_atfork handlers are in place. This fixes walking the pthreadpools list in reverse. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Kamen Mazdrashki <kamenim@samba.org> Reviewed-by: Simo Sorce <simo@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/pthreadpool/pthreadpool.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/source3/lib/pthreadpool/pthreadpool.c b/source3/lib/pthreadpool/pthreadpool.c
index bd58d62f8fa..654d420732f 100644
--- a/source3/lib/pthreadpool/pthreadpool.c
+++ b/source3/lib/pthreadpool/pthreadpool.c
@@ -188,16 +188,11 @@ static void pthreadpool_parent(void)
int ret;
struct pthreadpool *pool;
- pool = DLIST_TAIL(pthreadpools);
-
- while (1) {
+ for (pool = DLIST_TAIL(pthreadpools);
+ pool != NULL;
+ pool = DLIST_PREV(pool)) {
ret = pthread_mutex_unlock(&pool->mutex);
assert(ret == 0);
-
- if (pool == pthreadpools) {
- break;
- }
- pool = pool->prev;
}
ret = pthread_mutex_unlock(&pthreadpools_mutex);
@@ -209,9 +204,10 @@ static void pthreadpool_child(void)
int ret;
struct pthreadpool *pool;
- pool = DLIST_TAIL(pthreadpools);
+ for (pool = DLIST_TAIL(pthreadpools);
+ pool != NULL;
+ pool = DLIST_PREV(pool)) {
- while (1) {
close(pool->sig_pipe[0]);
close(pool->sig_pipe[1]);
@@ -236,11 +232,6 @@ static void pthreadpool_child(void)
ret = pthread_mutex_unlock(&pool->mutex);
assert(ret == 0);
-
- if (pool == pthreadpools) {
- break;
- }
- pool = pool->prev;
}
ret = pthread_mutex_unlock(&pthreadpools_mutex);