]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mworker: stop every tasks in the master
authorWilliam Lallemand <wlallemand@haproxy.com>
Thu, 6 Dec 2018 13:05:20 +0000 (14:05 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 6 Dec 2018 13:12:58 +0000 (14:12 +0100)
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.

include/proto/task.h
src/haproxy.c
src/task.c

index 111a0cfef1336fc374be34402d19e9e8b80d4b02..a1aa0ffb804341683e074f5383854c1714151469 100644 (file)
@@ -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 */
 
 /*
index f8fba140fdb0986cbbb5659b7455ff1b56aee06d..6c96794e23c3b9600b5dc8bd810fc517e39df6f7 100644 (file)
@@ -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 */
index 1f09f131c994d1ad0380ede9152424e29cff2c41..b9b8bd2b30c05eb60a58b140375b540de4d16c02 100644 (file)
@@ -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()
 {