Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishevent
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
varnishevent
Commits
4824f7c5
Commit
4824f7c5
authored
Apr 19, 2015
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a signal handler to flush pending transactions (as in varnishncsa)
parent
70bdf90b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
21 deletions
+43
-21
signals.h
src/signals.h
+5
-5
varnishevent.c
src/varnishevent.c
+38
-16
No files found.
src/signals.h
View file @
4824f7c5
/*-
* Copyright (c) 2012 UPLEX Nils Goroll Systemoptimierung
* Copyright (c) 2012 Otto Gmbh & Co KG
* Copyright (c) 2012
-2015
UPLEX Nils Goroll Systemoptimierung
* Copyright (c) 2012
-2015
Otto Gmbh & Co KG
* All rights reserved
* Use only with permission
*
...
...
@@ -29,12 +29,12 @@
*
*/
SIGDISP
(
SIGTERM
,
terminate_action
);
SIGDISP
(
SIGINT
,
terminate_action
);
SIGDISP
(
SIGUSR1
,
dump
_action
);
SIGDISP
(
SIGUSR2
,
ignore
_action
);
SIGDISP
(
SIGUSR1
,
flush
_action
);
SIGDISP
(
SIGUSR2
,
dump
_action
);
SIGDISP
(
SIGABRT
,
stacktrace_action
);
SIGDISP
(
SIGSEGV
,
stacktrace_action
);
SIGDISP
(
SIGBUS
,
stacktrace_action
);
SIGDISP
(
SIGPIPE
,
reopen_action
);
SIGDISP
(
SIGHUP
,
reopen_action
);
src/varnishevent.c
View file @
4824f7c5
...
...
@@ -82,6 +82,7 @@
#define DISPATCH_IOERR -4
#define DISPATCH_TERMINATE 10
#define DISPATCH_REOPEN 11
#define DISPATCH_FLUSH 12
static
unsigned
len_hi
=
0
,
closed
=
0
,
overrun
=
0
,
ioerr
=
0
,
reacquire
=
0
;
...
...
@@ -101,7 +102,7 @@ static unsigned long seen = 0, submitted = 0, len_overflows = 0, no_free_tx = 0,
} while(0)
static
struct
sigaction
dump_action
,
terminate_action
,
reopen_action
,
stacktrace_action
,
ignore_action
;
stacktrace_action
,
ignore_action
,
flush_action
;
static
volatile
sig_atomic_t
reopen
=
0
,
term
=
0
,
flush
=
0
;
...
...
@@ -341,7 +342,9 @@ event(struct VSL_data *vsl, struct VSL_transaction * const pt[], void *priv)
chunk_occ_hi
=
chunk_occ
;
submit
(
tx
);
}
if
(
flush
)
return
DISPATCH_FLUSH
;
if
(
!
reopen
)
return
status
;
return
DISPATCH_REOPEN
;
...
...
@@ -352,15 +355,16 @@ event(struct VSL_data *vsl, struct VSL_transaction * const pt[], void *priv)
static
void
sigreopen
(
int
sig
)
{
LOG_Log
(
LOG_
WARNING
,
"Received signal %d (%s), reopening output"
,
sig
,
strsignal
(
sig
));
LOG_Log
(
LOG_
NOTICE
,
"Received signal %d (%s), reopening output"
,
sig
,
strsignal
(
sig
));
reopen
=
1
;
}
static
void
dump
(
int
sig
)
{
(
void
)
sig
;
LOG_Log
(
LOG_NOTICE
,
"Received signal %d (%s), "
"dumping config and data table"
,
sig
,
strsignal
(
sig
));
CONF_Dump
();
DATA_Dump
();
}
...
...
@@ -368,9 +372,18 @@ dump(int sig)
static
void
terminate
(
int
sig
)
{
(
void
)
sig
;
term
=
1
;
flush
=
1
;
LOG_Log
(
LOG_NOTICE
,
"Received signal %d (%s), terminating"
,
sig
,
strsignal
(
sig
));
}
static
void
sigflush
(
int
sig
)
{
flush
=
1
;
LOG_Log
(
LOG_NOTICE
,
"Received signal %d (%s), "
"flushing pending transactions"
,
sig
,
strsignal
(
sig
));
}
static
vas_f
assert_fail
__attribute__
((
__noreturn__
));
...
...
@@ -600,6 +613,10 @@ main(int argc, char *argv[])
AZ
(
sigemptyset
(
&
reopen_action
.
sa_mask
));
reopen_action
.
sa_flags
|=
SA_RESTART
;
flush_action
.
sa_handler
=
sigflush
;
AZ
(
sigemptyset
(
&
flush_action
.
sa_mask
));
flush_action
.
sa_flags
|=
SA_RESTART
;
stacktrace_action
.
sa_handler
=
HNDL_Abort
;
ignore_action
.
sa_handler
=
SIG_IGN
;
...
...
@@ -713,18 +730,22 @@ main(int argc, char *argv[])
continue
;
case
DISPATCH_REOPEN
:
take_free
();
LOG_Log0
(
LOG_INFO
,
"Signal received to re-open output"
);
WRT_Reopen
();
reopen
=
0
;
continue
;
case
DISPATCH_EOL
:
take_free
();
VTIM_sleep
(
config
.
idle_pause
);
continue
;
if
(
!
flush
)
continue
;
break
;
case
DISPATCH_TERMINATE
:
AN
(
term
);
AN
(
flush
);
break
;
case
DISPATCH_FLUSH
:
AN
(
flush
);
break
;
case
DISPATCH_EOF
:
term
=
1
;
LOG_Log0
(
LOG_INFO
,
"Reached end of file"
);
...
...
@@ -751,10 +772,13 @@ main(int argc, char *argv[])
}
if
(
flush
)
{
LOG_Log0
(
LOG_NOTICE
,
"Flushing transactions"
);
take_free
();
VSLQ_Flush
(
vslq
,
event
,
NULL
);
flush
=
0
;
if
(
status
==
DISPATCH_FLUSH
||
status
==
DISPATCH_EOL
)
continue
;
VSLQ_Delete
(
&
vslq
);
AZ
(
vslq
);
flush
=
0
;
if
(
!
term
&&
EMPTY
(
config
.
varnish_bindump
))
{
/* cf. VUT_Main() in Varnish vut.c */
LOG_Log0
(
LOG_NOTICE
,
"Attempting to reacquire the log"
);
...
...
@@ -783,12 +807,10 @@ main(int argc, char *argv[])
}
}
if
(
term
&&
status
!=
DISPATCH_EOF
)
{
LOG_Log0
(
LOG_NOTICE
,
"Termination signal received"
);
if
(
flush
&&
vslq
!=
NULL
)
{
LOG_Log0
(
LOG_NOTICE
,
"Flushing transactions"
);
VSLQ_Flush
(
vslq
,
event
,
NULL
);
}
if
(
term
&&
status
!=
DISPATCH_EOF
&&
flush
&&
vslq
!=
NULL
)
{
LOG_Log0
(
LOG_NOTICE
,
"Flushing transactions"
);
take_free
();
VSLQ_Flush
(
vslq
,
event
,
NULL
);
}
WRT_Halt
();
...
...
@@ -801,7 +823,7 @@ main(int argc, char *argv[])
if
(
pfh
!=
NULL
)
{
errno
=
0
;
if
(
VPF_Remove
(
pfh
)
!=
0
)
LOG_Log
(
LOG_
WARNING
,
"Could not remove pid file %s: %s"
,
P_arg
,
LOG_Log
(
LOG_
ERR
,
"Could not remove pid file %s: %s"
,
P_arg
,
strerror
(
errno
));
}
LOG_Log0
(
LOG_INFO
,
"Exiting"
);
...
...
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