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.
diff --git a/src/peers.c b/src/peers.c
index 64d5e08..a99d8e1 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -2118,7 +2118,7 @@
} /* !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 3454925..afab68a 100644
--- a/src/session.c
+++ b/src/session.c
@@ -331,7 +331,7 @@
* 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 @@
}
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 @@
if (!(state & TASK_WOKEN_TIMER))
return t;
- session_kill_embryonic(sess);
+ session_kill_embryonic(sess, state);
return NULL;
}
@@ -441,7 +441,7 @@
fail:
if (sess->task)
- session_kill_embryonic(sess);
+ session_kill_embryonic(sess, 0);
return -1;
}