]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: tasks: Make sure we correctly init and deinit a tasklet.
authorOlivier Houchard <ohouchard@haproxy.com>
Fri, 8 Jun 2018 15:08:19 +0000 (17:08 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 14 Jun 2018 16:57:13 +0000 (18:57 +0200)
Up until now, a tasklet couldn't be free'd while it was in the list, it is
no longer the case, so make sure we remove it from the list before freeing it.
To do so, we have to make sure we correctly initialize it, so use LIST_INIT,
instead of setting the pointers to NULL.

include/proto/task.h

index 2662460989915b3ce19b84448d111a878c36cc34..dd08392d9eee8ae5eb75ecc4654e1ec67b42b471 100644 (file)
@@ -231,6 +231,7 @@ static inline void task_insert_into_tasklet_list(struct task *t)
 static inline void task_remove_from_task_list(struct task *t)
 {
        LIST_DEL(&((struct tasklet *)t)->list);
+       LIST_INIT(&((struct tasklet *)t)->list);
        task_list_size[tid]--;
        HA_ATOMIC_SUB(&tasks_run_queue, 1);
        if (!TASK_IS_TASKLET(t)) {
@@ -272,7 +273,7 @@ static inline void tasklet_init(struct tasklet *t)
        t->nice = -32768;
        t->calls = 0;
        t->state = 0;
-       t->list.p = t->list.n = NULL;
+       LIST_INIT(&t->list);
 }
 
 static inline struct tasklet *tasklet_new(void)
@@ -323,9 +324,10 @@ static inline void task_free(struct task *t)
                t->process = NULL;
 }
 
-
 static inline void tasklet_free(struct tasklet *tl)
 {
+       LIST_DEL(&tl->list);
+
        pool_free(pool_head_tasklet, tl);
        if (unlikely(stopping))
                pool_flush(pool_head_tasklet);