MINOR: receiver: reserve special values for "shards"

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.
This commit is contained in:
Willy Tarreau 2023-04-13 17:11:23 +02:00
parent 53fc98c3bc
commit d30e82b9f0
3 changed files with 6 additions and 2 deletions

View 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) */

View File

@ -2972,6 +2972,10 @@ int check_config_validity()
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;

View 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) {