]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Ensure PTO timer is not set in the past
authorFrédéric Lécaille <flecaille@haproxy.com>
Wed, 16 Feb 2022 13:46:17 +0000 (14:46 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 1 Mar 2022 15:22:35 +0000 (16:22 +0100)
Wakeup asap the timer task when setting its timer in the past.
Take also the opportunity of this patch to make simplify quic_pto_pktns():
calling tick_first() is useless here to compare <lpto> with <tmp_pto>.

include/haproxy/quic_loss.h
src/xprt_quic.c

index 0aea165ec33b0f78fa433a05a1b946b5f59e42ae..2ba94a9fab156406a0cc89de3b5d77f24dcc394b 100644 (file)
@@ -128,7 +128,7 @@ static inline struct quic_pktns *quic_pto_pktns(struct quic_conn *qc,
                                                 unsigned int *pto)
 {
        int i;
-       unsigned int duration, lpto, time_of_last_eliciting;
+       unsigned int duration, lpto;
        struct quic_loss *ql = &qc->path->loss;
        struct quic_pktns *pktns, *p;
 
@@ -170,9 +170,7 @@ static inline struct quic_pktns *quic_pto_pktns(struct quic_conn *qc,
                }
 
                p = &qc->pktns[i];
-               time_of_last_eliciting = p->tx.time_of_last_eliciting;
-               tmp_pto =
-                       tick_first(lpto, tick_add(time_of_last_eliciting, duration));
+               tmp_pto = tick_add(p->tx.time_of_last_eliciting, duration);
                if (!tick_isset(lpto) || tmp_pto < lpto) {
                        lpto = tmp_pto;
                        pktns = p;
index 6dccb13ba9e05817181c36eb1adc1e2d9259c9de..e2252865342fc8d78d4383df5c9940dc00a33e1e 100644 (file)
@@ -646,8 +646,12 @@ static inline void qc_set_timer(struct quic_conn *qc)
        if (tick_isset(pto))
                qc->timer = pto;
  out:
-       if (qc->timer_task && qc->timer != TICK_ETERNITY)
-               task_schedule(qc->timer_task, qc->timer);
+       if (qc->timer_task && qc->timer != TICK_ETERNITY) {
+               if (tick_is_expired(qc->timer, now_ms))
+                       task_wakeup(qc->timer_task, TASK_WOKEN_MSG);
+               else
+                       task_schedule(qc->timer_task, qc->timer);
+       }
        TRACE_LEAVE(QUIC_EV_CONN_STIMER, qc, pktns);
 }