[master] 75f057c Move the high-level param configuration to mgt_param.c
Poul-Henning Kamp
phk at FreeBSD.org
Wed Sep 27 08:45:11 UTC 2017
commit 75f057cfadf54afee9fc9f49a4c4284329f7f49f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Sep 27 08:23:51 2017 +0000
Move the high-level param configuration to mgt_param.c
diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h
index 4542aae..0262880 100644
--- a/bin/varnishd/mgt/mgt.h
+++ b/bin/varnishd/mgt/mgt.h
@@ -161,7 +161,6 @@ extern const char C_CLI[]; // CLI traffic between master and child
/* mgt_param.c */
void MCF_InitParams(struct cli *);
-void MCF_CollectParams(void);
enum mcf_which_e {
MCF_DEFAULT = 32,
MCF_MINIMUM = 33,
diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index be1bb67..0bc438a 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -249,53 +249,6 @@ mgt_Cflag_atexit(void)
/*--------------------------------------------------------------------*/
static void
-init_params(struct cli *cli)
-{
- ssize_t def, low;
-
- MCF_CollectParams();
-
- MCF_TcpParams();
-
- if (sizeof(void *) < 8) { /*lint !e506 !e774 */
- /*
- * Adjust default parameters for 32 bit systems to conserve
- * VM space.
- */
- MCF_ParamConf(MCF_DEFAULT, "workspace_client", "24k");
- MCF_ParamConf(MCF_DEFAULT, "workspace_backend", "16k");
- MCF_ParamConf(MCF_DEFAULT, "http_resp_size", "8k");
- MCF_ParamConf(MCF_DEFAULT, "http_req_size", "12k");
- MCF_ParamConf(MCF_DEFAULT, "gzip_buffer", "4k");
- MCF_ParamConf(MCF_MAXIMUM, "vsl_space", "1G");
- }
-
-#if !defined(HAVE_ACCEPT_FILTERS) || defined(__linux)
- MCF_ParamConf(MCF_DEFAULT, "accept_filter", "off");
-#endif
-
- low = sysconf(_SC_THREAD_STACK_MIN);
- MCF_ParamConf(MCF_MINIMUM, "thread_pool_stack", "%jdb", (intmax_t)low);
-
-#if defined(WITH_SANITIZERS)
- def = 92 * 1024;
-#else
- def = 48 * 1024;
-#endif
- if (def < low)
- def = low;
- MCF_ParamConf(MCF_DEFAULT, "thread_pool_stack", "%jdb", (intmax_t)def);
-
-#if !defined(MAX_THREAD_POOLS)
-# define MAX_THREAD_POOLS 32
-#endif
-
- MCF_ParamConf(MCF_MAXIMUM, "thread_pools", "%d", MAX_THREAD_POOLS);
-
- MCF_InitParams(cli);
-}
-
-static void
mgt_tests(void)
{
assert(VTIM_parse("Sun, 06 Nov 1994 08:49:37 GMT") == 784111777);
@@ -323,7 +276,7 @@ mgt_initialize(struct cli *cli)
mgt_cli_init_cls(); // CLI commands can be registered
- init_params(cli);
+ MCF_InitParams(cli);
cli_check(cli);
}
diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c
index dc25ea4..25b06df 100644
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@ -34,6 +34,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "mgt/mgt.h"
#include "common/heritage.h"
@@ -472,7 +473,7 @@ static struct cli_proto cli_params[] = {
};
/*--------------------------------------------------------------------
- * Wash the min/max/default values, and leave the default set.
+ * Configure the parameters
*/
void
@@ -481,11 +482,54 @@ MCF_InitParams(struct cli *cli)
struct plist *pl;
struct parspec *pp;
struct vsb *vsb;
+ ssize_t def, low;
+
+ MCF_AddParams(mgt_parspec);
+ MCF_AddParams(WRK_parspec);
+ MCF_AddParams(VSL_parspec);
+
+ MCF_TcpParams();
+
+ if (sizeof(void *) < 8) { /*lint !e506 !e774 */
+ /*
+ * Adjust default parameters for 32 bit systems to conserve
+ * VM space.
+ */
+ MCF_ParamConf(MCF_DEFAULT, "workspace_client", "24k");
+ MCF_ParamConf(MCF_DEFAULT, "workspace_backend", "16k");
+ MCF_ParamConf(MCF_DEFAULT, "http_resp_size", "8k");
+ MCF_ParamConf(MCF_DEFAULT, "http_req_size", "12k");
+ MCF_ParamConf(MCF_DEFAULT, "gzip_buffer", "4k");
+ MCF_ParamConf(MCF_MAXIMUM, "vsl_space", "1G");
+ }
+
+#if !defined(HAVE_ACCEPT_FILTERS) || defined(__linux)
+ MCF_ParamConf(MCF_DEFAULT, "accept_filter", "off");
+#endif
+
+ low = sysconf(_SC_THREAD_STACK_MIN);
+ MCF_ParamConf(MCF_MINIMUM, "thread_pool_stack", "%jdb", (intmax_t)low);
+
+#if defined(WITH_SANITIZERS)
+ def = 92 * 1024;
+#else
+ def = 48 * 1024;
+#endif
+ if (def < low)
+ def = low;
+ MCF_ParamConf(MCF_DEFAULT, "thread_pool_stack", "%jdb", (intmax_t)def);
+
+#if !defined(MAX_THREAD_POOLS)
+# define MAX_THREAD_POOLS 32
+#endif
+
+ MCF_ParamConf(MCF_MAXIMUM, "thread_pools", "%d", MAX_THREAD_POOLS);
VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_params);
vsb = VSB_new_auto();
AN(vsb);
+
VTAILQ_FOREACH(pl, &phead, list) {
pp = pl->spec;
@@ -504,17 +548,6 @@ MCF_InitParams(struct cli *cli)
/*--------------------------------------------------------------------*/
void
-MCF_CollectParams(void)
-{
-
- MCF_AddParams(mgt_parspec);
- MCF_AddParams(WRK_parspec);
- MCF_AddParams(VSL_parspec);
-}
-
-/*--------------------------------------------------------------------*/
-
-void
MCF_ParamConf(enum mcf_which_e which, const char *param, const char *fmt, ...)
{
struct parspec *pp;
More information about the varnish-commit
mailing list