MINOR: server: simplify srv_has_streams()

Now that thanks to commit c880c32b16 ("MINOR: stream: decrement
srv->served after detaching from the list") we can trust srv->served,
let's use it and no longer loop on threads when checking if a server
still has streams attached to it. This will be much cheaper and will
result in keeping isolation for a shorter time in the "wait" command.
This commit is contained in:
Willy Tarreau 2025-03-18 11:30:37 +01:00
parent 4651c4edd5
commit 0e8c573b4b

View File

@ -2005,18 +2005,10 @@ static int srv_parse_strict_maxconn(char **args, int *cur_arg, struct proxy *px,
return 0;
}
/* Returns 1 if the server has streams pointing to it, and 0 otherwise.
*
* Must be called with the server lock held.
*/
/* Returns 1 if the server has streams pointing to it, and 0 otherwise. */
static int srv_has_streams(struct server *srv)
{
int thr;
for (thr = 0; thr < global.nbthread; thr++)
if (!MT_LIST_ISEMPTY(&srv->per_thr[thr].streams))
return 1;
return 0;
return !!_HA_ATOMIC_LOAD(&srv->served);
}
/* Shutdown all connections of a server. The caller must pass a termination