[master] 941087b On futher reflection: gethostname(3) is a better -i default than "varnishd"
Poul-Henning Kamp
phk at FreeBSD.org
Tue Jun 6 16:54:06 CEST 2017
commit 941087b494da96afdd80c3865950fb5b51f0a304
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Jun 6 14:52:57 2017 +0000
On futher reflection: gethostname(3) is a better -i default than "varnishd"
diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h
index 8cb2490..07b8c61 100644
--- a/bin/varnishd/mgt/mgt.h
+++ b/bin/varnishd/mgt/mgt.h
@@ -174,6 +174,7 @@ void mgt_SHM_Size_Adjust(void);
void MCF_TcpParams(void);
/* mgt_util.c */
+char *mgt_HostName(void);
void mgt_ProcTitle(const char *comp);
void mgt_DumpRstVsl(void);
struct vsb *mgt_BuildVident(void);
diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index df1fbda..4c78e39 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -747,7 +747,7 @@ main(int argc, char * const *argv)
ARGV_ERR("Invalid instance (-n) name: %s\n", strerror(errno));
if (i_arg == NULL || *i_arg == '\0')
- i_arg = "varnishd";
+ i_arg = mgt_HostName();
heritage.identity = i_arg;
mgt_ProcTitle("Mgr");
diff --git a/bin/varnishd/mgt/mgt_util.c b/bin/varnishd/mgt/mgt_util.c
index 5730ae5..15bee9f 100644
--- a/bin/varnishd/mgt/mgt_util.c
+++ b/bin/varnishd/mgt/mgt_util.c
@@ -45,6 +45,20 @@
/*--------------------------------------------------------------------*/
+char *
+mgt_HostName(void)
+{
+ char *p;
+ char buf[1024];
+
+ AZ(gethostname(buf, sizeof buf));
+ p = strdup(buf);
+ AN(p);
+ return (p);
+}
+
+/*--------------------------------------------------------------------*/
+
void
mgt_ProcTitle(const char *comp)
{
diff --git a/doc/changes.rst b/doc/changes.rst
index 478202e..eef34c2 100644
--- a/doc/changes.rst
+++ b/doc/changes.rst
@@ -2,6 +2,8 @@
Varnish Cache Trunk (ongoing)
=============================
+* Default the -i argument to gethostname(3)
+
* On platforms with setproctitle(3), use the -i argument rather than -n
* VSM_Name() returns the -i argument name, rather than the -n name.
diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst
index 0064580..1d63dbe 100644
--- a/doc/sphinx/reference/varnishd.rst
+++ b/doc/sphinx/reference/varnishd.rst
@@ -135,7 +135,7 @@ Operations options
Specify the identity of the Varnish server. This can be accessed
using ``server.identity`` from VCL and with VSM_Name() from
- utilities.
+ utilities. If not specified the output of gethostname(3) is used.
-I clifile
diff --git a/lib/libvarnish/vin.c b/lib/libvarnish/vin.c
index 78ab952..f2a3119 100644
--- a/lib/libvarnish/vin.c
+++ b/lib/libvarnish/vin.c
@@ -85,7 +85,7 @@ VIN_n_Arg(const char *n_arg, char **dir)
if (dir != NULL) {
*dir = strdup(dn);
- if (*dir == NULL)
+ if (*dir == NULL)
return (-1);
}
return (0);
diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py
index 1a3d5da..94275d4 100755
--- a/lib/libvcc/generate.py
+++ b/lib/libvcc/generate.py
@@ -216,7 +216,7 @@ sp_variables = [
(), """
The identity of the server, as set by the -i
parameter. If the -i parameter is not passed to varnishd,
- server.identity will be set to "varnishd".
+ server.identity will be set to the hostname of the machine.
"""
),
('req',
More information about the varnish-commit
mailing list