Mailing List Archive

r1525 - in trunk/varnish-cache: bin/varnishd bin/varnishhist bin/varnishlog bin/varnishncsa bin/varnishstat bin/varnishtop include lib/libvarnishapi
Author: des
Date: 2007-06-15 12:40:53 +0200 (Fri, 15 Jun 2007)
New Revision: 1525

Modified:
trunk/varnish-cache/bin/varnishd/mgt_param.c
trunk/varnish-cache/bin/varnishd/varnishd.1
trunk/varnish-cache/bin/varnishd/varnishd.c
trunk/varnish-cache/bin/varnishhist/varnishhist.1
trunk/varnish-cache/bin/varnishhist/varnishhist.c
trunk/varnish-cache/bin/varnishlog/varnishlog.1
trunk/varnish-cache/bin/varnishlog/varnishlog.c
trunk/varnish-cache/bin/varnishncsa/varnishncsa.1
trunk/varnish-cache/bin/varnishncsa/varnishncsa.c
trunk/varnish-cache/bin/varnishstat/varnishstat.1
trunk/varnish-cache/bin/varnishstat/varnishstat.c
trunk/varnish-cache/bin/varnishtop/varnishtop.1
trunk/varnish-cache/bin/varnishtop/varnishtop.c
trunk/varnish-cache/include/varnishapi.h
trunk/varnish-cache/lib/libvarnishapi/shmlog.c
Log:
Slight improvements on Cecilie's commit: correct nroff style and man page
wording, constify varnish_name, move default name logic into VSL_Open*().


Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c 2007-06-15 09:27:29 UTC (rev 1524)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2007-06-15 10:40:53 UTC (rev 1525)
@@ -507,7 +507,7 @@
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 @@
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 @@
*/
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 @@
"naming conventions. Makes it possible to run "
"multiple varnishd instances on one server.\n"
EXPERIMENTAL,
- "hostname"},
+ "hostname" },
{ NULL, NULL, NULL }
};


Modified: trunk/varnish-cache/bin/varnishd/varnishd.1
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.1 2007-06-15 09:27:29 UTC (rev 1524)
+++ trunk/varnish-cache/bin/varnishd/varnishd.1 2007-06-15 10:40:53 UTC (rev 1525)
@@ -28,7 +28,7 @@
.\"
.\" $Id$
.\"
-.Dd May 30, 2007
+.Dd June 15, 2007
.Dt VARNISHD 1
.Os
.Sh NAME
@@ -129,9 +129,10 @@
.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 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 @@
.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 ,

Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c 2007-06-15 09:27:29 UTC (rev 1524)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c 2007-06-15 10:40:53 UTC (rev 1525)
@@ -403,7 +403,6 @@
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 @@
h_arg = optarg;
break;
case 'n':
- n_arg = optarg;
+ MCF_ParamSet(cli, "name", optarg);
break;
case 'P':
P_arg = optarg;
@@ -504,13 +503,7 @@
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);

Modified: trunk/varnish-cache/bin/varnishhist/varnishhist.1
===================================================================
--- trunk/varnish-cache/bin/varnishhist/varnishhist.1 2007-06-15 09:27:29 UTC (rev 1524)
+++ trunk/varnish-cache/bin/varnishhist/varnishhist.1 2007-06-15 10:40:53 UTC (rev 1525)
@@ -28,7 +28,7 @@
.\"
.\" $Id$
.\"
-.Dd September 20, 2006
+.Dd June 15, 2007
.Dt VARNISHHIST 1
.Os
.Sh NAME
@@ -102,11 +102,12 @@
.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

Modified: trunk/varnish-cache/bin/varnishhist/varnishhist.c
===================================================================
--- trunk/varnish-cache/bin/varnishhist/varnishhist.c 2007-06-15 09:27:29 UTC (rev 1524)
+++ trunk/varnish-cache/bin/varnishhist/varnishhist.c 2007-06-15 10:40:53 UTC (rev 1525)
@@ -180,7 +180,7 @@
{
int i, c, x;
struct VSL_data *vd;
- char *n_arg = NULL;
+ const char *n_arg = NULL;

vd = VSL_New();

@@ -202,11 +202,6 @@
}
}

- 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);


Modified: trunk/varnish-cache/bin/varnishlog/varnishlog.1
===================================================================
--- trunk/varnish-cache/bin/varnishlog/varnishlog.1 2007-06-15 09:27:29 UTC (rev 1524)
+++ trunk/varnish-cache/bin/varnishlog/varnishlog.1 2007-06-15 10:40:53 UTC (rev 1525)
@@ -28,7 +28,7 @@
.\"
.\" $Id$
.\"
-.Dd May 11, 2007
+.Dd June 15, 2007
.Dt VARNISHLOG 1
.Os
.Sh NAME
@@ -108,11 +108,12 @@
.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 o
Group log entries by request ID.
This has no effect when writing to a file using the

