Commit 3d9c0909 authored by Dag Erling Smørgrav's avatar Dag Erling Smørgrav

Make SIGHUP work: VSL_Dispatch() will not return as long as it has data

to feed to h_ncsa(), so it is up to h_ncsa() to interrupt it if reopen
is non-zero.

Also remove a superfluous call to VSL_Arg() as was previously done in
varnishlog(1).


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2270 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 936ecda1
...@@ -80,6 +80,8 @@ ...@@ -80,6 +80,8 @@
#include "shmlog.h" #include "shmlog.h"
#include "varnishapi.h" #include "varnishapi.h"
static volatile sig_atomic_t reopen;
static struct logline { static struct logline {
char *df_H; /* %H, Protocol version */ char *df_H; /* %H, Protocol version */
char *df_Host; /* %{Host}i */ char *df_Host; /* %{Host}i */
...@@ -187,7 +189,7 @@ h_ncsa(void *priv, enum shmlogtag tag, unsigned fd, ...@@ -187,7 +189,7 @@ h_ncsa(void *priv, enum shmlogtag tag, unsigned fd,
end = ptr + len; end = ptr + len;
if (!(spec & VSL_S_CLIENT || spec & VSL_S_BACKEND)) if (!(spec & VSL_S_CLIENT || spec & VSL_S_BACKEND))
return (0); return (reopen);
if (fd >= nll) { if (fd >= nll) {
struct logline **newll = ll; struct logline **newll = ll;
...@@ -315,11 +317,11 @@ h_ncsa(void *priv, enum shmlogtag tag, unsigned fd, ...@@ -315,11 +317,11 @@ h_ncsa(void *priv, enum shmlogtag tag, unsigned fd,
} }
if ((spec & VSL_S_CLIENT) && tag != SLT_ReqEnd) if ((spec & VSL_S_CLIENT) && tag != SLT_ReqEnd)
return (0); return (reopen);
if ((spec & VSL_S_BACKEND) && tag != SLT_BackendReuse && if ((spec & VSL_S_BACKEND) && tag != SLT_BackendReuse &&
(tag != SLT_BackendClose || lp->df_Uq)) (tag != SLT_BackendClose || lp->df_Uq))
return (0); return (reopen);
if (tag == SLT_ReqEnd) { if (tag == SLT_ReqEnd) {
if (sscanf(ptr, "%*u %*u.%*u %ld.", &l) != 1) if (sscanf(ptr, "%*u %*u.%*u %ld.", &l) != 1)
...@@ -407,13 +409,11 @@ h_ncsa(void *priv, enum shmlogtag tag, unsigned fd, ...@@ -407,13 +409,11 @@ h_ncsa(void *priv, enum shmlogtag tag, unsigned fd,
#undef freez #undef freez
lp->bogus = 0; lp->bogus = 0;
return (0); return (reopen);
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static volatile sig_atomic_t reopen;
static void static void
sighup(int sig) sighup(int sig)
{ {
...@@ -447,7 +447,7 @@ usage(void) ...@@ -447,7 +447,7 @@ usage(void)
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int i, c; int c;
int a_flag = 0, D_flag = 0; int a_flag = 0, D_flag = 0;
const char *n_arg = NULL; const char *n_arg = NULL;
const char *P_arg = NULL; const char *P_arg = NULL;
...@@ -459,11 +459,6 @@ main(int argc, char *argv[]) ...@@ -459,11 +459,6 @@ main(int argc, char *argv[])
vd = VSL_New(); vd = VSL_New();
while ((c = getopt(argc, argv, VSL_ARGS "aDn:P:Vw:")) != -1) { while ((c = getopt(argc, argv, VSL_ARGS "aDn:P:Vw:")) != -1) {
i = VSL_Arg(vd, c, optarg);
if (i < 0)
exit (1);
if (i > 0)
continue;
switch (c) { switch (c) {
case 'a': case 'a':
a_flag = 1; a_flag = 1;
...@@ -516,7 +511,7 @@ main(int argc, char *argv[]) ...@@ -516,7 +511,7 @@ main(int argc, char *argv[])
of = stdout; of = stdout;
} }
while (VSL_Dispatch(vd, h_ncsa, of) == 0) { while (VSL_Dispatch(vd, h_ncsa, of) >= 0) {
if (fflush(of) != 0) { if (fflush(of) != 0) {
perror(w_arg); perror(w_arg);
exit(1); exit(1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment