[master] 1d7cdadda vsm: Centralize VARNISH_DEFAULT_N fallback

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Fri May 24 12:27:05 UTC 2024


commit 1d7cdaddab67d156f6a99b2d2a1089b3a1913275
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Fri May 24 14:24:17 2024 +0200

    vsm: Centralize VARNISH_DEFAULT_N fallback
    
    Putting the new fallback next to the historical fallback.
    
    Refs #4105

diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c
index f855d2124..3f84afcc2 100644
--- a/bin/varnishadm/varnishadm.c
+++ b/bin/varnishadm/varnishadm.c
@@ -467,7 +467,6 @@ main(int argc, char * const *argv)
 		printf(OPTARG "\n");
 		exit(0);
 	}
-	n_arg = getenv("VARNISH_DEFAULT_N");
 	/*
 	 * By default linux::getopt(3) mangles the argv order, such that
 	 *	varnishadm -n bla param.set foo -bar
diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c
index 7da5aa171..2561d1a1d 100644
--- a/lib/libvarnishapi/vsm.c
+++ b/lib/libvarnishapi/vsm.c
@@ -346,8 +346,6 @@ VSM_New(void)
 	ALLOC_OBJ(vd, VSM_MAGIC);
 	AN(vd);
 
-	REPLACE(vd->wdname, getenv("VARNISH_DEFAULT_N"));
-
 	vd->mgt = vsm_newset(VSM_MGT_DIRNAME);
 	vd->mgt->flag_running = VSM_MGT_RUNNING;
 	vd->mgt->flag_changed = VSM_MGT_CHANGED;
@@ -756,6 +754,9 @@ VSM_Attach(struct vsm *vd, int progress)
 	else
 		t0 = VTIM_mono() + vd->patience;
 
+	if (vd->wdname == NULL)
+		REPLACE(vd->wdname, getenv("VARNISH_DEFAULT_N"));
+
 	if (vd->wdname == NULL) {
 		/* Use default (hostname) */
 		i = VSM_Arg(vd, 'n', "");
diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c
index 315aee7a5..42839da0c 100644
--- a/lib/libvarnishapi/vut.c
+++ b/lib/libvarnishapi/vut.c
@@ -263,7 +263,6 @@ VUT_Init(const char *progname, int argc, char * const *argv,
 	AZ(vut->vsl);
 	vut->vsl = VSL_New();
 	AN(vut->vsl);
-	REPLACE(vut->n_arg, getenv("VARNISH_DEFAULT_N"));
 	return (vut);
 }
 


More information about the varnish-commit mailing list