Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
hanoi2005
redis
提交
941c9fa2
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,发现更多精彩内容 >>
提交
941c9fa2
编写于
10月 13, 2010
作者:
P
Pieter Noordhuis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Return OK on QUIT
上级
9f1ae9ab
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
51 addition
and
13 deletion
+51
-13
src/networking.c
src/networking.c
+7
-0
src/redis.c
src/redis.c
+7
-3
src/redis.h
src/redis.h
+1
-0
tests/support/redis.tcl
tests/support/redis.tcl
+8
-0
tests/support/server.tcl
tests/support/server.tcl
+6
-10
tests/test_helper.tcl
tests/test_helper.tcl
+22
-0
未找到文件。
src/networking.c
浏览文件 @
941c9fa2
...
...
@@ -546,6 +546,9 @@ void sendReplyToClient(aeEventLoop *el, int fd, void *privdata, int mask) {
if
(
listLength
(
c
->
reply
)
==
0
)
{
c
->
sentlen
=
0
;
aeDeleteFileEvent
(
server
.
el
,
c
->
fd
,
AE_WRITABLE
);
/* Close connection after entire reply has been sent. */
if
(
c
->
flags
&
REDIS_QUIT
)
freeClient
(
c
);
}
}
...
...
@@ -675,6 +678,10 @@ again:
* will try to reiterate. The following line will make it return asap. */
if
(
c
->
flags
&
REDIS_BLOCKED
||
c
->
flags
&
REDIS_IO_WAIT
)
return
;
/* Never continue to process the input buffer after QUIT. After the output
* buffer is flushed (with the OK), the connection will be dropped. */
if
(
c
->
flags
&
REDIS_QUIT
)
return
;
if
(
seeknewline
&&
c
->
bulklen
==
-
1
)
c
->
newline
=
strchr
(
c
->
querybuf
,
'\n'
);
seeknewline
=
1
;
if
(
c
->
bulklen
==
-
1
)
{
...
...
src/redis.c
浏览文件 @
941c9fa2
...
...
@@ -962,10 +962,14 @@ int processCommand(redisClient *c) {
}
/* -- end of multi bulk commands processing -- */
/* The QUIT command is handled as a special case. Normal command
* procs are unable to close the client connection safely */
/* The QUIT command is handled separately. Normal command procs will
* go through checking for replication and QUIT will cause trouble
* when FORCE_REPLICATION is enabled and would be implemented in
* a regular command proc. */
redisAssert
(
!
(
c
->
flags
&
REDIS_QUIT
));
if
(
!
strcasecmp
(
c
->
argv
[
0
]
->
ptr
,
"quit"
))
{
freeClient
(
c
);
c
->
flags
|=
REDIS_QUIT
;
addReply
(
c
,
shared
.
ok
);
return
0
;
}
...
...
src/redis.h
浏览文件 @
941c9fa2
...
...
@@ -144,6 +144,7 @@
#define REDIS_BLOCKED 16
/* The client is waiting in a blocking operation */
#define REDIS_IO_WAIT 32
/* The client is waiting for Virtual Memory I/O */
#define REDIS_DIRTY_CAS 64
/* Watched keys modified. EXEC will fail. */
#define REDIS_QUIT 128
/* Client will be disconnected after reply is sent */
/* Slave replication state - slave side */
#define REDIS_REPL_NONE 0
/* No active replication */
...
...
tests/support/redis.tcl
浏览文件 @
941c9fa2
...
...
@@ -123,6 +123,14 @@ proc ::redis::__method__read {id fd} {
::redis::redis_read_reply $fd
}
proc ::redis::__method__write
{
id fd buf
}
{
::redis::redis_write $fd $buf
}
proc ::redis::__method__flush
{
id fd
}
{
flush $fd
}
proc ::redis::__method__close
{
id fd
}
{
catch
{
close $fd
}
catch
{
unset ::redis::fd
(
$id
)}
...
...
tests/support/server.tcl
浏览文件 @
941c9fa2
...
...
@@ -215,7 +215,8 @@ proc start_server {options {code undefined}} {
if
{[
dict exists $config port
]}
{
set port
[
dict get $config port
]
}
# setup config dict
dict set srv
"config"
$config_file
dict set srv
"config_file"
$config_file
dict set srv
"config"
$config
dict set srv
"pid"
$pid
dict set srv
"host"
$host
dict set srv
"port"
$port
...
...
@@ -238,17 +239,12 @@ proc start_server {options {code undefined}} {
after 10
}
set client
[
redis $host $port
]
dict set srv
"client"
$client
# select the right db when we don't have to authenticate
if
{
!
[
dict exists $config requirepass
]}
{
$client select 9
}
# append the server to the stack
lappend ::servers $srv
# connect client
(
after server dict is put on the stack
)
reconnect
# execute provided block
set curnum $::testnum
if
{
!
[
catch
{
uplevel 1 $code
}
err
]}
{
...
...
tests/test_helper.tcl
浏览文件 @
941c9fa2
...
...
@@ -50,6 +50,28 @@ proc r {args} {
[
srv $level
"client"
]
{*}
$args
}
proc reconnect
{
args
}
{
set level
[
lindex $args 0
]
if
{[
string length $level
]
== 0 || !
[
string is integer $level
]}
{
set level 0
}
set srv
[
lindex $::servers end+$level
]
set host
[
dict get $srv
"host"
]
set port
[
dict get $srv
"port"
]
set config
[
dict get $srv
"config"
]
set client
[
redis $host $port
]
dict set srv
"client"
$client
# select the right db when we don't have to authenticate
if
{
!
[
dict exists $config
"requirepass"
]}
{
$client select 9
}
# re-set $srv in the servers list
set ::servers
[
lreplace $::servers end+$level 1 $srv
]
}
proc redis_deferring_client
{
args
}
{
set level 0
if
{[
llength $args
]
> 0 &&
[
string is integer
[
lindex $args 0
]]}
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录