Modified: trunk/varnish-cache/bin/varnishlog/varnishlog.c
===================================================================
--- trunk/varnish-cache/bin/varnishlog/varnishlog.c 2007-06-15 09:27:29 UTC (rev 1524)
+++ trunk/varnish-cache/bin/varnishlog/varnishlog.c 2007-06-15 10:40:53 UTC (rev 1525)
@@ -285,7 +285,7 @@
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 @@
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);


Modified: trunk/varnish-cache/bin/varnishncsa/varnishncsa.1
===================================================================
--- trunk/varnish-cache/bin/varnishncsa/varnishncsa.1 2007-06-15 09:27:29 UTC (rev 1524)
+++ trunk/varnish-cache/bin/varnishncsa/varnishncsa.1 2007-06-15 10:40:53 UTC (rev 1525)
@@ -28,7 +28,7 @@
.\"
.\" $Id$
.\"
-.Dd April 21, 2007
+.Dd June 15, 2007
.Dt VARNISHNCSA 1
.Os
.Sh NAME
@@ -103,11 +103,12 @@
.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

Modified: trunk/varnish-cache/bin/varnishncsa/varnishncsa.c
===================================================================
--- trunk/varnish-cache/bin/varnishncsa/varnishncsa.c 2007-06-15 09:27:29 UTC (rev 1524)
+++ trunk/varnish-cache/bin/varnishncsa/varnishncsa.c 2007-06-15 10:40:53 UTC (rev 1525)
@@ -444,7 +444,7 @@
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 @@
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);

Modified: trunk/varnish-cache/bin/varnishstat/varnishstat.1
===================================================================
--- trunk/varnish-cache/bin/varnishstat/varnishstat.1 2007-06-15 09:27:29 UTC (rev 1524)
+++ trunk/varnish-cache/bin/varnishstat/varnishstat.1 2007-06-15 10:40:53 UTC (rev 1525)
@@ -28,7 +28,7 @@
.\"
.\" $Id$
.\"
-.Dd September 20, 2006
+.Dd June 15, 2007
.Dt VARNISHSTAT 1
.Os
.Sh NAME
@@ -53,11 +53,12 @@
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

Modified: trunk/varnish-cache/bin/varnishstat/varnishstat.c
===================================================================
--- trunk/varnish-cache/bin/varnishstat/varnishstat.c 2007-06-15 09:27:29 UTC (rev 1524)
+++ trunk/varnish-cache/bin/varnishstat/varnishstat.c 2007-06-15 10:40:53 UTC (rev 1525)
@@ -141,7 +141,7 @@
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 @@
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);

Modified: trunk/varnish-cache/bin/varnishtop/varnishtop.1
===================================================================
--- trunk/varnish-cache/bin/varnishtop/varnishtop.1 2007-06-15 09:27:29 UTC (rev 1524)
+++ trunk/varnish-cache/bin/varnishtop/varnishtop.1 2007-06-15 10:40:53 UTC (rev 1525)
@@ -28,7 +28,7 @@
.\"
.\" $Id$
.\"
-.Dd September 20, 2006
+.Dd June 15, 2007
.Dt VARNISHTOP 1
.Os
.Sh NAME
@@ -118,11 +118,12 @@
.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

Modified: trunk/varnish-cache/bin/varnishtop/varnishtop.c
===================================================================
--- trunk/varnish-cache/bin/varnishtop/varnishtop.c 2007-06-15 09:27:29 UTC (rev 1524)
+++ trunk/varnish-cache/bin/varnishtop/varnishtop.c 2007-06-15 10:40:53 UTC (rev 1525)
@@ -113,7 +113,7 @@
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 @@
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);

Modified: trunk/varnish-cache/include/varnishapi.h
===================================================================
--- trunk/varnish-cache/include/varnishapi.h 2007-06-15 09:27:29 UTC (rev 1524)
+++ trunk/varnish-cache/include/varnishapi.h 2007-06-15 10:40:53 UTC (rev 1525)
@@ -50,12 +50,12 @@
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 */

Modified: trunk/varnish-cache/lib/libvarnishapi/shmlog.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2007-06-15 09:27:29 UTC (rev 1524)
+++ trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2007-06-15 10:40:53 UTC (rev 1525)
@@ -102,7 +102,7 @@
/*--------------------------------------------------------------------*/

static int
-vsl_shmem_map(char* varnish_name)
+vsl_shmem_map(const char *varnish_name)
{
int i;
struct shmloghead slh;
@@ -170,16 +170,21 @@
/*--------------------------------------------------------------------*/

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 @@
}

struct varnish_stats *
-VSL_OpenStats(char *varnish_name)
+VSL_OpenStats(const char *varnish_name)
{

if (vsl_shmem_map(varnish_name))