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
Show 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 {
...
@@ -49,6 +49,8 @@ struct VUT {
struct
VSLQ
*
vslq
;
struct
VSLQ
*
vslq
;
FILE
*
fo
;
FILE
*
fo
;
struct
vpf_fh
*
pfh
;
struct
vpf_fh
*
pfh
;
int
sighup
;
int
sigint
;
};
};
extern
struct
VUT
VUT
;
extern
struct
VUT
VUT
;
...
...
lib/libvarnishtools/vut.c
View file @
0b2ae6b0
...
@@ -38,6 +38,7 @@
...
@@ -38,6 +38,7 @@
#include <stdio.h>
#include <stdio.h>
#include <errno.h>
#include <errno.h>
#include <string.h>
#include <string.h>
#include <signal.h>
#include "compat/daemon.h"
#include "compat/daemon.h"
#include "vpf.h"
#include "vpf.h"
...
@@ -61,6 +62,20 @@ vut_vpf_remove(void)
...
@@ -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
void
VUT_Error
(
int
status
,
const
char
*
fmt
,
...)
VUT_Error
(
int
status
,
const
char
*
fmt
,
...)
{
{
...
@@ -186,6 +201,11 @@ VUT_Setup(void)
...
@@ -186,6 +201,11 @@ VUT_Setup(void)
VUT_Error
(
1
,
"Query parse error (%s)"
,
VSL_Error
(
VUT
.
vsl
));
VUT_Error
(
1
,
"Query parse error (%s)"
,
VSL_Error
(
VUT
.
vsl
));
AZ
(
c
);
AZ
(
c
);
/* Signal handlers */
(
void
)
signal
(
SIGHUP
,
vut_sighup
);
(
void
)
signal
(
SIGINT
,
vut_sigint
);
(
void
)
signal
(
SIGTERM
,
vut_sigint
);
/* Open PID file */
/* Open PID file */
if
(
VUT
.
P_arg
)
{
if
(
VUT
.
P_arg
)
{
AZ
(
VUT
.
pfh
);
AZ
(
VUT
.
pfh
);
...
@@ -238,8 +258,8 @@ VUT_Main(VSLQ_dispatch_f *func, void *priv)
...
@@ -238,8 +258,8 @@ VUT_Main(VSLQ_dispatch_f *func, void *priv)
priv
=
VUT
.
fo
;
priv
=
VUT
.
fo
;
}
}
while
(
1
)
{
while
(
!
VUT
.
sigint
)
{
while
(
VUT
.
vslq
==
NULL
)
{
if
(
VUT
.
vslq
==
NULL
)
{
AZ
(
VUT
.
r_arg
);
AZ
(
VUT
.
r_arg
);
AN
(
VUT
.
vsm
);
AN
(
VUT
.
vsm
);
VTIM_sleep
(
0
.
1
);
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