Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
e928e75a
Commit
e928e75a
authored
Nov 14, 2013
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup varnishd arguments, usage() and argument diagnostics.
parent
18fd12a2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
68 deletions
+48
-68
common.h
bin/varnishd/common/common.h
+1
-1
mgt_main.c
bin/varnishd/mgt/mgt_main.c
+47
-67
No files found.
bin/varnishd/common/common.h
View file @
e928e75a
...
@@ -94,7 +94,7 @@ void mgt_child_inherit(int fd, const char *what);
...
@@ -94,7 +94,7 @@ void mgt_child_inherit(int fd, const char *what);
do { \
do { \
fprintf(stderr, "Error: " __VA_ARGS__); \
fprintf(stderr, "Error: " __VA_ARGS__); \
exit(2); \
exit(2); \
} while (0)
;
} while (0)
#define NEEDLESS_RETURN(foo) return (foo)
#define NEEDLESS_RETURN(foo) return (foo)
...
...
bin/varnishd/mgt/mgt_main.c
View file @
e928e75a
...
@@ -152,6 +152,7 @@ usage(void)
...
@@ -152,6 +152,7 @@ usage(void)
fprintf
(
stderr
,
FMT
,
"-d"
,
"debug"
);
fprintf
(
stderr
,
FMT
,
"-d"
,
"debug"
);
fprintf
(
stderr
,
FMT
,
"-f file"
,
"VCL script"
);
fprintf
(
stderr
,
FMT
,
"-f file"
,
"VCL script"
);
fprintf
(
stderr
,
FMT
,
"-F"
,
"Run in foreground"
);
fprintf
(
stderr
,
FMT
,
"-F"
,
"Run in foreground"
);
fprintf
(
stderr
,
FMT
,
"-g group"
,
"Privilege separation group id"
);
fprintf
(
stderr
,
FMT
,
"-h kind[,hashoptions]"
,
"Hash specification"
);
fprintf
(
stderr
,
FMT
,
"-h kind[,hashoptions]"
,
"Hash specification"
);
fprintf
(
stderr
,
FMT
,
""
,
" -h critbit [default]"
);
fprintf
(
stderr
,
FMT
,
""
,
" -h critbit [default]"
);
fprintf
(
stderr
,
FMT
,
""
,
" -h simple_list"
);
fprintf
(
stderr
,
FMT
,
""
,
" -h simple_list"
);
...
@@ -458,7 +459,7 @@ main(int argc, char * const *argv)
...
@@ -458,7 +459,7 @@ main(int argc, char * const *argv)
cli_check
(
cli
);
cli_check
(
cli
);
while
((
o
=
getopt
(
argc
,
argv
,
while
((
o
=
getopt
(
argc
,
argv
,
"a:b:Cdf:Fg:h:i:l:
L:M:n:P:p:r:S:s:T:t:u:Vx:w
:"
))
!=
-
1
)
"a:b:Cdf:Fg:h:i:l:
M:n:P:p:r:S:s:T:u:Vx
:"
))
!=
-
1
)
switch
(
o
)
{
switch
(
o
)
{
case
'a'
:
case
'a'
:
MCF_ParamSet
(
cli
,
"listen_address"
,
optarg
);
MCF_ParamSet
(
cli
,
"listen_address"
,
optarg
);
...
@@ -560,8 +561,6 @@ main(int argc, char * const *argv)
...
@@ -560,8 +561,6 @@ main(int argc, char * const *argv)
}
}
usage
();
usage
();
break
;
break
;
case
'w'
:
ARGV_ERR
(
"-w has been removed, use -p instead
\n
"
);
default:
default:
usage
();
usage
();
}
}
...
@@ -571,97 +570,79 @@ main(int argc, char * const *argv)
...
@@ -571,97 +570,79 @@ main(int argc, char * const *argv)
mgt_vcc_init
();
mgt_vcc_init
();
if
(
argc
!=
0
)
{
if
(
argc
!=
0
)
fprintf
(
stderr
,
"Too many arguments (%s...)
\n
"
,
argv
[
0
]);
ARGV_ERR
(
"Too many arguments (%s...)
\n
"
,
argv
[
0
]);
usage
();
}
/* XXX: we can have multiple CLI actions above, is this enough ? */
/* XXX: we can have multiple CLI actions above, is this enough ? */
if
(
cli
[
0
].
result
!=
CLIS_OK
)
{
if
(
cli
[
0
].
result
!=
CLIS_OK
)
{
fprintf
(
stderr
,
"Parameter errors:
\n
"
);
AZ
(
VSB_finish
(
cli
[
0
].
sb
));
AZ
(
VSB_finish
(
cli
[
0
].
sb
));
fprintf
(
stderr
,
"%s
\n
"
,
VSB_data
(
cli
[
0
].
sb
));
ARGV_ERR
(
"Failed parameter creation:
\n
%s
\n
"
,
exit
(
1
);
VSB_data
(
cli
[
0
].
sb
)
);
}
}
if
(
d_flag
&&
F_flag
)
{
if
(
d_flag
&&
F_flag
)
fprintf
(
stderr
,
"Only one of -d or -F can be specified
\n
"
);
ARGV_ERR
(
"Only one of -d or -F can be specified
\n
"
);
usage
();
}
if
(
b_arg
!=
NULL
&&
f_arg
!=
NULL
)
ARGV_ERR
(
"Only one of -b or -f can be specified
\n
"
);
if
(
b_arg
!=
NULL
&&
f_arg
!=
NULL
)
{
fprintf
(
stderr
,
"Only one of -b or -f can be specified
\n
"
);
usage
();
}
if
(
T_arg
==
NULL
&&
d_flag
==
0
&&
b_arg
==
NULL
&&
if
(
T_arg
==
NULL
&&
d_flag
==
0
&&
b_arg
==
NULL
&&
f_arg
==
NULL
&&
M_arg
==
NULL
)
{
f_arg
==
NULL
&&
M_arg
==
NULL
)
fprintf
(
stderr
,
ARGV_ERR
(
"At least one of -d, -b, -f, -M or -T "
"At least one of -d, -b, -f, -M or -T "
"must be specified
\n
"
);
"must be specified
\n
"
);
usage
();
}
if
(
S_arg
!=
NULL
&&
*
S_arg
==
'\0'
)
if
(
S_arg
!=
NULL
&&
*
S_arg
==
'\0'
)
fprintf
(
stderr
,
fprintf
(
stderr
,
"Warning: Empty -S argument, no CLI authentication.
\n
"
);
"Warning: Empty -S argument, no CLI authentication.
\n
"
);
else
if
(
S_arg
!=
NULL
)
{
o
=
open
(
S_arg
,
O_RDONLY
,
0
);
if
(
o
<
0
)
ARGV_ERR
(
"Cannot open -S file (%s): %s
\n
"
,
S_arg
,
strerror
(
errno
));
AZ
(
close
(
o
));
}
if
(
f_arg
!=
NULL
)
{
if
(
f_arg
!=
NULL
)
{
vcl
=
VFIL_readfile
(
NULL
,
f_arg
,
NULL
);
vcl
=
VFIL_readfile
(
NULL
,
f_arg
,
NULL
);
if
(
vcl
==
NULL
)
{
if
(
vcl
==
NULL
)
fprintf
(
stderr
,
"Cannot read '%s'
: %s
\n
"
,
ARGV_ERR
(
"Cannot read -f file (%s)
: %s
\n
"
,
f_arg
,
strerror
(
errno
));
f_arg
,
strerror
(
errno
));
exit
(
1
);
}
}
}
if
(
VIN_N_Arg
(
n_arg
,
&
heritage
.
name
,
&
dirname
,
NULL
)
!=
0
)
{
if
(
VIN_N_Arg
(
n_arg
,
&
heritage
.
name
,
&
dirname
,
NULL
)
!=
0
)
fprintf
(
stderr
,
"Invalid instance name: %s
\n
"
,
ARGV_ERR
(
"Invalid instance (-n) name: %s
\n
"
,
strerror
(
errno
));
strerror
(
errno
));
exit
(
1
);
}
if
(
i_arg
!=
NULL
)
{
if
(
i_arg
!=
NULL
&&
if
(
snprintf
(
heritage
.
identity
,
sizeof
heritage
.
identity
,
snprintf
(
heritage
.
identity
,
sizeof
heritage
.
identity
,
"%s"
,
i_arg
)
"%s"
,
i_arg
)
>
sizeof
heritage
.
identity
)
{
>
sizeof
heritage
.
identity
)
fprintf
(
stderr
,
"Invalid identity
name: %s
\n
"
,
ARGV_ERR
(
"Invalid identity (-i)
name: %s
\n
"
,
strerror
(
ENAMETOOLONG
));
strerror
(
ENAMETOOLONG
));
exit
(
1
);
}
}
if
(
n_arg
!=
NULL
)
if
(
n_arg
!=
NULL
)
openlog
(
n_arg
,
LOG_PID
,
LOG_LOCAL0
);
/* XXX: i_arg ? */
openlog
(
n_arg
,
LOG_PID
,
LOG_LOCAL0
);
/* XXX: i_arg ? */
else
else
openlog
(
"varnishd"
,
LOG_PID
,
LOG_LOCAL0
);
openlog
(
"varnishd"
,
LOG_PID
,
LOG_LOCAL0
);
if
(
mkdir
(
dirname
,
0755
)
<
0
&&
errno
!=
EEXIST
)
{
if
(
mkdir
(
dirname
,
0755
)
<
0
&&
errno
!=
EEXIST
)
fprintf
(
stderr
,
"Cannot create working directory '%s': %s
\n
"
,
ARGV_ERR
(
"Cannot create working directory '%s': %s
\n
"
,
dirname
,
strerror
(
errno
));
dirname
,
strerror
(
errno
));
exit
(
1
);
}
if
(
chdir
(
dirname
)
<
0
)
{
if
(
chdir
(
dirname
)
<
0
)
fprintf
(
stderr
,
"Cannot change to working directory '%s': %s
\n
"
,
ARGV_ERR
(
"Cannot change to working directory '%s': %s
\n
"
,
dirname
,
strerror
(
errno
));
dirname
,
strerror
(
errno
));
exit
(
1
);
}
fd
=
open
(
"_.testfile"
,
O_RDWR
|
O_CREAT
|
O_EXCL
,
0600
);
fd
=
open
(
"_.testfile"
,
O_RDWR
|
O_CREAT
|
O_EXCL
,
0600
);
if
(
fd
<
0
)
{
if
(
fd
<
0
)
fprintf
(
stderr
,
"Cannot create test-file in %s (%s)
\n
"
,
ARGV_ERR
(
"Error: Cannot create test-file in %s (%s)
\n
"
"Check permissions (or delete old directory)
\n
"
,
dirname
,
strerror
(
errno
));
dirname
,
strerror
(
errno
));
fprintf
(
stderr
,
"Check permissions (or delete old directory)
\n
"
);
exit
(
1
);
}
AZ
(
close
(
fd
));
AZ
(
close
(
fd
));
AZ
(
unlink
(
"_.testfile"
));
AZ
(
unlink
(
"_.testfile"
));
/* XXX: should this be relative to the -n arg ? */
/* XXX: should this be relative to the -n arg ? */
if
(
P_arg
&&
(
pfh
=
VPF_Open
(
P_arg
,
0644
,
NULL
))
==
NULL
)
{
if
(
P_arg
&&
(
pfh
=
VPF_Open
(
P_arg
,
0644
,
NULL
))
==
NULL
)
perror
(
P_arg
);
ARGV_ERR
(
"Could not open pid/lock (-P) file (%s): %s
\n
"
,
exit
(
1
);
P_arg
,
strerror
(
errno
));
}
if
(
b_arg
!=
NULL
||
f_arg
!=
NULL
)
if
(
b_arg
!=
NULL
||
f_arg
!=
NULL
)
if
(
mgt_vcc_default
(
b_arg
,
f_arg
,
vcl
,
C_flag
))
if
(
mgt_vcc_default
(
b_arg
,
f_arg
,
vcl
,
C_flag
))
...
@@ -671,11 +652,8 @@ main(int argc, char * const *argv)
...
@@ -671,11 +652,8 @@ main(int argc, char * const *argv)
exit
(
0
);
exit
(
0
);
if
(
!
d_flag
)
{
if
(
!
d_flag
)
{
if
(
MGT_open_sockets
())
{
if
(
MGT_open_sockets
())
fprintf
(
stderr
,
ARGV_ERR
(
"Failed to open (any) accept sockets.
\n
"
);
"Failed to open (any) accept sockets.
\n
"
);
exit
(
1
);
}
MGT_close_sockets
();
MGT_close_sockets
();
}
}
...
@@ -695,15 +673,17 @@ main(int argc, char * const *argv)
...
@@ -695,15 +673,17 @@ main(int argc, char * const *argv)
if
(
!
d_flag
&&
!
F_flag
)
if
(
!
d_flag
&&
!
F_flag
)
AZ
(
varnish_daemon
(
1
,
0
));
AZ
(
varnish_daemon
(
1
,
0
));
if
(
pfh
!=
NULL
&&
VPF_Write
(
pfh
))
/**************************************************************
fprintf
(
stderr
,
"NOTE: Could not write PID file
\n
"
);
* After this point diagnostics will only be seen with -d
*/
assert
(
pfh
==
NULL
||
!
VPF_Write
(
pfh
));
if
(
d_flag
)
if
(
d_flag
)
fprintf
(
stderr
,
"Platform: %s
\n
"
,
VSB_data
(
vident
)
+
1
);
fprintf
(
stderr
,
"Platform: %s
\n
"
,
VSB_data
(
vident
)
+
1
);
syslog
(
LOG_NOTICE
,
"Platform: %s
\n
"
,
VSB_data
(
vident
)
+
1
);
syslog
(
LOG_NOTICE
,
"Platform: %s
\n
"
,
VSB_data
(
vident
)
+
1
);
/* Do this again after debugstunt and daemon has run */
mgt_pid
=
getpid
();
/* daemon() changed this */
mgt_pid
=
getpid
();
mgt_evb
=
vev_new_base
();
mgt_evb
=
vev_new_base
();
XXXAN
(
mgt_evb
);
XXXAN
(
mgt_evb
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment