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.
This commit is contained in:
Willy Tarreau 2018-11-05 15:09:47 +01:00
parent 1d0b7069f2
commit 086735a688
2 changed files with 5 additions and 5 deletions

View file

@ -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 */

View file

@ -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;
}