]> git.kaiwu.me - haproxy.git/commit
MINOR: server: ensure max_events_at_once > 0 in server_atomic_sync()
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 7 Aug 2024 16:04:08 +0000 (18:04 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Wed, 7 Aug 2024 16:31:35 +0000 (18:31 +0200)
commita6d1eb8f5d81df0d18e0c9f07c6d199dc39f0893
treeb3e8b158000ffc7a07c1e1f296813482d74c84cb
parent3ef1ee477d3fef54633465b603206dd00bfefeba
MINOR: server: ensure max_events_at_once > 0 in server_atomic_sync()

In 8f1fd96 ("BUG/MEDIUM: server/addr: fix tune.events.max-events-at-once
event miss and leak"), we added a comment saying that
tune.events.max-events-at-once is assumed to be strictly positive.

It is so because the keyword parser forces values between 1 and 10000:
we don't want less than 1 because it wouldn't make any sense, and 10k
max because beyond that we could create contention in server_atomic_sync()

Now as the above commit implements a do..while it heavily relies on the
fact that the budget is at least 1. Upon soft-stop, we break away from
the loop without decrementing the budget. With all that in mind, it is
safe to assume that the 'remain' counter will only fall to 0 if the task
runs out of budget while doing work, in which case the task still exists
and must be rescheduled.

As seen in GH #2667 this assumption was ambiguous, so let's make it
official by adding a pair of BUG_ON() that make it explicit that it
works because remain 'cannot' be 0 unless the entire budget was
consumed.

No backport needed.
src/server.c