Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
2d2c17b0
Commit
2d2c17b0
authored
Mar 06, 2011
by
Pieter Noordhuis
Browse files
Save RDB on SIGTERM (see issue #471)
parent
048c0f0f
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/redis.c
View file @
2d2c17b0
...
@@ -837,7 +837,7 @@ void initServer() {
...
@@ -837,7 +837,7 @@ void initServer() {
signal
(
SIGHUP
,
SIG_IGN
);
signal
(
SIGHUP
,
SIG_IGN
);
signal
(
SIGPIPE
,
SIG_IGN
);
signal
(
SIGPIPE
,
SIG_IGN
);
setupSig
SegvAction
();
setupSig
nalHandlers
();
if
(
server
.
syslog_enabled
)
{
if
(
server
.
syslog_enabled
)
{
openlog
(
server
.
syslog_ident
,
LOG_PID
|
LOG_NDELAY
|
LOG_NOWAIT
,
openlog
(
server
.
syslog_ident
,
LOG_PID
|
LOG_NDELAY
|
LOG_NOWAIT
,
...
@@ -1574,10 +1574,8 @@ int main(int argc, char **argv) {
...
@@ -1574,10 +1574,8 @@ int main(int argc, char **argv) {
return
0
;
return
0
;
}
}
/* ============================= Backtrace support ========================= */
#ifdef HAVE_BACKTRACE
#ifdef HAVE_BACKTRACE
void
*
getMcontextEip
(
ucontext_t
*
uc
)
{
static
void
*
getMcontextEip
(
ucontext_t
*
uc
)
{
#if defined(__FreeBSD__)
#if defined(__FreeBSD__)
return
(
void
*
)
uc
->
uc_mcontext
.
mc_eip
;
return
(
void
*
)
uc
->
uc_mcontext
.
mc_eip
;
#elif defined(__dietlibc__)
#elif defined(__dietlibc__)
...
@@ -1605,7 +1603,7 @@ void *getMcontextEip(ucontext_t *uc) {
...
@@ -1605,7 +1603,7 @@ void *getMcontextEip(ucontext_t *uc) {
#endif
#endif
}
}
void
segvHandler
(
int
sig
,
siginfo_t
*
info
,
void
*
secret
)
{
static
void
sig
segvHandler
(
int
sig
,
siginfo_t
*
info
,
void
*
secret
)
{
void
*
trace
[
100
];
void
*
trace
[
100
];
char
**
messages
=
NULL
;
char
**
messages
=
NULL
;
int
i
,
trace_size
=
0
;
int
i
,
trace_size
=
0
;
...
@@ -1644,37 +1642,35 @@ void segvHandler(int sig, siginfo_t *info, void *secret) {
...
@@ -1644,37 +1642,35 @@ void segvHandler(int sig, siginfo_t *info, void *secret) {
sigaction
(
sig
,
&
act
,
NULL
);
sigaction
(
sig
,
&
act
,
NULL
);
kill
(
getpid
(),
sig
);
kill
(
getpid
(),
sig
);
}
}
#endif
/* HAVE_BACKTRACE */
void
sigtermHandler
(
int
sig
)
{
static
void
sigtermHandler
(
int
sig
)
{
REDIS_NOTUSED
(
sig
);
REDIS_NOTUSED
(
sig
);
redisLog
(
REDIS_WARNING
,
"
SIGTERM received
, scheduling shut
ting
down..."
);
redisLog
(
REDIS_WARNING
,
"
Received SIGTERM
, scheduling shutdown..."
);
server
.
shutdown_asap
=
1
;
server
.
shutdown_asap
=
1
;
}
}
void
setupSig
SegvAction
(
void
)
{
void
setupSig
nalHandlers
(
void
)
{
struct
sigaction
act
;
struct
sigaction
act
;
sigemptyset
(
&
act
.
sa_mask
);
/* When the SA_SIGINFO flag is set in sa_flags then sa_sigaction is used.
/* When the SA_SIGINFO flag is set in sa_flags then sa_sigaction
* Otherwise, sa_handler is used. */
* is used. Otherwise, sa_handler is used */
sigemptyset
(
&
act
.
sa_mask
);
act
.
sa_flags
=
SA_NODEFER
|
SA_ONSTACK
|
SA_RESETHAND
|
SA_SIGINFO
;
act
.
sa_sigaction
=
segvHandler
;
sigaction
(
SIGSEGV
,
&
act
,
NULL
);
sigaction
(
SIGBUS
,
&
act
,
NULL
);
sigaction
(
SIGFPE
,
&
act
,
NULL
);
sigaction
(
SIGILL
,
&
act
,
NULL
);
sigaction
(
SIGBUS
,
&
act
,
NULL
);
act
.
sa_flags
=
SA_NODEFER
|
SA_ONSTACK
|
SA_RESETHAND
;
act
.
sa_flags
=
SA_NODEFER
|
SA_ONSTACK
|
SA_RESETHAND
;
act
.
sa_handler
=
sigtermHandler
;
act
.
sa_handler
=
sigtermHandler
;
sigaction
(
SIGTERM
,
&
act
,
NULL
);
sigaction
(
SIGTERM
,
&
act
,
NULL
);
return
;
}
#else
/* HAVE_BACKTRACE */
#ifdef HAVE_BACKTRACE
void
setupSigSegvAction
(
void
)
{
sigemptyset
(
&
act
.
sa_mask
);
act
.
sa_flags
=
SA_NODEFER
|
SA_ONSTACK
|
SA_RESETHAND
|
SA_SIGINFO
;
act
.
sa_sigaction
=
sigsegvHandler
;
sigaction
(
SIGSEGV
,
&
act
,
NULL
);
sigaction
(
SIGBUS
,
&
act
,
NULL
);
sigaction
(
SIGFPE
,
&
act
,
NULL
);
sigaction
(
SIGILL
,
&
act
,
NULL
);
#endif
return
;
}
}
#endif
/* HAVE_BACKTRACE */
/* The End */
/* The End */
src/redis.h
View file @
2d2c17b0
...
@@ -777,7 +777,7 @@ zskiplistNode *zslInsert(zskiplist *zsl, double score, robj *obj);
...
@@ -777,7 +777,7 @@ zskiplistNode *zslInsert(zskiplist *zsl, double score, robj *obj);
/* Core functions */
/* Core functions */
void
freeMemoryIfNeeded
(
void
);
void
freeMemoryIfNeeded
(
void
);
int
processCommand
(
redisClient
*
c
);
int
processCommand
(
redisClient
*
c
);
void
setupSig
SegvAction
(
void
);
void
setupSig
nalHandlers
(
void
);
struct
redisCommand
*
lookupCommand
(
sds
name
);
struct
redisCommand
*
lookupCommand
(
sds
name
);
struct
redisCommand
*
lookupCommandByCString
(
char
*
s
);
struct
redisCommand
*
lookupCommandByCString
(
char
*
s
);
void
call
(
redisClient
*
c
,
struct
redisCommand
*
cmd
);
void
call
(
redisClient
*
c
,
struct
redisCommand
*
cmd
);
...
...
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