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.
diff --git a/include/haproxy/receiver-t.h b/include/haproxy/receiver-t.h
index b83fe1a..4372d46 100644
--- a/include/haproxy/receiver-t.h
+++ b/include/haproxy/receiver-t.h
@@ -50,7 +50,7 @@
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) */
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 4272c3d..aba342d 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -2972,6 +2972,10 @@
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;
diff --git a/src/listener.c b/src/listener.c
index 2e373a3..ce7f569 100644
--- a/src/listener.c
+++ b/src/listener.c
@@ -1865,7 +1865,7 @@
}
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) {