]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: server: simplify srv_has_streams()
authorWilly Tarreau <w@1wt.eu>
Tue, 18 Mar 2025 10:30:37 +0000 (11:30 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 18 Mar 2025 16:36:02 +0000 (17:36 +0100)
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.

src/server.c

index 051dd984a3f46a6a975f499cef73c3f38a848186..9fa7dfb33f956849c59f0cea2bbf4ac5666c0f64 100644 (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