Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
bb0b03a3
R
redis
项目概览
xindoo
/
redis
通知
2
Star
2
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,发现更多精彩内容 >>
提交
bb0b03a3
编写于
4月 28, 2009
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
less CPU usage in command parsing, case insensitive config directives
上级
02fdd5ab
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
21 addition
and
22 deletion
+21
-22
redis.c
redis.c
+21
-22
未找到文件。
redis.c
浏览文件 @
bb0b03a3
...
...
@@ -926,44 +926,44 @@ static void loadServerConfig(char *filename) {
sdstolower
(
argv
[
0
]);
/* Execute config directives */
if
(
!
strcmp
(
argv
[
0
],
"timeout"
)
&&
argc
==
2
)
{
if
(
!
strc
asec
mp
(
argv
[
0
],
"timeout"
)
&&
argc
==
2
)
{
server
.
maxidletime
=
atoi
(
argv
[
1
]);
if
(
server
.
maxidletime
<
1
)
{
err
=
"Invalid timeout value"
;
goto
loaderr
;
}
}
else
if
(
!
strcmp
(
argv
[
0
],
"port"
)
&&
argc
==
2
)
{
}
else
if
(
!
strc
asec
mp
(
argv
[
0
],
"port"
)
&&
argc
==
2
)
{
server
.
port
=
atoi
(
argv
[
1
]);
if
(
server
.
port
<
1
||
server
.
port
>
65535
)
{
err
=
"Invalid port"
;
goto
loaderr
;
}
}
else
if
(
!
strcmp
(
argv
[
0
],
"bind"
)
&&
argc
==
2
)
{
}
else
if
(
!
strc
asec
mp
(
argv
[
0
],
"bind"
)
&&
argc
==
2
)
{
server
.
bindaddr
=
zstrdup
(
argv
[
1
]);
}
else
if
(
!
strcmp
(
argv
[
0
],
"save"
)
&&
argc
==
3
)
{
}
else
if
(
!
strc
asec
mp
(
argv
[
0
],
"save"
)
&&
argc
==
3
)
{
int
seconds
=
atoi
(
argv
[
1
]);
int
changes
=
atoi
(
argv
[
2
]);
if
(
seconds
<
1
||
changes
<
0
)
{
err
=
"Invalid save parameters"
;
goto
loaderr
;
}
appendServerSaveParams
(
seconds
,
changes
);
}
else
if
(
!
strcmp
(
argv
[
0
],
"dir"
)
&&
argc
==
2
)
{
}
else
if
(
!
strc
asec
mp
(
argv
[
0
],
"dir"
)
&&
argc
==
2
)
{
if
(
chdir
(
argv
[
1
])
==
-
1
)
{
redisLog
(
REDIS_WARNING
,
"Can't chdir to '%s': %s"
,
argv
[
1
],
strerror
(
errno
));
exit
(
1
);
}
}
else
if
(
!
strcmp
(
argv
[
0
],
"loglevel"
)
&&
argc
==
2
)
{
if
(
!
strcmp
(
argv
[
1
],
"debug"
))
server
.
verbosity
=
REDIS_DEBUG
;
else
if
(
!
strcmp
(
argv
[
1
],
"notice"
))
server
.
verbosity
=
REDIS_NOTICE
;
else
if
(
!
strcmp
(
argv
[
1
],
"warning"
))
server
.
verbosity
=
REDIS_WARNING
;
}
else
if
(
!
strc
asec
mp
(
argv
[
0
],
"loglevel"
)
&&
argc
==
2
)
{
if
(
!
strc
asec
mp
(
argv
[
1
],
"debug"
))
server
.
verbosity
=
REDIS_DEBUG
;
else
if
(
!
strc
asec
mp
(
argv
[
1
],
"notice"
))
server
.
verbosity
=
REDIS_NOTICE
;
else
if
(
!
strc
asec
mp
(
argv
[
1
],
"warning"
))
server
.
verbosity
=
REDIS_WARNING
;
else
{
err
=
"Invalid log level. Must be one of debug, notice, warning"
;
goto
loaderr
;
}
}
else
if
(
!
strcmp
(
argv
[
0
],
"logfile"
)
&&
argc
==
2
)
{
}
else
if
(
!
strc
asec
mp
(
argv
[
0
],
"logfile"
)
&&
argc
==
2
)
{
FILE
*
fp
;
server
.
logfile
=
zstrdup
(
argv
[
1
]);
if
(
!
strcmp
(
server
.
logfile
,
"stdout"
))
{
if
(
!
strc
asec
mp
(
server
.
logfile
,
"stdout"
))
{
zfree
(
server
.
logfile
);
server
.
logfile
=
NULL
;
}
...
...
@@ -978,32 +978,32 @@ static void loadServerConfig(char *filename) {
}
fclose
(
fp
);
}
}
else
if
(
!
strcmp
(
argv
[
0
],
"databases"
)
&&
argc
==
2
)
{
}
else
if
(
!
strc
asec
mp
(
argv
[
0
],
"databases"
)
&&
argc
==
2
)
{
server
.
dbnum
=
atoi
(
argv
[
1
]);
if
(
server
.
dbnum
<
1
)
{
err
=
"Invalid number of databases"
;
goto
loaderr
;
}
}
else
if
(
!
strcmp
(
argv
[
0
],
"slaveof"
)
&&
argc
==
3
)
{
}
else
if
(
!
strc
asec
mp
(
argv
[
0
],
"slaveof"
)
&&
argc
==
3
)
{
server
.
masterhost
=
sdsnew
(
argv
[
1
]);
server
.
masterport
=
atoi
(
argv
[
2
]);
server
.
replstate
=
REDIS_REPL_CONNECT
;
}
else
if
(
!
strcmp
(
argv
[
0
],
"glueoutputbuf"
)
&&
argc
==
2
)
{
}
else
if
(
!
strc
asec
mp
(
argv
[
0
],
"glueoutputbuf"
)
&&
argc
==
2
)
{
if
((
server
.
glueoutputbuf
=
yesnotoi
(
argv
[
1
]))
==
-
1
)
{
err
=
"argument must be 'yes' or 'no'"
;
goto
loaderr
;
}
}
else
if
(
!
strcmp
(
argv
[
0
],
"shareobjects"
)
&&
argc
==
2
)
{
}
else
if
(
!
strc
asec
mp
(
argv
[
0
],
"shareobjects"
)
&&
argc
==
2
)
{
if
((
server
.
shareobjects
=
yesnotoi
(
argv
[
1
]))
==
-
1
)
{
err
=
"argument must be 'yes' or 'no'"
;
goto
loaderr
;
}
}
else
if
(
!
strcmp
(
argv
[
0
],
"daemonize"
)
&&
argc
==
2
)
{
}
else
if
(
!
strc
asec
mp
(
argv
[
0
],
"daemonize"
)
&&
argc
==
2
)
{
if
((
server
.
daemonize
=
yesnotoi
(
argv
[
1
]))
==
-
1
)
{
err
=
"argument must be 'yes' or 'no'"
;
goto
loaderr
;
}
}
else
if
(
!
strcmp
(
argv
[
0
],
"requirepass"
)
&&
argc
==
2
)
{
}
else
if
(
!
strc
asec
mp
(
argv
[
0
],
"requirepass"
)
&&
argc
==
2
)
{
server
.
requirepass
=
zstrdup
(
argv
[
1
]);
}
else
if
(
!
strcmp
(
argv
[
0
],
"pidfile"
)
&&
argc
==
2
)
{
}
else
if
(
!
strc
asec
mp
(
argv
[
0
],
"pidfile"
)
&&
argc
==
2
)
{
server
.
pidfile
=
zstrdup
(
argv
[
1
]);
}
else
if
(
!
strcmp
(
argv
[
0
],
"dbfilename"
)
&&
argc
==
2
)
{
}
else
if
(
!
strc
asec
mp
(
argv
[
0
],
"dbfilename"
)
&&
argc
==
2
)
{
server
.
dbfilename
=
zstrdup
(
argv
[
1
]);
}
else
{
err
=
"Bad directive or wrong number of arguments"
;
goto
loaderr
;
...
...
@@ -1140,7 +1140,7 @@ static void sendReplyToClient(aeEventLoop *el, int fd, void *privdata, int mask)
static
struct
redisCommand
*
lookupCommand
(
char
*
name
)
{
int
j
=
0
;
while
(
cmdTable
[
j
].
name
!=
NULL
)
{
if
(
!
strcmp
(
name
,
cmdTable
[
j
].
name
))
return
&
cmdTable
[
j
];
if
(
!
strc
asec
mp
(
name
,
cmdTable
[
j
].
name
))
return
&
cmdTable
[
j
];
j
++
;
}
return
NULL
;
...
...
@@ -1164,10 +1164,9 @@ static int processCommand(redisClient *c) {
struct
redisCommand
*
cmd
;
long
long
dirty
;
sdstolower
(
c
->
argv
[
0
]
->
ptr
);
/* The QUIT command is handled as a special case. Normal command
* procs are unable to close the client connection safely */
if
(
!
strcmp
(
c
->
argv
[
0
]
->
ptr
,
"quit"
))
{
if
(
!
strc
asec
mp
(
c
->
argv
[
0
]
->
ptr
,
"quit"
))
{
freeClient
(
c
);
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录