]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: tasks: make sure wakeup events are properly reported to subscribers
authorWilly Tarreau <w@1wt.eu>
Mon, 5 Nov 2018 14:09:47 +0000 (15:09 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 5 Nov 2018 16:15:21 +0000 (17:15 +0100)
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
src/session.c

index 64d5e085d90df4baeac2008f44d82964d824691d..a99d8e166da11ea55341c2fd397ad098c205b618 100644 (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 */
index 3454925ad9068d9d5e7ca96784c7fee2fc7f7d6c..afab68add4cd47aad8903971ffc9a2c6bd2a1df1 100644 (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;
 }