Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trackrdrd
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
trackrdrd
Commits
d3884da5
Commit
d3884da5
authored
Apr 30, 2015
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor and fix signal handling
parent
0e18aad6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
57 deletions
+66
-57
child.c
src/child.c
+22
-10
config.c
src/config.c
+24
-23
handler.c
src/handler.c
+0
-7
trackrdrd.c
src/trackrdrd.c
+18
-11
trackrdrd.h
src/trackrdrd.h
+2
-6
No files found.
src/child.c
View file @
d3884da5
...
...
@@ -97,9 +97,9 @@ static unsigned long seen = 0, submitted = 0, len_overflows = 0, no_data = 0,
ioerr
=
0
,
reacquire
=
0
,
truncated
=
0
,
key_hi
=
0
,
key_overflows
=
0
;
// no_free_chunk = 0;
static
volatile
sig_atomic_t
flush
=
0
;
static
volatile
sig_atomic_t
flush
=
0
,
term
=
0
;
static
struct
sigaction
dump_action
;
static
struct
sigaction
terminate_action
,
dump_action
;
/* Local freelist */
static
struct
freehead_s
reader_freelist
=
...
...
@@ -125,12 +125,21 @@ RDR_Stats(void)
static
void
dump
(
int
sig
)
{
LOG_Log
(
LOG_NOTICE
,
"
R
eceived signal %d (%s), "
LOG_Log
(
LOG_NOTICE
,
"
Child process r
eceived signal %d (%s), "
"dumping config and data table"
,
sig
,
strsignal
(
sig
));
CONF_Dump
();
CONF_Dump
(
LOG_INFO
);
DATA_Dump
();
}
static
void
term_s
(
int
sig
)
{
LOG_Log
(
LOG_NOTICE
,
"Child process received signal %d (%s), "
"will flush logs and terminate"
,
sig
,
strsignal
(
sig
));
term
=
1
;
flush
=
1
;
}
/*--------------------------------------------------------------------*/
/* efficiently retrieve a single data entry */
...
...
@@ -445,7 +454,7 @@ CHILD_Main(int readconfig)
LOG_Log
(
LOG_NOTICE
,
"Running as %s"
,
pw
->
pw_name
);
if
(
debug
)
CONF_Dump
();
CONF_Dump
(
LOG_DEBUG
);
/* read messaging module */
if
(
config
.
mq_module
[
0
]
==
'\0'
)
{
...
...
@@ -474,6 +483,10 @@ CHILD_Main(int readconfig)
AZ
(
sigemptyset
(
&
dump_action
.
sa_mask
));
dump_action
.
sa_flags
|=
SA_RESTART
;
terminate_action
.
sa_handler
=
term_s
;
AZ
(
sigemptyset
(
&
terminate_action
.
sa_mask
));
terminate_action
.
sa_flags
&=
~
SA_RESTART
;
#define CHILD(SIG,disp) SIGDISP(SIG,disp)
#define PARENT(SIG,disp) ((void) 0)
#include "signals.h"
...
...
@@ -648,20 +661,19 @@ CHILD_Main(int readconfig)
break
;
}
}
if
(
flush
)
{
if
(
flush
&&
!
term
)
{
LOG_Log0
(
LOG_NOTICE
,
"Flushing transactions"
);
take_free
();
VSLQ_Flush
(
vslq
,
dispatch
,
NULL
);
flush
=
0
;
if
(
!
term
&&
EMPTY
(
config
.
varnish_bindump
)
&&
status
!=
DISPATCH_CLOSED
&&
status
!=
DISPATCH_OVERRUN
&&
status
!=
DISPATCH_IOERR
)
if
(
EMPTY
(
config
.
varnish_bindump
)
&&
status
!=
DISPATCH_CLOSED
&&
status
!=
DISPATCH_OVERRUN
&&
status
!=
DISPATCH_IOERR
)
continue
;
VSLQ_Delete
(
&
vslq
);
AZ
(
vslq
);
/* cf. VUT_Main() in Varnish vut.c */
LOG_Log0
(
LOG_NOTICE
,
"Attempting to reacquire the log"
);
while
(
!
term
&&
vslq
==
NULL
)
{
while
(
vslq
==
NULL
)
{
AN
(
vsm
);
VTIM_sleep
(
0
.
1
);
if
(
VSM_Open
(
vsm
))
{
...
...
src/config.c
View file @
d3884da5
...
...
@@ -242,31 +242,32 @@ CONF_ReadDefault(void)
return
0
;
}
#define confdump(
str,val)
\
LOG_Log(
LOG_DEBUG
, "config: " str, (val))
#define confdump(
level,str,val)
\
LOG_Log(
(level)
, "config: " str, (val))
void
CONF_Dump
(
void
)
CONF_Dump
(
int
level
)
{
confdump
(
"pid.file = %s"
,
config
.
pid_file
);
confdump
(
"varnish.name = %s"
,
config
.
varnish_name
);
confdump
(
"log.file = %s"
,
strcmp
(
config
.
log_file
,
"-"
)
==
0
?
"stdout"
:
config
.
log_file
);
confdump
(
"varnish.bindump = %s"
,
config
.
varnish_bindump
);
confdump
(
"syslog.facility = %s"
,
config
.
syslog_facility_name
);
confdump
(
"monitor.interval = %u"
,
config
.
monitor_interval
);
confdump
(
"monitor.workers = %s"
,
config
.
monitor_workers
?
"true"
:
"false"
);
confdump
(
"maxdone = %u"
,
config
.
maxdone
);
confdump
(
"maxdata = %u"
,
config
.
maxdata
);
confdump
(
"maxkeylen = %u"
,
config
.
maxkeylen
);
confdump
(
"qlen.goal = %u"
,
config
.
qlen_goal
);
confdump
(
level
,
"pid.file = %s"
,
config
.
pid_file
);
confdump
(
level
,
"varnish.name = %s"
,
config
.
varnish_name
);
confdump
(
level
,
"log.file = %s"
,
strcmp
(
config
.
log_file
,
"-"
)
==
0
?
"stdout"
:
config
.
log_file
);
confdump
(
level
,
"varnish.bindump = %s"
,
config
.
varnish_bindump
);
confdump
(
level
,
"syslog.facility = %s"
,
config
.
syslog_facility_name
);
confdump
(
level
,
"monitor.interval = %u"
,
config
.
monitor_interval
);
confdump
(
level
,
"monitor.workers = %s"
,
config
.
monitor_workers
?
"true"
:
"false"
);
confdump
(
level
,
"maxdone = %u"
,
config
.
maxdone
);
confdump
(
level
,
"maxdata = %u"
,
config
.
maxdata
);
confdump
(
level
,
"maxkeylen = %u"
,
config
.
maxkeylen
);
confdump
(
level
,
"qlen.goal = %u"
,
config
.
qlen_goal
);
confdump
(
"mq.module = %s"
,
config
.
mq_module
);
confdump
(
"mq.config_file = %s"
,
config
.
mq_config_file
);
confdump
(
"nworkers = %u"
,
config
.
nworkers
);
confdump
(
"restarts = %u"
,
config
.
restarts
);
confdump
(
"restart.pause = %u"
,
config
.
restart_pause
);
confdump
(
"idle.pause = %f"
,
config
.
idle_pause
);
confdump
(
"thread.restarts = %u"
,
config
.
thread_restarts
);
confdump
(
"user = %s"
,
config
.
user_name
);
confdump
(
level
,
"mq.module = %s"
,
config
.
mq_module
);
confdump
(
level
,
"mq.config_file = %s"
,
config
.
mq_config_file
);
confdump
(
level
,
"nworkers = %u"
,
config
.
nworkers
);
confdump
(
level
,
"restarts = %u"
,
config
.
restarts
);
confdump
(
level
,
"restart.pause = %u"
,
config
.
restart_pause
);
confdump
(
level
,
"idle.pause = %f"
,
config
.
idle_pause
);
confdump
(
level
,
"thread.restarts = %u"
,
config
.
thread_restarts
);
confdump
(
level
,
"user = %s"
,
config
.
user_name
);
}
src/handler.c
View file @
d3884da5
...
...
@@ -58,13 +58,6 @@
/*--------------------------------------------------------------------*/
void
HNDL_Terminate
(
int
sig
)
{
(
void
)
sig
;
term
=
1
;
}
#ifdef HAVE_EXECINFO_H
/*
...
...
src/trackrdrd.c
View file @
d3884da5
...
...
@@ -62,9 +62,9 @@
#include "vpf.h"
#include "vtim.h"
static
volatile
sig_atomic_t
reload
;
static
volatile
sig_atomic_t
term
=
0
,
reload
=
0
;
static
struct
sigaction
restart_action
;
static
struct
sigaction
terminate_action
,
restart_action
;
static
const
char
*
version
=
PACKAGE_STRING
" revision "
VCS_Version
" branch "
VCS_Branch
;
...
...
@@ -74,10 +74,19 @@ static const char *version = PACKAGE_STRING " revision " VCS_Version
static
void
restart
(
int
sig
)
{
(
void
)
sig
;
LOG_Log
(
LOG_NOTICE
,
"Management process received signal %d (%s), "
"will restart child process with new config"
,
sig
,
strsignal
(
sig
));
reload
=
1
;
}
static
void
term_s
(
int
sig
)
{
LOG_Log
(
LOG_NOTICE
,
"Management process received signal %d (%s), "
"will terminate management and worker"
,
sig
,
strsignal
(
sig
));
term
=
1
;
}
/*--------------------------------------------------------------------*/
/* Handle for the PID file */
...
...
@@ -89,7 +98,7 @@ parent_shutdown(int status, pid_t child_pid)
if
(
child_pid
&&
kill
(
child_pid
,
SIGTERM
)
!=
0
)
{
LOG_Log
(
LOG_ERR
,
"Cannot kill child process %d: %s"
,
child_pid
,
strerror
(
errno
));
exit
(
EXIT_FAILURE
)
;
status
=
EXIT_FAILURE
;
}
/* Remove PID file if necessary */
...
...
@@ -139,8 +148,10 @@ parent_main(pid_t child_pid)
AZ
(
sigemptyset
(
&
restart_action
.
sa_mask
));
restart_action
.
sa_flags
&=
~
SA_RESTART
;
term
=
0
;
reload
=
0
;
terminate_action
.
sa_handler
=
term_s
;
AZ
(
sigemptyset
(
&
terminate_action
.
sa_mask
));
terminate_action
.
sa_flags
&=
~
SA_RESTART
;
/* install signal handlers */
#define PARENT(SIG,disp) SIGDISP(SIG,disp)
#define CHILD(SIG,disp) ((void) 0)
...
...
@@ -310,7 +321,7 @@ main(int argc, char * const *argv)
LOG_SetLevel
(
LOG_DEBUG
);
LOG_Log
(
LOG_INFO
,
"initializing (%s)"
,
version
);
CONF_Dump
();
CONF_Dump
(
LOG_DEBUG
);
if
(
!
EMPTY
(
config
.
pid_file
)
&&
(
pfh
=
VPF_Open
(
config
.
pid_file
,
0644
,
NULL
))
==
NULL
)
{
...
...
@@ -331,10 +342,6 @@ main(int argc, char * const *argv)
if
(
pfh
!=
NULL
)
VPF_Write
(
pfh
);
terminate_action
.
sa_handler
=
HNDL_Terminate
;
AZ
(
sigemptyset
(
&
terminate_action
.
sa_mask
));
terminate_action
.
sa_flags
&=
~
SA_RESTART
;
stacktrace_action
.
sa_handler
=
HNDL_Abort
;
ignore_action
.
sa_handler
=
SIG_IGN
;
...
...
src/trackrdrd.h
View file @
d3884da5
...
...
@@ -79,14 +79,10 @@ struct mqf {
strerror(errno)); \
} while(0)
volatile
sig_atomic_t
term
;
struct
sigaction
terminate_action
,
ignore_action
,
stacktrace_action
,
default_action
;
struct
sigaction
ignore_action
,
stacktrace_action
,
default_action
;
void
HNDL_Init
(
const
char
*
a0
);
void
HNDL_Abort
(
int
sig
);
void
HNDL_Terminate
(
int
sig
);
/* sandbox.c */
...
...
@@ -275,7 +271,7 @@ int CONF_Add(const char *lval, const char *rval);
* <0 if the file was read but the contents could not be processed
*/
int
CONF_ReadDefault
(
void
);
void
CONF_Dump
(
void
);
void
CONF_Dump
(
int
level
);
/* log.c */
typedef
void
log_log_t
(
int
level
,
const
char
*
msg
,
...);
...
...
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