[master] e9c70c7 Retire the -N option, it won't make any sense with multi-file VSM layout.

Poul-Henning Kamp phk at FreeBSD.org
Mon May 8 10:11:05 CEST 2017


commit e9c70c7306eb94c14768648dca03fc5b6c3252f9
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon May 8 08:10:06 2017 +0000

    Retire the -N option, it won't make any sense with multi-file VSM layout.

diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index 6e24a05..4f9b324 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -774,7 +774,7 @@ main(int argc, char * const *argv)
 		VJ_master(JAIL_MASTER_LOW);
 	}
 
-	if (VIN_N_Arg(n_arg, &heritage.name, &dirname, NULL) != 0)
+	if (VIN_n_Arg(n_arg, &heritage.name, &dirname) != 0)
 		ARGV_ERR("Invalid instance (-n) name: %s\n", strerror(errno));
 
 #ifdef HAVE_SETPROCTITLE
diff --git a/bin/varnishhist/varnishhist_options.h b/bin/varnishhist/varnishhist_options.h
index a9bedea..a4f70cd 100644
--- a/bin/varnishhist/varnishhist_options.h
+++ b/bin/varnishhist/varnishhist_options.h
@@ -73,7 +73,6 @@ HIS_OPT_g
 VUT_OPT_h
 VSL_OPT_L
 VUT_OPT_n
-VUT_OPT_N
 HIS_OPT_p
 #define HIS_CLIENT	"client"
 #define HIS_BACKEND	"backend"
diff --git a/bin/varnishlog/varnishlog_options.h b/bin/varnishlog/varnishlog_options.h
index 197b8c2..4847268 100644
--- a/bin/varnishlog/varnishlog_options.h
+++ b/bin/varnishlog/varnishlog_options.h
@@ -67,7 +67,6 @@ VSL_OPT_I
 VUT_OPT_k
 VSL_OPT_L
 VUT_OPT_n
-VUT_OPT_N
 VUT_OPT_P
 VUT_OPT_q
 VUT_OPT_r
diff --git a/bin/varnishncsa/varnishncsa_options.h b/bin/varnishncsa/varnishncsa_options.h
index 98ab675..6fe13de 100644
--- a/bin/varnishncsa/varnishncsa_options.h
+++ b/bin/varnishncsa/varnishncsa_options.h
@@ -85,7 +85,6 @@ NCSA_OPT_g
 VUT_OPT_h
 VSL_OPT_L
 VUT_OPT_n
-VUT_OPT_N
 VUT_OPT_P
 VUT_OPT_q
 VUT_OPT_r
diff --git a/bin/varnishstat/varnishstat_options.h b/bin/varnishstat/varnishstat_options.h
index 65a961c..47dd18b 100644
--- a/bin/varnishstat/varnishstat_options.h
+++ b/bin/varnishstat/varnishstat_options.h
@@ -64,7 +64,6 @@ VUT_OPT_h
 STAT_OPT_j
 STAT_OPT_l
 VUT_OPT_n
-VUT_OPT_N
 VUT_OPT_t
 VUT_OPT_V
 STAT_OPT_x
diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc
index 35c8e01..a36eff2 100644
--- a/bin/varnishtest/tests/u00006.vtc
+++ b/bin/varnishtest/tests/u00006.vtc
@@ -51,8 +51,8 @@ shell -err -expect {-X: Syntax error in "**"} \
 	{varnishlog -X "**:bar"}
 shell -err -expect "Cannot open output file (No such file or directory)" \
 	{varnishlog -w /nonexistent/file}
-shell -err -expect "Only one of -n, -N and -r options may be used" \
-	{varnishlog -n ${v1_name} -N ${v1_name}/_.vsm}
+shell -err -expect "Only one of -n and -r options may be used" \
+	{varnishlog -n ${v1_name} -r ${v1_name}/_.vsm}
 
 process p1 -wait
 shell {grep -q "0 CLI" ${tmpdir}/vlog}
diff --git a/bin/varnishtop/varnishtop_options.h b/bin/varnishtop/varnishtop_options.h
index b65a961..1cf0e20 100644
--- a/bin/varnishtop/varnishtop_options.h
+++ b/bin/varnishtop/varnishtop_options.h
@@ -65,7 +65,6 @@ VSL_OPT_i
 VSL_OPT_I
 VSL_OPT_L
 VUT_OPT_n
-VUT_OPT_N
 TOP_OPT_p
 VUT_OPT_q
 VUT_OPT_r
