Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
redis
提交
94364d53
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,发现更多精彩内容 >>
提交
94364d53
编写于
8月 26, 2010
作者:
P
Pieter Noordhuis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Verify that the blocking pop timeout value is a non-negative integer
上级
bad7d097
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
35 addition
and
1 deletion
+35
-1
src/t_list.c
src/t_list.c
+13
-1
tests/unit/type/list.tcl
tests/unit/type/list.tcl
+22
-0
未找到文件。
src/t_list.c
浏览文件 @
94364d53
...
...
@@ -782,9 +782,20 @@ int handleClientsWaitingListPush(redisClient *c, robj *key, robj *ele) {
/* Blocking RPOP/LPOP */
void
blockingPopGenericCommand
(
redisClient
*
c
,
int
where
)
{
robj
*
o
;
long
long
lltimeout
;
time_t
timeout
;
int
j
;
/* Make sure timeout is an integer value */
if
(
getLongLongFromObjectOrReply
(
c
,
c
->
argv
[
c
->
argc
-
1
],
&
lltimeout
,
"timeout is not an integer"
)
!=
REDIS_OK
)
return
;
/* Make sure the timeout is not negative */
if
(
lltimeout
<
0
)
{
addReplySds
(
c
,
sdsnew
(
"-ERR timeout is negative
\r\n
"
));
return
;
}
for
(
j
=
1
;
j
<
c
->
argc
-
1
;
j
++
)
{
o
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
j
]);
if
(
o
!=
NULL
)
{
...
...
@@ -823,8 +834,9 @@ void blockingPopGenericCommand(redisClient *c, int where) {
}
}
}
/* If the list is empty or the key does not exists we must block */
timeout
=
strtol
(
c
->
argv
[
c
->
argc
-
1
]
->
ptr
,
NULL
,
10
)
;
timeout
=
lltimeout
;
if
(
timeout
>
0
)
timeout
+=
time
(
NULL
);
blockForKeys
(
c
,
c
->
argv
+
1
,
c
->
argc
-
2
,
timeout
);
}
...
...
tests/unit/type/list.tcl
浏览文件 @
94364d53
...
...
@@ -139,6 +139,28 @@ start_server {
assert_equal 0
[
r exists blist1
]
}
test
"
$pop:
with negative timeout"
{
set rd
[
redis_deferring_client
]
$rd $pop blist1 -1
assert_error
"ERR*is negative*"
{
$rd
read
}
}
test
"
$pop:
with non-integer timeout"
{
set rd
[
redis_deferring_client
]
$rd $pop blist1 1.1
assert_error
"ERR*not an integer*"
{
$rd
read
}
}
test
"
$pop:
with zero timeout should block indefinitely"
{
# To test this, use a timeout of 0 and wait a second.
# The blocking pop should still be waiting for a push.
set rd
[
redis_deferring_client
]
$rd $pop blist1 0
after 1000
r rpush blist1 foo
assert_equal
{
blist1 foo
}
[
$rd
read
]
}
test
"
$pop:
second argument is not a list"
{
set rd
[
redis_deferring_client
]
r del blist1 blist2
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录