From 086735a6888d1985c00c958fc34962630e1f8d01 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 5 Nov 2018 15:09:47 +0100 Subject: [PATCH] BUG/MINOR: tasks: make sure wakeup events are properly reported to subscribers The tasks API was changed in 1.9-dev1 with commit 9f6af3322 ("MINOR: tasks: Change the task API so that the callback takes 3 arguments."), causing the task's state not to be usable anymore and to have been replaced with an explicit argument in the callee. The task's state doesn't contain any trace of the wakeup cause anymore. But there were two places where the old task's state remained in use : - sessions, used to more accurately report timeouts in logs when seeing TASK_WOKEN_TIMEOUT ; - peers, used to finish resynchronization when seeing TASK_WOKEN_SIGNAL This commit fixes both occurrences by making sure we don't access task->state directly (should we rename it by the way ?). No backport is needed. --- src/peers.c | 2 +- src/session.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/peers.c b/src/peers.c index 64d5e085d..a99d8e166 100644 --- a/src/peers.c +++ b/src/peers.c @@ -2118,7 +2118,7 @@ static struct task *process_peer_sync(struct task * task, void *context, unsigne } /* !stopping */ else { /* soft stop case */ - if (task->state & TASK_WOKEN_SIGNAL) { + if (state & TASK_WOKEN_SIGNAL) { /* We've just recieved the signal */ if (!(peers->flags & PEERS_F_DONOTSTOP)) { /* add DO NOT STOP flag if not present */ diff --git a/src/session.c b/src/session.c index 3454925ad..afab68add 100644 --- a/src/session.c +++ b/src/session.c @@ -331,7 +331,7 @@ static void session_prepare_log_prefix(struct session *sess) * disabled and finally kills the file descriptor. This function requires that * sess->origin points to the incoming connection. */ -static void session_kill_embryonic(struct session *sess) +static void session_kill_embryonic(struct session *sess, unsigned short state) { int level = LOG_INFO; struct connection *conn = __objt_conn(sess->origin); @@ -352,7 +352,7 @@ static void session_kill_embryonic(struct session *sess) } if (log) { - if (!conn->err_code && (task->state & TASK_WOKEN_TIMER)) { + if (!conn->err_code && (state & TASK_WOKEN_TIMER)) { if (conn->flags & CO_FL_ACCEPT_PROXY) conn->err_code = CO_ER_PRX_TIMEOUT; else if (conn->flags & CO_FL_ACCEPT_CIP) @@ -391,7 +391,7 @@ static struct task *session_expire_embryonic(struct task *t, void *context, unsi if (!(state & TASK_WOKEN_TIMER)) return t; - session_kill_embryonic(sess); + session_kill_embryonic(sess, state); return NULL; } @@ -441,7 +441,7 @@ static int conn_complete_session(struct connection *conn) fail: if (sess->task) - session_kill_embryonic(sess); + session_kill_embryonic(sess, 0); return -1; }