[master] 6e4d4b3b5 param: Document timeout "never" with a pseudo-flag

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Tue Mar 5 08:53:08 UTC 2024


commit 6e4d4b3b5f9dc782431a48e4c3e27d0e9396a86a
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Mon Feb 26 19:11:12 2024 +0100

    param: Document timeout "never" with a pseudo-flag
    
    The timeout type is the authority from which both the tweak and flag
    are derived.

diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c
index d305a1006..009ad7618 100644
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@ -62,6 +62,10 @@ static const int tab0 = 3;
 
 /*--------------------------------------------------------------------*/
 
+static const char TYPE_TIMEOUT_TEXT[] =
+	"\n\n"
+	"NB: This parameter can be disabled with the value \"never\".";
+
 static const char OBJ_STICKY_TEXT[] =
 	"\n\n"
 	"NB: This parameter is evaluated only when objects are created. "
@@ -337,6 +341,8 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv)
 				    margin1, "", pp->max);
 			VCLI_Out(cli, "\n");
 			mcf_wrap(cli, pp->descr);
+			if (pp->func == tweak_timeout)
+				mcf_wrap(cli, TYPE_TIMEOUT_TEXT);
 			if (pp->flags & OBJ_STICKY)
 				mcf_wrap(cli, OBJ_STICKY_TEXT);
 			if (pp->flags & DELAYED_EFFECT)
@@ -825,6 +831,7 @@ MCF_DumpRstParam(void)
 	struct plist *pl;
 	const struct parspec *pp;
 	const char *p, *q, *t1, *t2;
+	unsigned flags;
 	size_t z;
 
 	printf("\n.. The following is the autogenerated "
@@ -857,35 +864,42 @@ MCF_DumpRstParam(void)
 		MCF_DYN_REASON(Minimum, min);
 		MCF_DYN_REASON(Maximum, max);
 #undef MCF_DYN_REASON
-		if (pp->flags & ~DOCS_FLAGS) {
+		flags = pp->flags & ~DOCS_FLAGS;
+		if (pp->func == tweak_timeout)
+			flags |= TYPE_TIMEOUT;
+		if (flags) {
 			printf("\t* Flags: ");
 			q = "";
 
-			if (pp->flags & DELAYED_EFFECT) {
+			if (flags & TYPE_TIMEOUT) {
+				printf("%stimeout", q);
+				q = ", ";
+			}
+			if (flags & DELAYED_EFFECT) {
 				printf("%sdelayed", q);
 				q = ", ";
 			}
-			if (pp->flags & MUST_RESTART) {
+			if (flags & MUST_RESTART) {
 				printf("%smust_restart", q);
 				q = ", ";
 			}
-			if (pp->flags & MUST_RELOAD) {
+			if (flags & MUST_RELOAD) {
 				printf("%smust_reload", q);
 				q = ", ";
 			}
-			if (pp->flags & EXPERIMENTAL) {
+			if (flags & EXPERIMENTAL) {
 				printf("%sexperimental", q);
 				q = ", ";
 			}
-			if (pp->flags & WIZARD) {
+			if (flags & WIZARD) {
 				printf("%swizard", q);
 				q = ", ";
 			}
-			if (pp->flags & ONLY_ROOT) {
+			if (flags & ONLY_ROOT) {
 				printf("%sonly_root", q);
 				q = ", ";
 			}
-			if (pp->flags & OBJ_STICKY) {
+			if (flags & OBJ_STICKY) {
 				printf("%sobj_sticky", q);
 				q = ", ";
 			}
diff --git a/bin/varnishd/mgt/mgt_param.h b/bin/varnishd/mgt/mgt_param.h
index 83a497945..c88aef212 100644
--- a/bin/varnishd/mgt/mgt_param.h
+++ b/bin/varnishd/mgt/mgt_param.h
@@ -58,6 +58,7 @@ struct parspec {
 #define NOT_IMPLEMENTED		(1<<8)
 #define PLATFORM_DEPENDENT	(1<<9)
 #define BUILD_OPTIONS		(1<<10)
+#define TYPE_TIMEOUT		(1<<11)
 
 #define DOCS_FLAGS	(NOT_IMPLEMENTED|PLATFORM_DEPENDENT|BUILD_OPTIONS)
 
diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst
index 002de7d73..3f7dfcb1b 100644
--- a/doc/sphinx/reference/varnishd.rst
+++ b/doc/sphinx/reference/varnishd.rst
@@ -590,7 +590,7 @@ A duration parameter may accept the following units suffixes:
 - ``w`` (weeks)
 - ``y`` (years)
 
-If the parameter is a timeout or a deadline, a value of zero (when allowed)
+If the parameter is a timeout or a deadline, a value of "never" (when allowed)
 disables the effect of the parameter.
 
 Run Time Parameter Flags


More information about the varnish-commit mailing list