]> err.no Git - varnish/commitdiff
Slight improvements on Cecilie's commit: correct nroff style and man page
authordes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 15 Jun 2007 10:40:53 +0000 (10:40 +0000)
committerdes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 15 Jun 2007 10:40:53 +0000 (10:40 +0000)
wording, constify varnish_name, move default name logic into VSL_Open*().

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1525 d4fa192b-c00b-0410-8231-f00ffab90ce4

15 files changed:
varnish-cache/bin/varnishd/mgt_param.c
varnish-cache/bin/varnishd/varnishd.1
varnish-cache/bin/varnishd/varnishd.c
varnish-cache/bin/varnishhist/varnishhist.1
varnish-cache/bin/varnishhist/varnishhist.c
varnish-cache/bin/varnishlog/varnishlog.1
varnish-cache/bin/varnishlog/varnishlog.c
varnish-cache/bin/varnishncsa/varnishncsa.1
varnish-cache/bin/varnishncsa/varnishncsa.c
varnish-cache/bin/varnishstat/varnishstat.1
varnish-cache/bin/varnishstat/varnishstat.c
varnish-cache/bin/varnishtop/varnishtop.1
varnish-cache/bin/varnishtop/varnishtop.c
varnish-cache/include/varnishapi.h
varnish-cache/lib/libvarnishapi/shmlog.c

index 3d59ad291ba8f05fdbff1b59caec3b06a9f85387..c2a8501864041ddd3a95dbc0a48666ea620c3f1c 100644 (file)
@@ -507,7 +507,7 @@ tweak_name(struct cli *cli, struct parspec *par, const char* arg)
        char *old_path;
        int renaming;
        (void)par;
