Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
hanoi2005
redis
提交
fe3bbfbe
R
redis
项目概览
hanoi2005
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
fe3bbfbe
编写于
6月 05, 2009
作者:
H
hrothgar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- put some order in code
- better output
上级
8a355d69
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
39 deletion
+36
-39
redis.c
redis.c
+36
-39
未找到文件。
redis.c
浏览文件 @
fe3bbfbe
...
...
@@ -378,7 +378,7 @@ static void getSetCommand(redisClient *c);
static
void
ttlCommand
(
redisClient
*
c
);
static
void
slaveofCommand
(
redisClient
*
c
);
static
void
debugCommand
(
redisClient
*
c
);
static
void
setupSigSegvAction
();
/*================================= Globals ================================= */
/* Global vars */
...
...
@@ -898,6 +898,7 @@ static void initServer() {
signal
(
SIGHUP
,
SIG_IGN
);
signal
(
SIGPIPE
,
SIG_IGN
);
setupSigSegvAction
();
server
.
clients
=
listCreate
();
server
.
slaves
=
listCreate
();
...
...
@@ -4080,6 +4081,39 @@ static void debugCommand(redisClient *c) {
}
}
static
void
segvHandler
(
int
sig
,
siginfo_t
*
info
,
void
*
secret
)
{
void
*
trace
[
100
];
char
**
messages
=
(
char
**
)
NULL
;
int
i
,
trace_size
=
0
;
ucontext_t
*
uc
=
(
ucontext_t
*
)
secret
;
redisLog
(
REDIS_DEBUG
,
"Segmentation fault -%d- Redis %s"
,
sig
,
REDIS_VERSION
);
redisLog
(
REDIS_DEBUG
,
"EIP %p"
,
(
void
*
)
uc
->
uc_mcontext
.
gregs
[
REG_EIP
]);
redisLog
(
REDIS_DEBUG
,
"EAX %p, EBX %p, ECX %p, EDX %p"
,
(
void
*
)
uc
->
uc_mcontext
.
gregs
[
REG_EAX
],
(
void
*
)
uc
->
uc_mcontext
.
gregs
[
REG_EBX
],
(
void
*
)
uc
->
uc_mcontext
.
gregs
[
REG_ECX
],
(
void
*
)
uc
->
uc_mcontext
.
gregs
[
REG_EDX
]);
trace_size
=
backtrace
(
trace
,
100
);
/* overwrite sigaction with caller's address */
trace
[
1
]
=
(
void
*
)
uc
->
uc_mcontext
.
gregs
[
REG_EIP
];
messages
=
backtrace_symbols
(
trace
,
trace_size
);
for
(
i
=
1
;
i
<
trace_size
;
++
i
)
redisLog
(
REDIS_DEBUG
,
"[bt] %s"
,
messages
[
i
]);
free
(
messages
);
exit
(
0
);
}
void
setupSigSegvAction
(){
struct
sigaction
act
;
sigemptyset
(
&
act
.
sa_mask
);
/* When the SA_SIGINFO flag is set in sa_flags then sa_sigaction is used. Otherwise, sa_handler is used */
act
.
sa_flags
=
SA_NODEFER
|
SA_ONSTACK
|
SA_RESETHAND
|
SA_SIGINFO
;
act
.
sa_sigaction
=
segvHandler
;
sigaction
(
SIGSEGV
,
&
act
,
NULL
);
}
/* =================================== Main! ================================ */
#ifdef __linux__
...
...
@@ -4128,48 +4162,11 @@ static void daemonize(void) {
}
}
static
void
segvHandler
(
int
sig
,
siginfo_t
*
info
,
void
*
secret
)
{
void
*
trace
[
16
];
char
**
messages
=
(
char
**
)
NULL
;
int
i
,
trace_size
=
0
;
ucontext_t
*
uc
=
(
ucontext_t
*
)
secret
;
/* Do something useful with siginfo_t */
if
(
sig
==
SIGSEGV
)
printf
(
"Got signal %d, faulty address is %p, from %p
\n
"
,
sig
,
info
->
si_addr
,
(
void
*
)
uc
->
uc_mcontext
.
gregs
[
REG_EIP
]);
else
printf
(
"Got signal %d
\n
"
,
sig
);
trace_size
=
backtrace
(
trace
,
16
);
/* overwrite sigaction with caller's address */
trace
[
1
]
=
(
void
*
)
uc
->
uc_mcontext
.
gregs
[
REG_EIP
];
messages
=
backtrace_symbols
(
trace
,
trace_size
);
/* skip first stack frame (points here) */
printf
(
"[bt] Execution path:
\n
"
);
for
(
i
=
1
;
i
<
trace_size
;
++
i
)
printf
(
"[bt] %s
\n
"
,
messages
[
i
]);
exit
(
0
);
}
void
setupSigAction
(){
struct
sigaction
act
;
sigemptyset
(
&
act
.
sa_mask
);
/* When the SA_SIGINFO flag is set in sa_flags then sa_sigaction is used. Otherwise, sa_handler is used */
act
.
sa_flags
=
SA_NODEFER
|
SA_ONSTACK
|
SA_RESETHAND
|
SA_SIGINFO
;
act
.
sa_sigaction
=
segvHandler
;
sigaction
(
SIGSEGV
,
&
act
,
NULL
);
}
int
main
(
int
argc
,
char
**
argv
)
{
setupSigAction
();
#ifdef __linux__
linuxOvercommitMemoryWarning
();
#endif
initServerConfig
();
if
(
argc
==
2
)
{
ResetServerSaveParams
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录