[master] dbbfa11 Make sure there is always a listen address name

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Thu Aug 17 11:20:07 CEST 2017


commit dbbfa11f106ea099fdaab3dbcdd4a8712bb4e934
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Thu Aug 17 11:13:48 2017 +0200

    Make sure there is always a listen address name
    
    Otherwise a field goes missing in SessOpen records.

diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c
index 48e54a0..9284bd0 100644
--- a/bin/varnishd/mgt/mgt_acceptor.c
+++ b/bin/varnishd/mgt/mgt_acceptor.c
@@ -163,6 +163,8 @@ MAC_Arg(const char *spec)
 	int error;
 	const struct transport *xp;
 	const char *name;
+	char name_buf[8];
+	static unsigned seq = 0;
 
 	av = MGT_NamedArg(spec, &name, "-a");
 	AN(av);
@@ -172,6 +174,12 @@ MAC_Arg(const char *spec)
 	VTAILQ_INIT(&la->socks);
 	VTAILQ_INSERT_TAIL(&listen_args, la, list);
 	la->endpoint = av[1];
+
+	if (name == NULL) {
+		bprintf(name_buf, "a%u", seq++);
+		name = strdup(name_buf);
+		AN(name);
+	}
 	la->name = name;
 
 	if (av[2] == NULL) {
diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst
index 4261ce2..0592c7d 100644
--- a/doc/sphinx/reference/varnishd.rst
+++ b/doc/sphinx/reference/varnishd.rst
@@ -15,7 +15,7 @@ HTTP accelerator daemon
 SYNOPSIS
 ========
 
-varnishd [-a address[:port][,PROTO]] [-b host[:port]] [-C] [-d] [-F] [-f config] [-h type[,options]] [-I clifile] [-i identity] [-j jail[,jailoptions]] [-l vsl[,vsm]] [-M address:port] [-n name] [-P file] [-p param=value] [-r param[,param...]] [-S secret-file] [-s [name=]kind[,options]] [-T address[:port]] [-t TTL] [-V] [-W waiter] [-x parameter|vsl|cli|builtin] [-?]
+varnishd [-a [name=]address[:port][,PROTO]] [-b host[:port]] [-C] [-d] [-F] [-f config] [-h type[,options]] [-I clifile] [-i identity] [-j jail[,jailoptions]] [-l vsl[,vsm]] [-M address:port] [-n name] [-P file] [-p param=value] [-r param[,param...]] [-S secret-file] [-s [name=]kind[,options]] [-T address[:port]] [-t TTL] [-V] [-W waiter] [-x parameter|vsl|cli|builtin] [-?]
 
 DESCRIPTION
 ===========
@@ -32,14 +32,15 @@ OPTIONS
 Basic options
 -------------
 
--a <address[:port][,PROTO]>
+-a <[name=]address[:port][,PROTO]>
 
   Listen for client requests on the specified address and port. The
   address can be a host name ("localhost"), an IPv4 dotted-quad
   ("127.0.0.1"), or an IPv6 address enclosed in square brackets
   ("[::1]"). If address is not specified, `varnishd` will listen on all
   available IPv4 and IPv6 interfaces. If port is not specified, port
-  80 (http) is used.
+  80 (http) is used. Names are referenced in logs, and when omitted they fall
+  back to "a0", "a1" etc.
   An additional protocol type can be set for the listening socket with PROTO.
   Valid protocol types are: HTTP/1 (default), and PROXY.
   Multiple listening addresses can be specified by using multiple -a arguments.
@@ -168,7 +169,8 @@ Tuning options
   Use the specified storage backend. See `Storage Backend`_ section.
 
   This option can be used multiple times to specify multiple storage
-  files. Names are referenced in logs, VCL, statistics, etc.
+  files. Names are referenced in logs, VCL, statistics... When omitted
+  names fall back to "s0", "s1" etc.
 
 -l <vsl[,vsm]>
 
diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h
index 65191d2..c34df04 100644
--- a/include/tbl/vsl_tags.h
+++ b/include/tbl/vsl_tags.h
@@ -72,7 +72,7 @@ SLTM(SessOpen, 0, "Client connection opened",
 	"\t|  |  |  |  |  +- File descriptor number\n"
 	"\t|  |  |  |  +---- Local TCP port\n"
 	"\t|  |  |  +------- Local IPv4/6 address\n"
-	"\t|  |  +---------- Listen socket (-a argument)\n"
+	"\t|  |  +---------- Socket name (from -a argument)\n"
 	"\t|  +------------- Remote TCP port\n"
 	"\t+---------------- Remote IPv4/6 address\n"
 	"\n"



More information about the varnish-commit mailing list