]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: stream: decrement srv->served after detaching from the list
authorWilly Tarreau <w@1wt.eu>
Tue, 18 Mar 2025 10:24:56 +0000 (11:24 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 18 Mar 2025 10:43:52 +0000 (11:43 +0100)
commitc880c32b16dfd633aa7a8290b74dd46fc4f004cb
treee289357b20fd5d93b8f5b400858d27bc8f5968b8
parent7895726bffb14dd463a969fb8ffaec4ed44ef8b8
MINOR: stream: decrement srv->served after detaching from the list

In commit 3372a2ea00 ("BUG/MEDIUM: queues: Stricly respect maxconn for
outgoing connections"), it has been ensured that srv->served is held
as long as possible around the periods where a stream is attached to a
server. However, it's decremented early when entering sess_change_server,
and actually just before detaching from that server's list. While there
is theoretically nothing wrong with this, it prevents us from looking at
this counter to know if streams are still using a server or not.

We could imagine decrementing it much later but that wouldn't work with
leastconn, since that algo needs ->served to be final before calling
lbprm.server_drop_conn(). Thus what we're doing here is to detach from
the server, then decrement ->served, and only then call the LB callback
to update the server's position in the tree. At this moment the stream
doesn't know the server anymore anyway (except via this function's
local variable) so it's safe to consider that no stream knows the server
once the variable reaches zero.
src/stream.c