[master] f09b51f Add a VUT.name desc string of the currently open VSM context.

Martin Blix Grydeland martin at varnish-software.com
Thu Jan 30 14:02:08 CET 2014


commit f09b51fbad14ec5c11e6422dd1efd429436a684d
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Thu Jan 30 13:34:58 2014 +0100

    Add a VUT.name desc string of the currently open VSM context.

diff --git a/include/vut.h b/include/vut.h
index ba109f4..a0b9df2 100644
--- a/include/vut.h
+++ b/include/vut.h
@@ -35,6 +35,7 @@ typedef int VUT_cb_f(void);
 
 struct VUT {
 	const char	*progname;
+	char		*name;
 
 	/* Options */
 	int		d_opt;
diff --git a/lib/libvarnishtools/vut.c b/lib/libvarnishtools/vut.c
index 4ca7fbc..f465b1f 100644
--- a/lib/libvarnishtools/vut.c
+++ b/lib/libvarnishtools/vut.c
@@ -173,6 +173,7 @@ void
 VUT_Init(const char *progname)
 {
 	VUT.progname = progname;
+	REPLACE(VUT.name, "");
 	VUT.g_arg = VSL_g_vxid;
 	AZ(VUT.vsl);
 	VUT.vsl = VSL_New();
@@ -189,9 +190,10 @@ VUT_Setup(void)
 	/* Input */
 	if (VUT.r_arg && VUT.vsm)
 		VUT_Error(1, "Can't have both -n and -r options");
-	if (VUT.r_arg)
+	if (VUT.r_arg) {
+		REPLACE(VUT.name, VUT.r_arg);
 		c = VSL_CursorFile(VUT.vsl, VUT.r_arg, 0);
-	else {
+	} else {
 		if (VUT.vsm == NULL)
 			/* Default uses VSM with n=hostname */
 			VUT.vsm = VSM_New();
@@ -199,6 +201,7 @@ VUT_Setup(void)
 		if (VSM_Open(VUT.vsm))
 			VUT_Error(1, "Can't open VSM file (%s)",
 			    VSM_Error(VUT.vsm));
+		REPLACE(VUT.name, VSM_Name(VUT.vsm));
 		c = VSL_CursorVSM(VUT.vsl, VUT.vsm,
 		    (VUT.d_opt ? VSL_COPT_TAILSTOP : VSL_COPT_TAIL)
 		    | VSL_COPT_BATCH);
@@ -242,6 +245,7 @@ VUT_Fini(void)
 {
 	free(VUT.r_arg);
 	free(VUT.P_arg);
+	free(VUT.name);
 
 	vut_vpf_remove();
 	AZ(VUT.pfh);



More information about the varnish-commit mailing list