From: Willy Tarreau Date: Mon, 24 Jul 2017 15:52:58 +0000 (+0200) Subject: MINOR: task: always preinitialize the task's timeout in task_init() X-Git-Tag: v1.8-dev3~213 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f42199975c8ab0442935ecb8f3db608c051675b5;p=thirdparty%2Fhaproxy.git MINOR: task: always preinitialize the task's timeout in task_init() task_init() is called exclusively by task_new() which is the only way to create a task. Most callers set t->expire to TICK_ETERNITY, some set it to another value and a few like Lua don't set it at all as they don't need a timeout, causing random values to be used in case the task gets queued. Let's always set t->expire to TICK_ETERNITY in task_init() so that all tasks are now initialized in a clean state. This patch can be backported as it will definitely make the code more robust (at least the Lua code, possibly other places). --- diff --git a/include/proto/task.h b/include/proto/task.h index e510cd9ec0..82e6f5322b 100644 --- a/include/proto/task.h +++ b/include/proto/task.h @@ -184,6 +184,7 @@ static inline struct task *task_init(struct task *t) t->pending_state = t->state = TASK_SLEEPING; t->nice = 0; t->calls = 0; + t->expire = TICK_ETERNITY; return t; }