[master] b23dddd3e Add param.reset command to varnishadm

guillaume quintard gquintard at users.noreply.github.com
Thu Jan 31 22:43:08 UTC 2019


commit b23dddd3ee02cd5cf093ae7fd534ace34ef90656
Author: Guillaume Quintard <guillaume at varnish-software.com>
Date:   Mon Jan 14 21:35:27 2019 -0800

    Add param.reset command to varnishadm

diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c
index 9c6a74685..2bf69a0e5 100644
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@ -505,6 +505,8 @@ MCF_ParamSet(struct cli *cli, const char *param, const char *val)
 		VCLI_Out(cli, "parameter \"%s\" is protected.", param);
 		return;
 	}
+	if (!val)
+		val = pp->def;
 	if (pp->func(cli->sb, pp, val))
 		VCLI_SetResult(cli, CLIS_PARAM);
 
@@ -534,6 +536,16 @@ mcf_param_set(struct cli *cli, const char * const *av, void *priv)
 	MCF_ParamSet(cli, av[2], av[3]);
 }
 
+/*--------------------------------------------------------------------*/
+
+static void v_matchproto_(cli_func_t)
+mcf_param_reset(struct cli *cli, const char * const *av, void *priv)
+{
+
+	(void)priv;
+	MCF_ParamSet(cli, av[2], NULL);
+}
+
 /*--------------------------------------------------------------------
  * Add a group of parameters to the global set and sort by name.
  */
@@ -595,6 +607,7 @@ static struct cli_proto cli_params[] = {
 	{ CLICMD_PARAM_SHOW,		"", mcf_param_show,
 	  mcf_param_show_json },
 	{ CLICMD_PARAM_SET,		"", mcf_param_set },
+	{ CLICMD_PARAM_RESET,		"", mcf_param_reset },
 	{ NULL }
 };
 
diff --git a/bin/varnishtest/tests/b00008.vtc b/bin/varnishtest/tests/b00008.vtc
index 6134ff0e6..4fdf4205b 100644
--- a/bin/varnishtest/tests/b00008.vtc
+++ b/bin/varnishtest/tests/b00008.vtc
@@ -38,6 +38,12 @@ varnish v1 -clijson "ping -j"
 
 varnish v1 -clierr 106 "param.set waiter HASH(0x8839c4c)"
 
+varnish v1 -cliexpect 60 "param.show first_byte_timeout"
+varnish v1 -cliok "param.set first_byte_timeout 120"
+varnish v1 -cliexpect 120 "param.show first_byte_timeout"
+varnish v1 -cliok "param.reset first_byte_timeout"
+varnish v1 -cliexpect 60 "param.show first_byte_timeout"
+
 varnish v1 -cliok "param.set cli_limit 128"
 
 varnish v1 -clierr 201 "param.show"
diff --git a/doc/changes.rst b/doc/changes.rst
index 79e353b15..37b7dfbba 100644
--- a/doc/changes.rst
+++ b/doc/changes.rst
@@ -110,6 +110,8 @@ Varnish Cache trunk (ongoing)
 
 * added ``req.is_hitmiss`` and ``req.is_hitpass`` (2743_)
 
+* Add ``param.reset`` command to ``varnishadm``
+
 .. _2809: https://github.com/varnishcache/varnish-cache/issues/2809
 .. _2820: https://github.com/varnishcache/varnish-cache/issues/2820
 .. _2815: https://github.com/varnishcache/varnish-cache/issues/2815
diff --git a/include/tbl/cli_cmds.h b/include/tbl/cli_cmds.h
index 25f13d4ac..57efeaab6 100644
--- a/include/tbl/cli_cmds.h
+++ b/include/tbl/cli_cmds.h
@@ -133,6 +133,14 @@ CLI_CMD(VCL_LABEL,
 	2, 2
 )
 
+CLI_CMD(PARAM_RESET,
+	"param.reset",
+	"param.reset <param>",
+	"Reset parameter to default value.",
+	"",
+	1,1
+)
+
 CLI_CMD(PARAM_SHOW,
 	"param.show",
 	"param.show [-l|-j] [<param>|changed]",


More information about the varnish-commit mailing list