]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: receiver: reserve special values for "shards"
authorWilly Tarreau <w@1wt.eu>
Thu, 13 Apr 2023 15:11:23 +0000 (17:11 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 13 Apr 2023 15:12:50 +0000 (17:12 +0200)
Instead of artificially setting the shards count to MAX_THREAD when
"by-thread" is used, let's reserve special values for symbolic names
so that we can add more in the future. For now we use value -1 for
"by-thread", which requires to turn the type to signed int but it was
already used as such everywhere anyway.

include/haproxy/receiver-t.h
src/cfgparse.c
src/listener.c

index b83fe1ac04648bde7f9b9ff2f36a329becdcbc07..4372d46970a4e5cd91952dc80b0fb7f62ddf123b 100644 (file)
@@ -50,7 +50,7 @@ struct rx_settings {
        char *interface;                  /* interface name or NULL */
        const struct netns_entry *netns;  /* network namespace of the listener*/
        unsigned int options;             /* receiver options (RX_O_*) */
-       uint shards;                      /* number of shards */
+       int shards;                       /* number of shards, 0=not set yet, -1="by-thread" */
 };
 
 /* This describes a receiver with all its characteristics (address, options, etc) */
index 4272c3df185be9f2b9689b65a60f947eabb4c9ad..aba342d6d458094025b3a05dd768f71840c61f3a 100644 (file)
@@ -2972,6 +2972,10 @@ init_proxies_list_stage1:
                                shards = bind_conf->settings.shards;
                                todo = thread_set_count(&bind_conf->thread_set);
 
+                               /* special values: -1 = "by-thread" */
+                               if (shards == -1)
+                                       shards = todo;
+
                                /* no more shards than total threads */
                                if (shards > todo)
                                        shards = todo;
index 2e373a3614f10581a86982118369f252d9a1385d..ce7f56993f0276a461787583f280b2defcb27a4c 100644 (file)
@@ -1865,7 +1865,7 @@ static int bind_parse_shards(char **args, int cur_arg, struct proxy *px, struct
        }
 
        if (strcmp(args[cur_arg + 1], "by-thread") == 0) {
-               val = MAX_THREADS; /* will be trimmed later anyway */
+               val = -1; /* -1 = "by-thread", will be fixed in check_config_validity() */
        } else {
                val = atol(args[cur_arg + 1]);
                if (val < 1 || val > MAX_THREADS) {