]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: haload: fix spurious task wakeup in hld_strm_task()
authorFrederic Lecaille <flecaille@haproxy.com>
Tue, 7 Jul 2026 14:00:47 +0000 (16:00 +0200)
committerFrederic Lecaille <flecaille@haproxy.com>
Wed, 8 Jul 2026 06:27:28 +0000 (08:27 +0200)
When a stream is freed, hld_strm_task() was unconditionally re-queuing
the user task, even when no streams were left or when no update was
needed. This caused spurious task wakeups, which could incorrectly inflate
connection and request rate counters to come for the -R option implementation.

Only queue the user task if there are remaining streams to process, and
properly update the expiration time.

No need to backport. haload arrived with this current version.

src/haload.c

index 470f9a3b99c3576242ad1ab3812f21010f012785..17cefa9612b65fb876e134f42ff0a954d6ef8698 100644 (file)
@@ -1265,6 +1265,17 @@ struct task *hld_strm_task(struct task *t, void *context, unsigned int state)
        hldstream_free(&hs);
        t = NULL;
 
+       if (LIST_ISEMPTY(&usr->strms))
+               usr->task->expire = TICK_ETERNITY;
+       else {
+               /* Update the user task expiration from the first stream which
+                * is also the stream with the oldest expiration time.
+                */
+               first_hs = LIST_ELEM(usr->strms.n, struct hldstream *, list);
+               hs->usr->task->expire = first_hs->expire;
+               task_queue(hs->usr->task);
+       }
+
        goto leave;
  err:
        TRACE_DEVEL("leaving on error", HLD_STRM_EV_TASK, hs);