]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Simplication for qc_set_timer()
authorFrédéric Lécaille <flecaille@haproxy.com>
Thu, 9 Feb 2023 06:48:33 +0000 (07:48 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 17 Feb 2023 16:36:30 +0000 (17:36 +0100)
There is no reason to run code for nothing if the timer task has been
released when entering qc_set_timer().

Must be backported to 2.7.

src/quic_conn.c

index 419d1c67034a53ea79b47fff9e7be9d9d154130a..4a3730958fba3f20975b4a577949249104cb02a9 100644 (file)
@@ -754,6 +754,12 @@ static inline void qc_set_timer(struct quic_conn *qc)
        TRACE_ENTER(QUIC_EV_CONN_STIMER, qc,
                    NULL, NULL, &qc->path->ifae_pkts);
 
+       pktns = NULL;
+       if (!qc->timer_task) {
+               TRACE_PROTO("already released timer task", QUIC_EV_CONN_STIMER, qc);
+               goto leave;
+       }
+
        pktns = quic_loss_pktns(qc);
        if (tick_isset(pktns->tx.loss_time)) {
                qc->timer = pktns->tx.loss_time;
@@ -782,19 +788,18 @@ static inline void qc_set_timer(struct quic_conn *qc)
        if (tick_isset(pto))
                qc->timer = pto;
  out:
-       if (qc->timer_task) {
-               if (qc->timer == TICK_ETERNITY) {
-                       qc->timer_task->expire = TICK_ETERNITY;
-               }
-               else  if (tick_is_expired(qc->timer, now_ms)) {
-                       TRACE_DEVEL("wakeup asap timer task", QUIC_EV_CONN_STIMER, qc);
-                       task_wakeup(qc->timer_task, TASK_WOKEN_MSG);
-               }
-               else {
-                       TRACE_DEVEL("timer task scheduling", QUIC_EV_CONN_STIMER, qc);
-                       task_schedule(qc->timer_task, qc->timer);
-               }
+       if (qc->timer == TICK_ETERNITY) {
+               qc->timer_task->expire = TICK_ETERNITY;
+       }
+       else  if (tick_is_expired(qc->timer, now_ms)) {
+               TRACE_DEVEL("wakeup asap timer task", QUIC_EV_CONN_STIMER, qc);
+               task_wakeup(qc->timer_task, TASK_WOKEN_MSG);
        }
+       else {
+               TRACE_DEVEL("timer task scheduling", QUIC_EV_CONN_STIMER, qc);
+               task_schedule(qc->timer_task, qc->timer);
+       }
+ leave:
        TRACE_LEAVE(QUIC_EV_CONN_STIMER, qc, pktns);
 }