REORG: cli: move "set maxconn frontend" to proxy.c
And get rid of the last specific "set maxconn" case.
diff --git a/src/cli.c b/src/cli.c
index 177a955..3e560c3 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -73,7 +73,6 @@
" help : this message\n"
" prompt : toggle interactive mode with prompt\n"
" quit : disconnect\n"
- " set maxconn : change a maxconn setting\n"
" set rate-limit : change a rate limiting value\n"
" disable : put a server or frontend in maintenance mode\n"
" enable : re-enable a server or frontend which is in maintenance mode\n"
@@ -542,51 +541,7 @@
}
}
else if (strcmp(args[0], "set") == 0) {
- if (strcmp(args[1], "maxconn") == 0) {
- if (strcmp(args[2], "frontend") == 0) {
- struct proxy *px;
- struct listener *l;
- int v;
-
- px = expect_frontend_admin(s, si, args[3]);
- if (!px)
- return 1;
-
- if (!*args[4]) {
- appctx->ctx.cli.msg = "Integer value expected.\n";
- appctx->st0 = STAT_CLI_PRINT;
- return 1;
- }
-
- v = atoi(args[4]);
- if (v < 0) {
- appctx->ctx.cli.msg = "Value out of range.\n";
- appctx->st0 = STAT_CLI_PRINT;
- return 1;
- }
-
- /* OK, the value is fine, so we assign it to the proxy and to all of
- * its listeners. The blocked ones will be dequeued.
- */
- px->maxconn = v;
- list_for_each_entry(l, &px->conf.listeners, by_fe) {
- l->maxconn = v;
- if (l->state == LI_FULL)
- resume_listener(l);
- }
-
- if (px->maxconn > px->feconn && !LIST_ISEMPTY(&px->listener_queue))
- dequeue_all_listeners(&px->listener_queue);
-
- return 1;
- }
- else {
- appctx->ctx.cli.msg = "'set maxconn' only supports 'frontend', 'server', and 'global'.\n";
- appctx->st0 = STAT_CLI_PRINT;
- return 1;
- }
- }
- else if (strcmp(args[1], "rate-limit") == 0) {
+ if (strcmp(args[1], "rate-limit") == 0) {
if (strcmp(args[2], "connections") == 0) {
if (strcmp(args[3], "global") == 0) {
int v;
diff --git a/src/proxy.c b/src/proxy.c
index 45a3db0..7d33442 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -1419,8 +1419,52 @@
return 1;
}
+/* Parses the "set maxconn frontend" directive, it always returns 1 */
+static int cli_parse_set_maxconn_frontend(char **args, struct appctx *appctx, void *private)
+{
+ struct proxy *px;
+ struct listener *l;
+ int v;
+
+ if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
+ return 1;
+
+ px = cli_find_frontend(appctx, args[3]);
+ if (!px)
+ return 1;
+
+ if (!*args[4]) {
+ appctx->ctx.cli.msg = "Integer value expected.\n";
+ appctx->st0 = STAT_CLI_PRINT;
+ return 1;
+ }
+
+ v = atoi(args[4]);
+ if (v < 0) {
+ appctx->ctx.cli.msg = "Value out of range.\n";
+ appctx->st0 = STAT_CLI_PRINT;
+ return 1;
+ }
+
+ /* OK, the value is fine, so we assign it to the proxy and to all of
+ * its listeners. The blocked ones will be dequeued.
+ */
+ px->maxconn = v;
+ list_for_each_entry(l, &px->conf.listeners, by_fe) {
+ l->maxconn = v;
+ if (l->state == LI_FULL)
+ resume_listener(l);
+ }
+
+ if (px->maxconn > px->feconn && !LIST_ISEMPTY(&px->listener_queue))
+ dequeue_all_listeners(&px->listener_queue);
+
+ return 1;
+}
+
/* register cli keywords */
static struct cli_kw_list cli_kws = {{ },{
+ { { "set", "maxconn", "frontend", NULL }, "set maxconn frontend : change a frontend's maxconn setting", cli_parse_set_maxconn_frontend, NULL },
{ { "show","servers", "state", NULL }, "show servers state [id]: dump volatile server information (for backend <id>)", cli_parse_show_servers, cli_io_handler_servers_state },
{ { "show", "backend", NULL }, "show backend : list backends in the current running config", cli_parse_show_backend, cli_io_handler_show_backend },
{{},}