Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
redis
提交
a7d12cba
R
redis
项目概览
别团等shy哥发育
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a7d12cba
编写于
3月 28, 2012
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Log from signal handlers is now safer.
上级
1043c806
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
13 deletion
+33
-13
src/debug.c
src/debug.c
+3
-12
src/redis.c
src/redis.c
+29
-1
src/redis.h
src/redis.h
+1
-0
未找到文件。
src/debug.c
浏览文件 @
a7d12cba
...
...
@@ -682,25 +682,16 @@ void watchdogSignalHandler(int sig, siginfo_t *info, void *secret) {
REDIS_NOTUSED
(
info
);
REDIS_NOTUSED
(
sig
);
sds
st
,
log
;
time_t
now
=
time
(
NULL
);
char
date
[
128
];
FILE
*
fp
;
fp
=
(
server
.
logfile
==
NULL
)
?
stdout
:
fopen
(
server
.
logfile
,
"a"
);
if
(
fp
==
NULL
)
return
;
strftime
(
date
,
sizeof
(
date
),
"%d %b %H:%M:%S"
,
localtime
(
&
now
));
log
=
sdscatprintf
(
sdsempty
(),
"
\n
--- WATCHDOG TIMER EXPIRED (%s) ---
\n
"
,
date
);
log
=
sdsnew
(
"
\n
--- WATCHDOG TIMER EXPIRED ---
\n
"
);
#ifdef HAVE_BACKTRACE
st
=
getStackTrace
(
uc
);
#else
st
=
sdsnew
(
"Sorry: no support for backtrace().
\n
"
);
#endif
log
=
sdscatsds
(
log
,
st
);
log
=
sdscat
(
log
,
"------
\n\n
"
);
fprintf
(
fp
,
"%s"
,
log
);
if
(
server
.
logfile
)
fclose
(
fp
);
log
=
sdscat
(
log
,
"------
\n
"
);
redisLogFromHandler
(
REDIS_WARNING
,
log
);
sdsfree
(
st
);
sdsfree
(
log
);
}
...
...
src/redis.c
浏览文件 @
a7d12cba
...
...
@@ -293,6 +293,34 @@ void redisLog(int level, const char *fmt, ...) {
redisLogRaw
(
level
,
msg
);
}
/* Log a fixed message without printf-alike capabilities, in a way that is
* safe to call from a signal handler.
*
* We actually use this only for signals that are not fatal from the point
* of view of Redis. Signals that are going to kill the server anyway and
* where we need printf-alike features are served by redisLog(). */
void
redisLogFromHandler
(
int
level
,
const
char
*
msg
)
{
int
fd
;
char
buf
[
64
];
if
((
level
&
0xff
)
<
server
.
verbosity
||
(
server
.
logfile
==
NULL
&&
server
.
daemonize
))
return
;
fd
=
server
.
logfile
?
open
(
server
.
logfile
,
O_APPEND
|
O_CREAT
|
O_WRONLY
,
0644
)
:
STDIN_FILENO
;
if
(
fd
==
-
1
)
return
;
ll2string
(
buf
,
sizeof
(
buf
),
getpid
());
write
(
fd
,
"["
,
1
);
write
(
fd
,
buf
,
strlen
(
buf
));
write
(
fd
,
" | signal handler] ("
,
20
);
ll2string
(
buf
,
sizeof
(
buf
),
time
(
NULL
));
write
(
fd
,
buf
,
strlen
(
buf
));
write
(
fd
,
") "
,
2
);
write
(
fd
,
msg
,
strlen
(
msg
));
write
(
fd
,
"
\n
"
,
1
);
close
(
fd
);
}
/* Redis generally does not try to recover from out of memory conditions
* when allocating objects or strings, it is not clear if it will be possible
* to report this condition to the client since the networking layer itself
...
...
@@ -2282,7 +2310,7 @@ void redisAsciiArt(void) {
static
void
sigtermHandler
(
int
sig
)
{
REDIS_NOTUSED
(
sig
);
redisLog
(
REDIS_WARNING
,
"Received SIGTERM, scheduling shutdown..."
);
redisLog
FromHandler
(
REDIS_WARNING
,
"Received SIGTERM, scheduling shutdown..."
);
server
.
shutdown_asap
=
1
;
}
...
...
src/redis.h
浏览文件 @
a7d12cba
...
...
@@ -1004,6 +1004,7 @@ void alsoPropagate(struct redisCommand *cmd, int dbid, robj **argv, int argc, in
int
prepareForShutdown
();
void
redisLog
(
int
level
,
const
char
*
fmt
,
...);
void
redisLogRaw
(
int
level
,
const
char
*
msg
);
void
redisLogFromHandler
(
int
level
,
const
char
*
msg
);
void
usage
();
void
updateDictResizePolicy
(
void
);
int
htNeedsResize
(
dict
*
dict
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录