]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cfgparse: parse tune.bufsize.small as a size
authorWilly Tarreau <w@1wt.eu>
Mon, 18 Nov 2024 18:07:05 +0000 (19:07 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 18 Nov 2024 18:07:05 +0000 (19:07 +0100)
Till now this value was parsed as raw integer using atol() and would
silently ignore any trailing suffix, causing unexpected behaviors when
set, e.g. to "4k". Let's make use of parse_size_err() on it so that
units are supported. This requires to turn it to uint as well, which
was verified to be OK.

doc/configuration.txt
include/haproxy/global-t.h
src/dynbuf.c

index 793716a5a610e7a3002ba5d238880dab0193b5d4..bca9974aeef70c9a384eac56c323ae04636d6e00 100644 (file)
@@ -3336,7 +3336,7 @@ tune.bufsize <size>
   value set using this parameter will automatically be rounded up to the next
   multiple of 8 on 32-bit machines and 16 on 64-bit machines.
 
-tune.bufsize.small <number>
+tune.bufsize.small <size>
   Sets the size in bytes for small buffers. The defaults value is 1024.
 
   These buffers are designed to be used in some specific contexts where memory
index 0a176a65f50ea55095cfa10d6a63c268a44db778..6d4a3986c9ef43eb7882629e8642bd23f76554a4 100644 (file)
@@ -166,7 +166,7 @@ struct global {
                int runqueue_depth;/* max number of tasks to run at once */
                uint recv_enough;  /* how many input bytes at once are "enough" */
                uint bufsize;      /* buffer size in bytes, defaults to BUFSIZE */
-               int bufsize_small; /* small buffer size in bytes */
+               uint bufsize_small;/* small buffer size in bytes */
                int maxrewrite;    /* buffer max rewrite size in bytes, defaults to MAXREWRITE */
                int reserved_bufs; /* how many buffers can only be allocated for response */
                int buf_limit;     /* if not null, how many total buffers may only be allocated */
index f5ae52ee24bb0c52b9a0cc34213d959ab55a5b42..336e40d1dbbe9d0aab4e40976ef9c9627429f120 100644 (file)
@@ -193,7 +193,8 @@ static int cfg_parse_tune_bufsize_small(char **args, int section_type,
                                         struct proxy *curpx, const struct proxy *defpx,
                                         const char *file, int line, char **err)
 {
-       int size;
+       const char *res;
+       uint size;
 
        if (too_many_args(1, args, err, NULL))
                goto err;
@@ -203,7 +204,12 @@ static int cfg_parse_tune_bufsize_small(char **args, int section_type,
                goto err;
        }
 
-       size = atol(args[1]);
+       res = parse_size_err(args[1], &size);
+       if (res != NULL) {
+               memprintf(err, "unexpected '%s' after size passed to '%s'", res, args[0]);
+               goto err;
+       }
+
        if (size <= 0) {
                memprintf(err, "'%s' expects a positive integer argument.\n", args[0]);
                goto err;