[master] 32574ab46 vsm: Pass VARNISH_DEFAULT_N to VSM_Arg()

Nils Goroll nils.goroll at uplex.de
Mon May 27 10:30:54 UTC 2024


On 26.05.24 20:12, Dridi Boukelmoune wrote:
> Neither the VUT API nor non-VUT programs like varnishadm should
> *duplicate*  this logic

Yes. I see this as the task here: Converge to VUT.

If I consolidate my and your patches into a single diff, this is what I see:

diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c
index 15ab45799..ad5438428 100644
--- a/lib/libvarnishapi/vsm.c
+++ b/lib/libvarnishapi/vsm.c
@@ -745,6 +745,7 @@ VSM_Status(struct vsm *vd)
  int
  VSM_Attach(struct vsm *vd, int progress)
  {
+       const char *def;
         double t0;
         unsigned u;
         int i, n = 0;
@@ -757,8 +758,10 @@ VSM_Attach(struct vsm *vd, int progress)
                 t0 = VTIM_mono() + vd->patience;

         if (vd->wdname == NULL) {
-               /* Use default (hostname) */
-               i = VSM_Arg(vd, 'n', "");
+               def = getenv("VARNISH_DEFAULT_N");
+               if (def == NULL)
+                       def = ""; /* Use default (hostname) */
+               i = VSM_Arg(vd, 'n', def);
                 if (i < 0)
                         return (i);
                 AN(vd->wdname);

To summarize, compared to my original change 
8f8d26c0c1fec91aec9a7f79380c93eb4d266b7e

* this removes *one* line from varnishadm.c

* this does not properly initialize the vut->n_arg

* this does not set the default in VSM_New()

Sorry, you really lost me here.

When you write "there should be only 2 locations needed", I agree that two 
locations are better than four, but no matter how much I appreciate your desire 
to minimize code changes, I do not agree that this is now handled at the right 
place for the reasons given.

Nils



-- 

Nils Goroll (he/him)

** * * UPLEX - Nils Goroll Systemoptimierung

Scheffelstraße 32
22301 Hamburg

tel +49 40 28805731
mob +49 170 2723133
fax +49 40 42949753

xmpp://slink@jabber.int.uplex.de/

http://uplex.de/



More information about the varnish-commit mailing list