Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
c7f93143
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,发现更多精彩内容 >>
提交
c7f93143
编写于
6月 09, 2014
作者:
S
Salvatore Sanfilippo
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1669 from mattsta/blpop-internally-added-keys
Fix blocking operations from missing new lists
上级
6a13193d
33f943b4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
11 deletion
+30
-11
src/db.c
src/db.c
+1
-0
src/redis.h
src/redis.h
+1
-0
src/t_list.c
src/t_list.c
+5
-11
tests/unit/type/list.tcl
tests/unit/type/list.tcl
+23
-0
未找到文件。
src/db.c
浏览文件 @
c7f93143
...
...
@@ -95,6 +95,7 @@ void dbAdd(redisDb *db, robj *key, robj *val) {
int
retval
=
dictAdd
(
db
->
dict
,
copy
,
val
);
redisAssertWithInfo
(
NULL
,
key
,
retval
==
REDIS_OK
);
if
(
val
->
type
==
REDIS_LIST
)
signalListAsReady
(
db
,
key
);
if
(
server
.
cluster_enabled
)
slotToKeyAdd
(
key
);
}
...
...
src/redis.h
浏览文件 @
c7f93143
...
...
@@ -1037,6 +1037,7 @@ void listTypeConvert(robj *subject, int enc);
void
unblockClientWaitingData
(
redisClient
*
c
);
void
handleClientsBlockedOnLists
(
void
);
void
popGenericCommand
(
redisClient
*
c
,
int
where
);
void
signalListAsReady
(
redisDb
*
db
,
robj
*
key
);
/* MULTI/EXEC/WATCH... */
void
unwatchAllKeys
(
redisClient
*
c
);
...
...
src/t_list.c
浏览文件 @
c7f93143
...
...
@@ -29,8 +29,6 @@
#include "redis.h"
void
signalListAsReady
(
redisClient
*
c
,
robj
*
key
);
/*-----------------------------------------------------------------------------
* List API
*----------------------------------------------------------------------------*/
...
...
@@ -297,15 +295,12 @@ void listTypeConvert(robj *subject, int enc) {
void
pushGenericCommand
(
redisClient
*
c
,
int
where
)
{
int
j
,
waiting
=
0
,
pushed
=
0
;
robj
*
lobj
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
int
may_have_waiting_clients
=
(
lobj
==
NULL
);
if
(
lobj
&&
lobj
->
type
!=
REDIS_LIST
)
{
addReply
(
c
,
shared
.
wrongtypeerr
);
return
;
}
if
(
may_have_waiting_clients
)
signalListAsReady
(
c
,
c
->
argv
[
1
]);
for
(
j
=
2
;
j
<
c
->
argc
;
j
++
)
{
c
->
argv
[
j
]
=
tryObjectEncoding
(
c
->
argv
[
j
]);
if
(
!
lobj
)
{
...
...
@@ -709,7 +704,6 @@ void rpoplpushHandlePush(redisClient *c, robj *dstkey, robj *dstobj, robj *value
if
(
!
dstobj
)
{
dstobj
=
createZiplistObject
();
dbAdd
(
c
->
db
,
dstkey
,
dstobj
);
signalListAsReady
(
c
,
dstkey
);
}
signalModifiedKey
(
c
->
db
,
dstkey
);
listTypePush
(
dstobj
,
value
,
REDIS_HEAD
);
...
...
@@ -849,19 +843,19 @@ void unblockClientWaitingData(redisClient *c) {
* made by a script or in the context of MULTI/EXEC.
*
* The list will be finally processed by handleClientsBlockedOnLists() */
void
signalListAsReady
(
redis
Client
*
c
,
robj
*
key
)
{
void
signalListAsReady
(
redis
Db
*
db
,
robj
*
key
)
{
readyList
*
rl
;
/* No clients blocking for this key? No need to queue it. */
if
(
dictFind
(
c
->
db
->
blocking_keys
,
key
)
==
NULL
)
return
;
if
(
dictFind
(
db
->
blocking_keys
,
key
)
==
NULL
)
return
;
/* Key was already signaled? No need to queue it again. */
if
(
dictFind
(
c
->
db
->
ready_keys
,
key
)
!=
NULL
)
return
;
if
(
dictFind
(
db
->
ready_keys
,
key
)
!=
NULL
)
return
;
/* Ok, we need to queue this key into server.ready_keys. */
rl
=
zmalloc
(
sizeof
(
*
rl
));
rl
->
key
=
key
;
rl
->
db
=
c
->
db
;
rl
->
db
=
db
;
incrRefCount
(
key
);
listAddNodeTail
(
server
.
ready_keys
,
rl
);
...
...
@@ -869,7 +863,7 @@ void signalListAsReady(redisClient *c, robj *key) {
* to avoid adding it multiple times into a list with a simple O(1)
* check. */
incrRefCount
(
key
);
redisAssert
(
dictAdd
(
c
->
db
->
ready_keys
,
key
,
NULL
)
==
DICT_OK
);
redisAssert
(
dictAdd
(
db
->
ready_keys
,
key
,
NULL
)
==
DICT_OK
);
}
/* This is a helper function for handleClientsBlockedOnLists(). It's work
...
...
tests/unit/type/list.tcl
浏览文件 @
c7f93143
...
...
@@ -408,6 +408,29 @@ start_server {
$rd read
}
{}
test
"BLPOP when new key is moved into place"
{
set rd
[
redis_deferring_client
]
$rd blpop foo 5
r lpush bob abc def hij
r rename bob foo
$rd read
}
{
foo hij
}
test
"BLPOP when result key is created by SORT..STORE"
{
set rd
[
redis_deferring_client
]
# zero out list from previous test without explicit delete
r lpop foo
r lpop foo
r lpop foo
$rd blpop foo 5
r lpush notfoo hello hola aguacate konichiwa zanzibar
r sort notfoo ALPHA store foo
$rd read
}
{
foo aguacate
}
foreach
{
pop
}
{
BLPOP BRPOP
}
{
test
"
$pop:
with single empty list argument"
{
set rd
[
redis_deferring_client
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录