]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: thread: Restric nbthread/thread-group(s) to very first global sections
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 18 Nov 2022 14:52:58 +0000 (15:52 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 18 Nov 2022 15:03:45 +0000 (16:03 +0100)
nbhread, thead-group and thread-groups directives must only be defined in
very first global sections. It means no other section must have been parsed
before. Indeed, some parts of the configuratio depends on the value of these
settings and it is undefined to change them after.

src/thread.c

index 64ac476a35aadfcadef07ed30f901b65f1372498..59bfbf89cefd3dc7408468be4f21efe1daf4496b 100644 (file)
@@ -1312,6 +1312,11 @@ static int cfg_parse_nbthread(char **args, int section_type, struct proxy *curpx
        if (too_many_args(1, args, err, NULL))
                return -1;
 
+       if (non_global_section_parsed == 1) {
+               memprintf(err, "'%s' not allowed if a non-global section was previously defined. This parameter must be declared in the first global section", args[0]);
+               return -1;
+       }
+
        nbthread = strtol(args[1], &errptr, 10);
        if (!*args[1] || *errptr) {
                memprintf(err, "'%s' passed a missing or unparsable integer value in '%s'", args[0], args[1]);
@@ -1349,6 +1354,11 @@ static int cfg_parse_thread_group(char **args, int section_type, struct proxy *c
        long tnum, tend, tgroup;
        int arg, tot;
 
+       if (non_global_section_parsed == 1) {
+               memprintf(err, "'%s' not allowed if a non-global section was previously defined. This parameter must be declared in the first global section", args[0]);
+               return -1;
+       }
+
        tgroup = strtol(args[1], &errptr, 10);
        if (!*args[1] || *errptr) {
                memprintf(err, "'%s' passed a missing or unparsable integer value in '%s'", args[0], args[1]);
@@ -1446,6 +1456,11 @@ static int cfg_parse_thread_groups(char **args, int section_type, struct proxy *
        if (too_many_args(1, args, err, NULL))
                return -1;
 
+       if (non_global_section_parsed == 1) {
+               memprintf(err, "'%s' not allowed if a non-global section was previously defined. This parameter must be declared in the first global section", args[0]);
+               return -1;
+       }
+
        nbtgroups = strtol(args[1], &errptr, 10);
        if (!*args[1] || *errptr) {
                memprintf(err, "'%s' passed a missing or unparsable integer value in '%s'", args[0], args[1]);