-       
+
        if (arg != NULL) {
                /* Check that the new name follows hostname convention */
                /* [a-zA-Z0-9.-] */
@@ -518,7 +518,7 @@ tweak_name(struct cli *cli, struct parspec *par, const char* arg)
                if (stat(path, &st)) {
                        if (renaming) {
                                if (renaming && rename(old_path, path)) {
-                                       cli_out(cli, 
+                                       cli_out(cli,
                                            "Error: Directory %s could not be "
                                            "renamed to %s",
                                            old_path, path);
@@ -578,12 +578,12 @@ tweak_name(struct cli *cli, struct parspec *par, const char* arg)
  */
 static struct parspec parspec[] = {
        { "user", tweak_user,
-               "The unprivileged user to run as.  Setting this will "
+               "The unprivileged user to run as.  Setting this will "
                "also set \"group\" to the specified user's primary group.\n"
                MUST_RESTART,
                "nobody" },
        { "group", tweak_group,
-               "The unprivileged group to run as.\n"
+               "The unprivileged group to run as.\n"
                MUST_RESTART,
                "nogroup" },
        { "default_ttl", tweak_default_ttl,
@@ -734,7 +734,7 @@ static struct parspec parspec[] = {
                "naming conventions. Makes it possible to run "
                "multiple varnishd instances on one server.\n"
                EXPERIMENTAL,
-               "hostname"}, 
+               "hostname" },
        { NULL, NULL, NULL }
 };
 
index f42020bd80b49305dbfe099cc9161f87c63a24c2..0a822145e3ba9f92c3af6abf4a14515061c7a388 100644 (file)
@@ -28,7 +28,7 @@
 .\"
 .\" $Id$
 .\"
-.Dd May 30, 2007
+.Dd June 15, 2007
 .Dt VARNISHD 1
 .Os
 .Sh NAME
@@ -129,9 +129,10 @@ See
 .Sx Hash Algorithms
 for a list of supported algorithms.
 .It Fl n
-Specify a name for this instance. If 
-.Fl n
-is not specified, hostname is used. Files will be stored in /tmp/<name>/
+Specify a name for this instance.
+This is a shortcut for specifying the
+.Va name
+run-time parameter.
 .It Fl P Ar file
 Write the process's PID to the specified
 .Ar file .
@@ -401,6 +402,14 @@ The default is 0.0.0.0:80.
 The depth of the TCP listen queue.
 .Pp
 The default is 512.
+.It Va name
+The name of this
+.Nm
+instance.
+All temporary files are stored in
+.Pa /tmp/ Ns Va name .
+.Pp
+The default is the hostname.
 .It Va overflow_max
 The maximum depth of the overflow queue as a percentage of
 .Va thread_pool_max .
@@ -499,11 +508,6 @@ Note that this will generate large amounts of log data.
 .Pp
 The default is
 .Dv off .
-.It Va name
-The name if this varnishd instance. All temporary files are stored in
-/tmp/<name>/
-.Pp
-The default is the hostname
 .El
 .Sh SEE ALSO
 .Xr varnishlog 1 ,
index a639bbb1485497a952b20f5b3e49000ad179f0eb..f5cc3cf53485c44e6aefc2662614cabe77324683 100644 (file)
@@ -403,7 +403,6 @@ main(int argc, char *argv[])
        const char *b_arg = NULL;
        const char *f_arg = NULL;
        const char *h_arg = "classic";
-       char *n_arg = NULL;
        const char *P_arg = NULL;
        const char *s_arg = "file";
        const char *T_arg = NULL;
@@ -452,7 +451,7 @@ main(int argc, char *argv[])
                        h_arg = optarg;
                        break;
                case 'n':
-                       n_arg = optarg;
+                       MCF_ParamSet(cli, "name", optarg);
                        break;
                case 'P':
                        P_arg = optarg;
@@ -504,13 +503,7 @@ main(int argc, char *argv[])
                fprintf(stderr, "One of -b or -f must be specified\n");
                usage();
        }
-       
-       if (n_arg == NULL) {
-               n_arg = malloc(HOST_NAME_MAX+1);
-               gethostname(n_arg, HOST_NAME_MAX+1);
-       }
-       MCF_ParamSet(cli, "name", n_arg);
-       
+
        if (P_arg && (pfh = vpf_open(P_arg, 0600, NULL)) == NULL) {
                perror(P_arg);
                exit(1);
index 45205f369b1673dec01f2a3b9aaf6a0e22181c4a..5a4cf2fe5cb669387deb0233135f8a841872d40f 100644 (file)
@@ -28,7 +28,7 @@
 .\"
 .\" $Id$
 .\"
-.Dd September 20, 2006
+.Dd June 15, 2007
 .Dt VARNISHHIST 1
 .Os
 .Sh NAME
@@ -102,11 +102,12 @@ nor
 .Fl i
 is specified, all log entries are included.
 .It Fl n
-Specify the name of the varnishd to get logs from. If 
+Specifies the name of the
+.Nm varnishd
+instance to get logs from.
+If
 .Fl n
-is not specified, hostname is used. If varnishd was started with
-.Fl n
-the option must be specified.
+is not specified, the host name is used.
 .It Fl r Ar file
 Read log entries from
 .Ar file
index dfe71876f6c5be92d97671222dbb54b2086b3451..d9a600244d2115218906471b71cf66880e84a227 100644 (file)
@@ -180,7 +180,7 @@ main(int argc, char **argv)
 {
        int i, c, x;
        struct VSL_data *vd;
-       char *n_arg = NULL;
+       const char *n_arg = NULL;
 
        vd = VSL_New();
 
@@ -202,11 +202,6 @@ main(int argc, char **argv)
                }
        }
 
-       if (n_arg == NULL) {
-               n_arg = malloc(HOST_NAME_MAX+1);
-               gethostname(n_arg, HOST_NAME_MAX+1);
-       }
-       
        if (VSL_OpenLog(vd, n_arg))
                exit (1);
 
index a5bb9f7664c47f31ad595049ab7224d3ef5dd519..9e8387facbe70ad3d979e0a515cefa76a3658b0d 100644 (file)
@@ -28,7 +28,7 @@
 .\"
 .\" $Id$
 .\"
-.Dd May 11, 2007
+.Dd June 15, 2007
 .Dt VARNISHLOG 1
 .Os
 .Sh NAME
@@ -108,11 +108,12 @@ nor
 .Fl i
 is specified, all log entries are included.
 .It Fl n
-Specify the name of the varnishd to get logs from. If 
-.Fl n
-is not specified, hostname is used. If varnishd was started with
+Specifies the name of the
+.Nm varnishd
+instance to get logs from.
+If
 .Fl n
-the option must be specified.
+is not specified, the host name is used.
 .It Fl o
 Group log entries by request ID.
 This has no effect when writing to a file using the
index 2b6e2f17b3c02e1748196763c4da31d9b702e3a1..b0400ff0bb4de3b645d309a2feedd7cdb38a0079 100644 (file)
@@ -285,7 +285,7 @@ main(int argc, char **argv)
        int a_flag = 0, D_flag = 0, o_flag = 0;
        const char *P_arg = NULL;
        const char *w_arg = NULL;
-       char *n_arg = NULL;
+       const char *n_arg = NULL;
        struct pidfh *pfh = NULL;
        struct VSL_data *vd;
 
@@ -334,11 +334,6 @@ main(int argc, char **argv)
        if (o_flag && w_arg != NULL)
                usage();
 
-       if (n_arg == NULL) {
-               n_arg = malloc(HOST_NAME_MAX+1);
-               gethostname(n_arg, HOST_NAME_MAX+1);
-       }
-
        if (VSL_OpenLog(vd, n_arg))
                exit(1);
 
index 3569b1ed711dc2f65f624ddc2650d6a0bbef7665..d1c76056d46dec69a72662f2baf326657b36b861 100644 (file)
@@ -28,7 +28,7 @@
 .\"
 .\" $Id$
 .\"
-.Dd April 21, 2007
+.Dd June 15, 2007
 .Dt VARNISHNCSA 1
 .Os
 .Sh NAME
@@ -103,11 +103,12 @@ nor
 .Fl i
 is specified, all log entries are included.
 .It Fl n
-Specify the name of the varnishd to get logs from. If 
-.Fl n
-is not specified, hostname is used. If varnishd was started with
+Specifies the name of the
+.Nm varnishd
+instance to get logs from.
+If
 .Fl n
-the option must be specified.
+is not specified, the host name is used.
 .It Fl r Ar file
 Read log entries from
 .Ar file
index 8d2308a6171fe3fb5e833efd5b6057d63eef3d3e..926422927f13acafca69320d6dd0322cf7b5d3b9 100644 (file)
@@ -444,7 +444,7 @@ main(int argc, char *argv[])
        int i, c;
        struct VSL_data *vd;
        const char *ofn = NULL;
-       char *n_arg = NULL;
+       const char *n_arg = NULL;
        int append = 0;
        FILE *of;
 
@@ -475,11 +475,6 @@ main(int argc, char *argv[])
                        usage();
                }
        }
-       
-       if (n_arg == NULL) {
-               n_arg = malloc(HOST_NAME_MAX+1);
-               gethostname(n_arg, HOST_NAME_MAX+1);
-       }
 
        if (VSL_OpenLog(vd, n_arg))
                exit(1);
index 42c2ca4cbc8f0265fa430c2bd5c23c2df2e27f84..6e9310e85840dcf212b2131f2bce99beab757c4e 100644 (file)
@@ -28,7 +28,7 @@
 .\"
 .\" $Id$
 .\"
-.Dd September 20, 2006
+.Dd June 15, 2007
 .Dt VARNISHSTAT 1
 .Os
 .Sh NAME
@@ -53,11 +53,12 @@ The following options are available:
 Instead of presenting of a continuously updated display, print the
 statistics once and exit.
 .It Fl n
-Specify the name of the varnishd to get logs from. If 
+Specifies the name of the
+.Nm varnishd
+instance to get logs from.
+If
 .Fl n
-is not specified, hostname is used. If varnishd was started with
-.Fl n
-the option must be specified.
+is not specified, the host name is used.
 .It Fl V
 Display the version number and exit.
 .It Fl w Ar delay
index 43784ab07eec2ddd2fc6c87628eed69cb6ee5839..7486f05ed6964ea055c9a23fd0fc7f0565c5f5d4 100644 (file)
@@ -141,7 +141,7 @@ main(int argc, char **argv)
        int c;
        struct varnish_stats *VSL_stats;
        int delay = 1, once = 0;
-       char *n_arg = NULL;
+       const char *n_arg = NULL;
 
        while ((c = getopt(argc, argv, "1n:Vw:")) != -1) {
                switch (c) {
@@ -161,15 +161,9 @@ main(int argc, char **argv)
                        usage();
                }
        }
-       
-       if (n_arg == NULL) {
-               n_arg = malloc(HOST_NAME_MAX+1);
-               gethostname(n_arg, HOST_NAME_MAX+1);
-       }
 
-       if (!(VSL_stats = VSL_OpenStats(n_arg))) {
+       if ((VSL_stats = VSL_OpenStats(n_arg)) == NULL)
                exit(1);
-       }
 
        if (!once) {
                do_curses(VSL_stats, delay);
index 961d028f6a5fa62ce46817b64202a926db34caa0..6c3d685fb4a6f1a80a575b71b9305e107a0eabba 100644 (file)
@@ -28,7 +28,7 @@
 .\"
 .\" $Id$
 .\"
-.Dd September 20, 2006
+.Dd June 15, 2007
 .Dt VARNISHTOP 1
 .Os
 .Sh NAME
@@ -118,11 +118,12 @@ nor
 .Fl i
 is specified, all log entries are included.
 .It Fl n
-Specify the name of the varnishd to get logs from. If 
+Specifies the name of the
+.Nm varnishd
+instance to get logs from.
+If
 .Fl n
-is not specified, hostname is used. If varnishd was started with
-.Fl n
-the option must be specified.
+is not specified, the host name is used.
 .It Fl r Ar file
 Read log entries from
 .Ar file
index dcbb11b70bed2968080bda4edd95b9ad45b57a76..462139ef8a95bd504cf47e023b59a4e04dfc7344 100644 (file)
@@ -113,7 +113,7 @@ main(int argc, char **argv)
        unsigned u, v;
        struct top *tp, *tp2;
        int f_flag = 0;
-       char *n_arg = NULL;
+       const char *n_arg = NULL;
 
        vd = VSL_New();
 
@@ -140,11 +140,6 @@ main(int argc, char **argv)
                        usage();
                }
        }
-       
-       if (n_arg == NULL) {
-               n_arg = malloc(HOST_NAME_MAX+1);
-               gethostname(n_arg, HOST_NAME_MAX+1);
-       }
 
        if (VSL_OpenLog(vd, n_arg))
                exit (1);
index 2f2aa9f2209ac7be3f10a10afe49232ad25e1b64..e3854e348a327c2a2fb5d385fa3192b3f35eef6c 100644 (file)
@@ -50,12 +50,12 @@ vsl_handler VSL_H_Print;
 struct VSL_data;
 struct VSL_data *VSL_New(void);
 void VSL_Select(struct VSL_data *vd, unsigned tag);
-int VSL_OpenLog(struct VSL_data *vd, char *varnish_name);
+int VSL_OpenLog(struct VSL_data *vd, const char *varnish_name);
 void VSL_NonBlocking(struct VSL_data *vd, int nb);
 int VSL_Dispatch(struct VSL_data *vd, vsl_handler *func, void *priv);
 int VSL_NextLog(struct VSL_data *lh, unsigned char **pp);
 int VSL_Arg(struct VSL_data *vd, int arg, const char *opt);
-struct varnish_stats *VSL_OpenStats(char *varnish_name);
+struct varnish_stats *VSL_OpenStats(const char *varnish_name);
 extern const char *VSL_tags[256];
 
 /* varnish_debug.c */
index 4dcb1c85fa81a890f890f813f9f6ffe2d59bfc21..090ef2b06c87cd71a3674116b8603b4f60b60abe 100644 (file)
@@ -102,7 +102,7 @@ const char *VSL_tags[256] = {
 /*--------------------------------------------------------------------*/
 
 static int
-vsl_shmem_map(char* varnish_name)
+vsl_shmem_map(const char *varnish_name)
 {
        int i;
        struct shmloghead slh;
@@ -170,16 +170,21 @@ VSL_Select(struct VSL_data *vd, unsigned tag)
 /*--------------------------------------------------------------------*/
 
 int
-VSL_OpenLog(struct VSL_data *vd, char *varnish_name)
+VSL_OpenLog(struct VSL_data *vd, const char *varnish_name)
 {
+       char hostname[1024];
        unsigned char *p;
 
        CHECK_OBJ_NOTNULL(vd, VSL_MAGIC);
        if (vd->fi != NULL)
                return (0);
 
+       if (varnish_name == NULL) {
+               gethostname(hostname, sizeof hostname);
+               varnish_name = hostname;
+       }
        if (vsl_shmem_map(varnish_name))
-               return (1);
+               return (-1);
 
        vd->head = vsl_lh;
        vd->logstart = (unsigned char *)vsl_lh + vsl_lh->start;
@@ -477,7 +482,7 @@ VSL_Arg(struct VSL_data *vd, int arg, const char *opt)
 }
 
 struct varnish_stats *
-VSL_OpenStats(char *varnish_name)
+VSL_OpenStats(const char *varnish_name)
 {
 
        if (vsl_shmem_map(varnish_name))