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
0b2ae6b0
Commit
0b2ae6b0
authored
May 27, 2013
by
Martin Blix Grydeland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add signal handlers to utilities library for graceful shutdown
parent
d72139a6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
vut.h
include/vut.h
+2
-0
vut.c
lib/libvarnishtools/vut.c
+22
-2
No files found.
include/vut.h
View file @
0b2ae6b0
...
...
@@ -49,6 +49,8 @@ struct VUT {
struct
VSLQ
*
vslq
;
FILE
*
fo
;
struct
vpf_fh
*
pfh
;
int
sighup
;
int
sigint
;
};
extern
struct
VUT
VUT
;
...
...
lib/libvarnishtools/vut.c
View file @
0b2ae6b0
...
...
@@ -38,6 +38,7 @@
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <signal.h>
#include "compat/daemon.h"
#include "vpf.h"
...
...
@@ -61,6 +62,20 @@ vut_vpf_remove(void)
}
}
static
void
vut_sighup
(
int
sig
)
{
(
void
)
sig
;
VUT
.
sighup
=
1
;
}
static
void
vut_sigint
(
int
sig
)
{
(
void
)
sig
;
VUT
.
sigint
=
1
;
}
void
VUT_Error
(
int
status
,
const
char
*
fmt
,
...)
{
...
...
@@ -186,6 +201,11 @@ VUT_Setup(void)
VUT_Error
(
1
,
"Query parse error (%s)"
,
VSL_Error
(
VUT
.
vsl
));
AZ
(
c
);
/* Signal handlers */
(
void
)
signal
(
SIGHUP
,
vut_sighup
);
(
void
)
signal
(
SIGINT
,
vut_sigint
);
(
void
)
signal
(
SIGTERM
,
vut_sigint
);
/* Open PID file */
if
(
VUT
.
P_arg
)
{
AZ
(
VUT
.
pfh
);
...
...
@@ -238,8 +258,8 @@ VUT_Main(VSLQ_dispatch_f *func, void *priv)
priv
=
VUT
.
fo
;
}
while
(
1
)
{
while
(
VUT
.
vslq
==
NULL
)
{
while
(
!
VUT
.
sigint
)
{
if
(
VUT
.
vslq
==
NULL
)
{
AZ
(
VUT
.
r_arg
);
AN
(
VUT
.
vsm
);
VTIM_sleep
(
0
.
1
);
...
...
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