diff --git a/include/vapi/vsm.h b/include/vapi/vsm.h
index 79cba08..52d8167 100644
--- a/include/vapi/vsm.h
+++ b/include/vapi/vsm.h
@@ -98,18 +98,6 @@ int VSM_n_Arg(struct VSM_data *vd, const char *n_arg);
 	 *	 <0 on failure, VSM_Error() returns diagnostic string
 	 */
 
-#define VSM_N_USAGE	"[-N filename]"
-
-int VSM_N_Arg(struct VSM_data *vd, const char *N_arg);
-	/*
-	 * Configure the library to use the specified VSM file name. This
-	 * bypasses abandonment checks and allows looking at stale VSM
-	 * files without a running Varnish instance.
-	 *
-	 * Returns:
-	 *	1 on success
-	 */
-
 const char *VSM_Name(const struct VSM_data *vd);
 	/*
 	 * Return the instance name.
diff --git a/include/vin.h b/include/vin.h
index f627ab5..e0fe073 100644
--- a/include/vin.h
+++ b/include/vin.h
@@ -32,5 +32,5 @@
 #define VIN_H_INCLUDED
 
 /* This function lives in both libvarnish and libvarnishapi */
-int VIN_N_Arg(const char *n_arg, char **name, char **dir, char **vsl);
+int VIN_n_Arg(const char *n_arg, char **name, char **dir);
 #endif
diff --git a/include/vut.h b/include/vut.h
index 5825994..1e1942c 100644
--- a/include/vut.h
+++ b/include/vut.h
@@ -43,7 +43,6 @@ struct VUT {
 	int		g_arg;
 	int		k_arg;
 	char		*n_arg;
-	char		*N_arg;
 	char		*P_arg;
 	char		*q_arg;
 	char		*r_arg;
diff --git a/include/vut_options.h b/include/vut_options.h
index 7afc723..5e6d094 100644
--- a/include/vut_options.h
+++ b/include/vut_options.h
@@ -63,12 +63,6 @@
 	    " the host name is used."					\
 	)
 
-#define VUT_OPT_N							\
-	VOPT("N:", "[-N <filename>]", "VSM filename",			\
-	    "Specify the filename of a stale VSM instance. When using"	\
-	    " this option the abandonment checking is disabled."	\
-	)
-
 #define VUT_OPT_P							\
 	VOPT("P:", "[-P <file>]", "PID file",				\
 		"Write the process' PID to the specified file."		\
diff --git a/lib/libvarnish/vin.c b/lib/libvarnish/vin.c
index e06a2c0..1cb064c 100644
--- a/lib/libvarnish/vin.c
+++ b/lib/libvarnish/vin.c
@@ -43,7 +43,7 @@
 #include "vin.h"
 
 int
-VIN_N_Arg(const char *n_arg, char **name, char **dir, char **vsl)
+VIN_n_Arg(const char *n_arg, char **name, char **dir)
 {
 	char nm[PATH_MAX];
 	char dn[PATH_MAX];
@@ -92,11 +92,5 @@ VIN_N_Arg(const char *n_arg, char **name, char **dir, char **vsl)
 		if (*dir == NULL)
 			return (-1);
 	}
-	if (vsl != NULL) {
-		bprintf(nm, "%s%s", dn, VSM_FILENAME);
-		*vsl = strdup(nm);
-		if (*vsl == NULL)
-			return (-1);
-	}
 	return (0);
 }
diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c
index 5fd55fd..a17d3d0 100644
--- a/lib/libvarnishapi/vsc.c
+++ b/lib/libvarnishapi/vsc.c
@@ -201,7 +201,6 @@ VSC_Arg(struct VSM_data *vd, int arg, const char *opt)
 	switch (arg) {
 	case 'f': return (vsc_f_arg(vd, opt));
 	case 'n': return (VSM_n_Arg(vd, opt));
-	case 'N': return (VSM_N_Arg(vd, opt));
 	default:
 		return (0);
 	}
diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c
index 3805237..18c7b6c 100644
--- a/lib/libvarnishapi/vsm.c
+++ b/lib/libvarnishapi/vsm.c
@@ -132,48 +132,33 @@ int
 VSM_n_Arg(struct VSM_data *vd, const char *arg)
 {
 	char *name = NULL;
-	char *fname = NULL;
+	char *dname = NULL;
+	struct vsb *vsb;
 
 	CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
 
 	if (vd->head)
 		return (vsm_diag(vd, "VSM_n_Arg: Already open"));
-	if (VIN_N_Arg(arg, &name, NULL, &fname))
+	if (VIN_n_Arg(arg, &name, &dname))
 		return (vsm_diag(vd, "Invalid instance name: %s",
 		    strerror(errno)));
 	AN(name);
-	AN(fname);
+	AN(dname);
+	vsb = VSB_new_auto();
+	AN(vsb);
+	VSB_printf(vsb, "%s%s", dname, VSM_FILENAME);
+	AZ(VSB_finish(vsb));
 
-	if (vd->name)
-		free(vd->name);
-	vd->name = name;
-	if (vd->fname)
-		free(vd->fname);
-	vd->fname = fname;
-	vd->N_opt = 0;
+	REPLACE(vd->name, name);
+	REPLACE(vd->dname, dname);
+	REPLACE(vd->iname, VSB_data(vsb));
+	VSB_destroy(&vsb);
 
 	return (1);
 }
 
 /*--------------------------------------------------------------------*/
 
-int
-VSM_N_Arg(struct VSM_data *vd, const char *arg)
-{
-
-	CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
-	AN(arg);
-
-	if (vd->head)
-		return (vsm_diag(vd, "VSM_N_Arg: Already open"));
-	REPLACE(vd->name, arg);
-	REPLACE(vd->fname, arg);
-	vd->N_opt = 1;
-	return (1);
-}
-
-/*--------------------------------------------------------------------*/
-
 const char *
 VSM_Name(const struct VSM_data *vd)
 {
@@ -196,7 +181,7 @@ VSM_Delete(struct VSM_data *vd)
 		VSC_Delete(vd);
 	VSM_ResetError(vd);
 	free(vd->name);
-	free(vd->fname);
+	free(vd->dname);
 	FREE_OBJ(vd);
 }
 
@@ -224,43 +209,42 @@ VSM_Open(struct VSM_data *vd)
 		/* Already open */
 		return (0);
 
-	if (vd->fname == NULL) {
+	if (vd->dname == NULL) {
 		/* Use default (hostname) */
 		i = VSM_n_Arg(vd, "");
 		if (i < 0)
 			return (i);
-		AN(vd->fname);
+		AN(vd->dname);
 	}
 
-	vd->vsm_fd = open(vd->fname, O_RDONLY);
+	vd->vsm_fd = open(vd->iname, O_RDONLY);
 	if (vd->vsm_fd < 0)
 		return (vsm_diag(vd, "Cannot open %s: %s",
-		    vd->fname, strerror(errno)));
+		    vd->iname, strerror(errno)));
 
 	AZ(fstat(vd->vsm_fd, &vd->fstat));
 	if (!S_ISREG(vd->fstat.st_mode)) {
 		closefd(&vd->vsm_fd);
-		return (vsm_diag(vd, "%s is not a regular file",
-		    vd->fname));
+		return (vsm_diag(vd, "%s is not a regular file", vd->iname));
 	}
 
 	i = read(vd->vsm_fd, &slh, sizeof slh);
 	if (i != sizeof slh) {
 		closefd(&vd->vsm_fd);
 		return (vsm_diag(vd, "Cannot read %s: %s",
-		    vd->fname, strerror(errno)));
+		    vd->iname, strerror(errno)));
 	}
 
 	if (memcmp(slh.marker, VSM_HEAD_MARKER, sizeof slh.marker)) {
 		closefd(&vd->vsm_fd);
-		return (vsm_diag(vd, "Not a VSM file %s", vd->fname));
+		return (vsm_diag(vd, "Not a VSM file %s", vd->iname));
 	}
 
-	if (!vd->N_opt && slh.alloc_seq == 0) {
+	if (slh.alloc_seq == 0) {
 		closefd(&vd->vsm_fd);
 		return (vsm_diag(vd,
 		    "Abandoned VSM file (Varnish not running?) %s",
-		    vd->fname));
+		    vd->iname));
 	}
 
 	v = mmap(NULL, slh.shm_size,
@@ -268,7 +252,7 @@ VSM_Open(struct VSM_data *vd)
 	if (v == MAP_FAILED) {
 		closefd(&vd->vsm_fd);
 		return (vsm_diag(vd, "Cannot mmap %s: %s",
-		    vd->fname, strerror(errno)));
+		    vd->iname, strerror(errno)));
 	}
 	vd->head = v;
 	vd->b = v;
@@ -321,9 +305,6 @@ VSM_Abandoned(struct VSM_data *vd)
 	if (vd->head == NULL)
 		/* Not open */
 		return (1);
-	if (vd->N_opt)
-		/* No abandonment check should be done */
-		return (0);
 	if (!vd->head->alloc_seq)
 		/* Flag of abandonment set by mgt */
 		return (1);
@@ -333,7 +314,7 @@ VSM_Abandoned(struct VSM_data *vd)
 	now = VTIM_mono();
 	if (vd->head->age == vd->age_ok && now - vd->t_ok > 2.) {
 		/* No age change for 2 seconds, stat the file */
-		if (stat(vd->fname, &st))
+		if (stat(vd->iname, &st))
 			return (1);
 		if (st.st_dev != vd->fstat.st_dev)
 			return (1);
@@ -370,11 +351,11 @@ VSM__itern(const struct VSM_data *vd, struct VSM_fantom *vf)
 
 	if (!vd->head)
 		return (0);	/* Not open */
-	if (!vd->N_opt && vd->head->alloc_seq == 0)
+	if (vd->head->alloc_seq == 0)
 		return (0);	/* abandoned VSM */
 	else if (vf->chunk != NULL) {
 		/* get next chunk */
-		if (!vd->N_opt && vf->priv != vd->head->alloc_seq)
+		if (vf->priv != vd->head->alloc_seq)
 			return (0); /* changes during iteration */
 		if (vf->chunk->len == 0)
 			return (0); /* free'd during iteration */
@@ -421,7 +402,7 @@ VSM_StillValid(const struct VSM_data *vd, struct VSM_fantom *vf)
 	AN(vf);
 	if (!vd->head)
 		return (VSM_invalid);
-	if (!vd->N_opt && !vd->head->alloc_seq)
+	if (!vd->head->alloc_seq)
 		return (VSM_invalid);
 	if (vf->chunk == NULL)
 		return (VSM_invalid);
diff --git a/lib/libvarnishapi/vsm_api.h b/lib/libvarnishapi/vsm_api.h
index 8ef537b..e357a8f 100644
--- a/lib/libvarnishapi/vsm_api.h
+++ b/lib/libvarnishapi/vsm_api.h
@@ -38,8 +38,8 @@ struct VSM_data {
 	struct vsb		*diag;
 
 	char			*name;
-	char			*fname;
-	int			N_opt;
+	char			*dname;
+	char			*iname;
 
 	struct stat		fstat;
 
diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c
index e3bc741..9079b22 100644
--- a/lib/libvarnishapi/vut.c
+++ b/lib/libvarnishapi/vut.c
@@ -167,10 +167,6 @@ VUT_Arg(int opt, const char *arg)
 		/* Varnish instance name */
 		REPLACE(VUT.n_arg, arg);
 		return (1);
-	case 'N':
-		/* Varnish stale VSM file */
-		REPLACE(VUT.N_arg, arg);
-		return (1);
 	case 'P':
 		/* PID file */
 		REPLACE(VUT.P_arg, arg);
@@ -242,9 +238,8 @@ VUT_Setup(void)
 
 	/* Check input arguments (2 used for bug in FlexeLint) */
 	if ((VUT.n_arg == NULL ? 0 : 2) +
-	    (VUT.N_arg == NULL ? 0 : 2) +
 	    (VUT.r_arg == NULL ? 0 : 2) > 2)
-		VUT_Error(1, "Only one of -n, -N and -r options may be used");
+		VUT_Error(1, "Only one of -n and -r options may be used");
 
 	/* Create and validate the query expression */
 	VUT.vslq = VSLQ_New(VUT.vsl, NULL, VUT.g_arg, VUT.q_arg);
@@ -263,8 +258,6 @@ VUT_Setup(void)
 		AN(VUT.vsm);
 		if (VUT.n_arg && VSM_n_Arg(VUT.vsm, VUT.n_arg) <= 0)
 			VUT_Error(1, "%s", VSM_Error(VUT.vsm));
-		if (VUT.N_arg && VSM_N_Arg(VUT.vsm, VUT.N_arg) <= 0)
-			VUT_Error(1, "%s", VSM_Error(VUT.vsm));
 		REPLACE(VUT.name, VSM_Name(VUT.vsm));
 		t_start = NAN;
 		c = NULL;
@@ -336,7 +329,6 @@ void
 VUT_Fini(void)
 {
 	free(VUT.n_arg);
-	free(VUT.N_arg);
 	free(VUT.r_arg);
 	free(VUT.P_arg);
 	free(VUT.name);



More information about the varnish-commit mailing list