From: William Lallemand Date: Thu, 6 Dec 2018 13:05:20 +0000 (+0100) Subject: BUG/MEDIUM: mworker: stop every tasks in the master X-Git-Tag: v1.9-dev10~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27f3fa5;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: mworker: stop every tasks in the master The master is not supposed to run (at the moment) any task before the polling loop, the created tasks should be run only in the workers but in the master they should be disabled or removed. No backport needed. --- diff --git a/include/proto/task.h b/include/proto/task.h index 111a0cfef1..a1aa0ffb80 100644 --- a/include/proto/task.h +++ b/include/proto/task.h @@ -553,6 +553,11 @@ void process_runnable_tasks(); */ int wake_expired_tasks(); +/* + * Delete every tasks before running the master polling loop + */ +void mworker_cleantasks(); + #endif /* _PROTO_TASK_H */ /* diff --git a/src/haproxy.c b/src/haproxy.c index f8fba140fd..6c96794e23 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -895,6 +895,7 @@ static void mworker_loop() mworker_unblock_signals(); mworker_cleanlisteners(); + mworker_cleantasks(); mworker_catch_sigchld(NULL); /* ensure we clean the children in case some SIGCHLD were lost */ diff --git a/src/task.c b/src/task.c index 1f09f131c9..b9b8bd2b30 100644 --- a/src/task.c +++ b/src/task.c @@ -469,6 +469,54 @@ void process_runnable_tasks() } } +/* + * Delete every tasks before running the master polling loop + */ +void mworker_cleantasks() +{ + struct task *t; + int i; + struct eb32_node *next_wq = NULL; + struct eb32sc_node *next_rq = NULL; + +#ifdef USE_THREAD + /* cleanup the global run queue */ + next_rq = eb32sc_first(&rqueue, MAX_THREADS); + while (next_rq) { + t = eb32sc_entry(next_rq, struct task, rq); + next_rq = eb32sc_next(rq_next, MAX_THREADS_MASK); + task_delete(t); + task_free(t); + } + /* cleanup the timers queue */ + next_wq = eb32_first(&timers); + while (next_wq) { + t = eb32_entry(next_wq, struct task, wq); + next_wq = eb32_next(next_wq); + task_delete(t); + task_free(t); + } +#endif + /* clean the per thread run queue */ + for (i = 0; i < global.nbthread; i++) { + next_rq = eb32sc_first(&task_per_thread[i].rqueue, MAX_THREADS_MASK); + while (next_rq) { + t = eb32sc_entry(next_rq, struct task, rq); + next_rq = eb32sc_next(next_rq, MAX_THREADS_MASK); + task_delete(t); + task_free(t); + } + /* cleanup the per thread timers queue */ + next_wq = eb32_first(&task_per_thread[i].timers); + while (next_wq) { + t = eb32_entry(next_wq, struct task, wq); + next_wq = eb32_next(next_wq); + task_delete(t); + task_free(t); + } + } +} + /* perform minimal intializations */ static void init_task() {