From 12eca3a727b3278cf456b0f62da9d91c4b9c2a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= Date: Tue, 4 Apr 2023 10:46:54 +0200 Subject: [PATCH] BUG/MINOR: quic: Unexpected connection closures upon idle timer task execution This bug arrived with this commit: MEDIUM: quic: Ack delay implementation It is possible that the idle timer task was already in the run queue when its ->expire field was updated calling qc_idle_timer_do_rearm(). To prevent this task from running in this condition, one must check its ->expire field value with this condition to run the task if its timer has really expired: !tick_is_expired(t->expire, now_ms) Furthermore, as this task may be directly woken up with a call to task_wakeup() all, for instance by qc_kill_conn() to kill the connection, one must check this task has really been woken up when it was in the wait queue and not by a direct call to task_wakeup() thanks to this test: (state & TASK_WOKEN_ANY) == TASK_WOKEN_TIMER Again, when this condition is not fulfilled, the task must be run. Must be backported where the commit mentionned above was backported. --- src/quic_conn.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/quic_conn.c b/src/quic_conn.c index 5936a5390..22da20760 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -5681,6 +5681,9 @@ struct task *qc_idle_timer_task(struct task *t, void *ctx, unsigned int state) TRACE_ENTER(QUIC_EV_CONN_IDLE_TIMER, qc); + if ((state & TASK_WOKEN_ANY) == TASK_WOKEN_TIMER && !tick_is_expired(t->expire, now_ms)) + goto requeue; + if (tick_is_expired(qc->ack_expire, now_ms)) { TRACE_PROTO("ack timer expired", QUIC_EV_CONN_SSLALERT, qc); qc->ack_expire = TICK_ETERNITY;