]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: cli: Atomically inc the global request counter between CLI commands
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 16 Jul 2024 12:42:20 +0000 (14:42 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 18 Jul 2024 14:39:38 +0000 (16:39 +0200)
The global request counter is used to set the stream id (s->uniq_id). It is
incremented at different places. And it must be atomically incremented
because it is a global value. However, in the analyer dealing with CLI
command response, this was not the case. It is now fixed.

This patch must be backported to all stable versions.

src/cli.c

index a1c9323631eddd39a815e59cb473a4ec12e95c87..3b88c7872a4099e2f4a18163577042e1579699ad 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -3219,7 +3219,7 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
                s->target = NULL;
                /* re-init store persistence */
                s->store_count = 0;
-               s->uniq_id = global.req_count++;
+               s->uniq_id = _HA_ATOMIC_FETCH_ADD(&global.req_count, 1);
 
                s->scf->flags &= ~(SC_FL_EOS|SC_FL_ERROR|SC_FL_ABRT_DONE|SC_FL_ABRT_WANTED);
                s->scf->flags &= ~SC_FL_SND_NEVERWAIT;