]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: haload: set default thread count to 1
authorFrederic Lecaille <flecaille@haproxy.com>
Wed, 22 Jul 2026 09:00:49 +0000 (11:00 +0200)
committerFrederic Lecaille <flecaille@haproxy.com>
Thu, 23 Jul 2026 13:47:07 +0000 (15:47 +0200)
By default <arg_thrd> was unset (-1) and fell back to global.nbthread,
causing inconsistencies since <arg_usr> defaults to 1. This patch sets
the default thread count to 1, enforces that <arg_thrd> does not exceed
<arg_usr>, updates usage help, and writes nbthread unconditionally.

Modify the doc/haload.txt file.

doc/haload.txt
src/haload_init.c

index c82e6d92f768665f917df811ca3ba3d272883c24..73ecc5d4870972632557c46d9c8349a5fbfac205 100644 (file)
@@ -66,7 +66,7 @@ HALoad displays its usage when run without argument or wrong arguments:
             -n <reqs>        maximum total requests (-1)
             -r <reqs>        number of requests per connection (-1)
             -s <time>        soft start: time in sec to reach 100% load
-            -t <threads>     number of threads
+            -t <threads>     number of threads (1)
             -u <users>       number of users (1)
             -w <time>        I/O timeout in milliseconds (10000)
             -C               dump the configuration and exit
index 08cf051a03f719d22b95984ea2dff14715fa88bb..3482bbce2f012a5d2d4b6944f23c230a74ce5c3f 100644 (file)
@@ -28,7 +28,7 @@ static void  hld_usage(char *name, int argc)
                "        -n <reqs>        maximum total requests (-1)\n"
                "        -r <reqs>        number of requests per connection (-1)\n"
                "        -s <time>        soft start: time in sec to reach 100%% load\n"
-               "        -t <threads>     number of threads\n"
+               "        -t <threads>     number of threads (1)\n"
                "        -u <users>       number of users (1)\n"
                "        -w <time>        I/O timeout in milliseconds (10000)\n"
                "        -A               ignore 1st req for resp time measurements\n"
@@ -650,10 +650,14 @@ void haproxy_init_args(int argc, char **argv)
                goto leave;
        }
 
+       if (arg_thrd > arg_usr) {
+               ha_alert("Thread count must not exceed connection count\n");
+               goto leave;
+       }
+
        /* "global" section */
        hbuf_appendf(&buf, "%.*s", (int)gbuf.data, gbuf.area);
-       if (arg_thrd != -1)
-               hbuf_appendf(&buf, "\tnbthread %d\n", arg_thrd);
+       hbuf_appendf(&buf, "\tnbthread %d\n", arg_thrd);
        if (arg_mreqs)
                hbuf_appendf(&buf,
                             "\ttune.h2.be.max-concurrent-streams %d\n", arg_mreqs);