Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
e3c51c4b
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,发现更多精彩内容 >>
提交
e3c51c4b
编写于
11月 09, 2010
作者:
D
Damian Janowski & Michel Martens
提交者:
Michel Martens
11月 29, 2010
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename bstate to bpop.
上级
59bd44d1
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
25 addition
and
25 deletion
+25
-25
src/networking.c
src/networking.c
+5
-5
src/redis.h
src/redis.h
+1
-1
src/t_list.c
src/t_list.c
+19
-19
未找到文件。
src/networking.c
浏览文件 @
e3c51c4b
...
...
@@ -41,10 +41,10 @@ redisClient *createClient(int fd) {
c
->
reply
=
listCreate
();
listSetFreeMethod
(
c
->
reply
,
decrRefCount
);
listSetDupMethod
(
c
->
reply
,
dupClientReplyValue
);
c
->
b
state
.
keys
=
NULL
;
c
->
b
state
.
count
=
0
;
c
->
b
state
.
timeout
=
0
;
c
->
b
state
.
target
=
NULL
;
c
->
b
pop
.
keys
=
NULL
;
c
->
b
pop
.
count
=
0
;
c
->
b
pop
.
timeout
=
0
;
c
->
b
pop
.
target
=
NULL
;
c
->
io_keys
=
listCreate
();
c
->
watched_keys
=
listCreate
();
listSetFreeMethod
(
c
->
io_keys
,
decrRefCount
);
...
...
@@ -679,7 +679,7 @@ void closeTimedoutClients(void) {
redisLog
(
REDIS_VERBOSE
,
"Closing idle client"
);
freeClient
(
c
);
}
else
if
(
c
->
flags
&
REDIS_BLOCKED
)
{
if
(
c
->
b
state
.
timeout
!=
0
&&
c
->
bstate
.
timeout
<
now
)
{
if
(
c
->
b
pop
.
timeout
!=
0
&&
c
->
bpop
.
timeout
<
now
)
{
addReply
(
c
,
shared
.
nullmultibulk
);
unblockClientWaitingData
(
c
);
}
...
...
src/redis.h
浏览文件 @
e3c51c4b
...
...
@@ -326,7 +326,7 @@ typedef struct redisClient {
long
repldboff
;
/* replication DB file offset */
off_t
repldbsize
;
/* replication DB file size */
multiState
mstate
;
/* MULTI/EXEC state */
blockingState
b
state
;
/* blocking state */
blockingState
b
pop
;
/* blocking state */
list
*
io_keys
;
/* Keys this client is waiting to be loaded from the
* swap file in order to continue. */
list
*
watched_keys
;
/* Keys WATCHED for MULTI/EXEC CAS */
...
...
src/t_list.c
浏览文件 @
e3c51c4b
...
...
@@ -694,10 +694,10 @@ void blockForKeys(redisClient *c, robj **keys, int numkeys, time_t timeout, robj
list
*
l
;
int
j
;
c
->
b
state
.
keys
=
zmalloc
(
sizeof
(
robj
*
)
*
numkeys
);
c
->
b
state
.
count
=
numkeys
;
c
->
b
state
.
timeout
=
timeout
;
c
->
b
state
.
target
=
target
;
c
->
b
pop
.
keys
=
zmalloc
(
sizeof
(
robj
*
)
*
numkeys
);
c
->
b
pop
.
count
=
numkeys
;
c
->
b
pop
.
timeout
=
timeout
;
c
->
b
pop
.
target
=
target
;
if
(
target
!=
NULL
)
{
incrRefCount
(
target
);
...
...
@@ -705,7 +705,7 @@ void blockForKeys(redisClient *c, robj **keys, int numkeys, time_t timeout, robj
for
(
j
=
0
;
j
<
numkeys
;
j
++
)
{
/* Add the key in the client structure, to map clients -> keys */
c
->
b
state
.
keys
[
j
]
=
keys
[
j
];
c
->
b
pop
.
keys
[
j
]
=
keys
[
j
];
incrRefCount
(
keys
[
j
]);
/* And in the other "side", to map keys -> clients */
...
...
@@ -734,28 +734,28 @@ void unblockClientWaitingData(redisClient *c) {
list
*
l
;
int
j
;
redisAssert
(
c
->
b
state
.
keys
!=
NULL
);
redisAssert
(
c
->
b
pop
.
keys
!=
NULL
);
/* The client may wait for multiple keys, so unblock it for every key. */
for
(
j
=
0
;
j
<
c
->
b
state
.
count
;
j
++
)
{
for
(
j
=
0
;
j
<
c
->
b
pop
.
count
;
j
++
)
{
/* Remove this client from the list of clients waiting for this key. */
de
=
dictFind
(
c
->
db
->
blocking_keys
,
c
->
b
state
.
keys
[
j
]);
de
=
dictFind
(
c
->
db
->
blocking_keys
,
c
->
b
pop
.
keys
[
j
]);
redisAssert
(
de
!=
NULL
);
l
=
dictGetEntryVal
(
de
);
listDelNode
(
l
,
listSearchKey
(
l
,
c
));
/* If the list is empty we need to remove it to avoid wasting memory */
if
(
listLength
(
l
)
==
0
)
dictDelete
(
c
->
db
->
blocking_keys
,
c
->
b
state
.
keys
[
j
]);
decrRefCount
(
c
->
b
state
.
keys
[
j
]);
dictDelete
(
c
->
db
->
blocking_keys
,
c
->
b
pop
.
keys
[
j
]);
decrRefCount
(
c
->
b
pop
.
keys
[
j
]);
}
if
(
c
->
b
state
.
target
!=
NULL
)
{
decrRefCount
(
c
->
b
state
.
target
);
if
(
c
->
b
pop
.
target
!=
NULL
)
{
decrRefCount
(
c
->
b
pop
.
target
);
}
/* Cleanup the client structure */
zfree
(
c
->
b
state
.
keys
);
c
->
b
state
.
keys
=
NULL
;
c
->
b
state
.
target
=
NULL
;
zfree
(
c
->
b
pop
.
keys
);
c
->
b
pop
.
keys
=
NULL
;
c
->
b
pop
.
target
=
NULL
;
c
->
flags
&=
(
~
REDIS_BLOCKED
);
server
.
blpop_blocked_clients
--
;
/* We want to process data if there is some command waiting
...
...
@@ -789,7 +789,7 @@ int handleClientsWaitingListPush(redisClient *c, robj *key, robj *ele) {
redisAssert
(
ln
!=
NULL
);
receiver
=
ln
->
value
;
if
(
receiver
->
b
state
.
target
==
NULL
)
{
if
(
receiver
->
b
pop
.
target
==
NULL
)
{
/* BRPOP/BLPOP return a multi-bulk with the name
* of the popped list */
addReplyMultiBulkLen
(
receiver
,
2
);
...
...
@@ -798,16 +798,16 @@ int handleClientsWaitingListPush(redisClient *c, robj *key, robj *ele) {
}
else
{
/* BRPOPLPUSH */
robj
*
dobj
=
lookupKeyWrite
(
receiver
->
db
,
receiver
->
b
state
.
target
);
robj
*
dobj
=
lookupKeyWrite
(
receiver
->
db
,
receiver
->
b
pop
.
target
);
if
(
dobj
&&
checkType
(
receiver
,
dobj
,
REDIS_LIST
))
return
0
;
addReplyBulk
(
receiver
,
ele
);
if
(
!
handleClientsWaitingListPush
(
receiver
,
receiver
->
b
state
.
target
,
ele
))
{
if
(
!
handleClientsWaitingListPush
(
receiver
,
receiver
->
b
pop
.
target
,
ele
))
{
/* Create the list if the key does not exist */
if
(
!
dobj
)
{
dobj
=
createZiplistObject
();
dbAdd
(
receiver
->
db
,
receiver
->
b
state
.
target
,
dobj
);
dbAdd
(
receiver
->
db
,
receiver
->
b
pop
.
target
,
dobj
);
}
listTypePush
(
dobj
,
ele
,
REDIS_HEAD
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录