Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Turbo码先生
redis
提交
6c001bfc
R
redis
项目概览
Turbo码先生
/
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,发现更多精彩内容 >>
提交
6c001bfc
编写于
9月 03, 2018
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Unblocked clients API refactoring. See #4418.
上级
2b689ad6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
15 deletion
+33
-15
src/blocked.c
src/blocked.c
+26
-6
src/networking.c
src/networking.c
+4
-5
src/scripting.c
src/scripting.c
+2
-4
src/server.h
src/server.h
+1
-0
未找到文件。
src/blocked.c
浏览文件 @
6c001bfc
...
...
@@ -132,6 +132,31 @@ void processUnblockedClients(void) {
}
}
/* This function will schedule the client for reprocessing at a safe time.
*
* This is useful when a client was blocked for some reason (blocking opeation,
* CLIENT PAUSE, or whatever), because it may end with some accumulated query
* buffer that needs to be processed ASAP:
*
* 1. When a client is blocked, its readable handler is still active.
* 2. However in this case it only gets data into the query buffer, but the
* query is not parsed or executed once there is enough to proceed as
* usually (because the client is blocked... so we can't execute commands).
* 3. When the client is unblocked, without this function, the client would
* have to write some query in order for the readable handler to finally
* call processQueryBuffer*() on it.
* 4. With this function instead we can put the client in a queue that will
* process it for queries ready to be executed at a safe time.
*/
void
queueClientForReprocessing
(
client
*
c
)
{
/* The client may already be into the unblocked list because of a previous
* blocking operation, don't add back it into the list multiple times. */
if
(
!
(
c
->
flags
&
CLIENT_UNBLOCKED
))
{
c
->
flags
|=
CLIENT_UNBLOCKED
;
listAddNodeTail
(
server
.
unblocked_clients
,
c
);
}
}
/* Unblock a client calling the right function depending on the kind
* of operation the client is blocking for. */
void
unblockClient
(
client
*
c
)
{
...
...
@@ -152,12 +177,7 @@ void unblockClient(client *c) {
server
.
blocked_clients_by_type
[
c
->
btype
]
--
;
c
->
flags
&=
~
CLIENT_BLOCKED
;
c
->
btype
=
BLOCKED_NONE
;
/* The client may already be into the unblocked list because of a previous
* blocking operation, don't add back it into the list multiple times. */
if
(
!
(
c
->
flags
&
CLIENT_UNBLOCKED
))
{
c
->
flags
|=
CLIENT_UNBLOCKED
;
listAddNodeTail
(
server
.
unblocked_clients
,
c
);
}
queueClientForReprocessing
(
c
);
}
/* This function gets called when a blocked client timed out in order to
...
...
src/networking.c
浏览文件 @
6c001bfc
...
...
@@ -2134,11 +2134,10 @@ int clientsArePaused(void) {
while
((
ln
=
listNext
(
&
li
))
!=
NULL
)
{
c
=
listNodeValue
(
ln
);
/* Don't touch slaves and blocked or unblocked clients.
* The latter pending requests be processed when unblocked. */
if
(
c
->
flags
&
(
CLIENT_SLAVE
|
CLIENT_BLOCKED
|
CLIENT_UNBLOCKED
))
continue
;
c
->
flags
|=
CLIENT_UNBLOCKED
;
listAddNodeTail
(
server
.
unblocked_clients
,
c
);
/* Don't touch slaves and blocked clients.
* The latter pending requests will be processed when unblocked. */
if
(
c
->
flags
&
(
CLIENT_SLAVE
|
CLIENT_BLOCKED
))
continue
;
queueClientForReprocessing
(
c
);
}
}
return
server
.
clients_paused
;
...
...
src/scripting.c
浏览文件 @
6c001bfc
...
...
@@ -1367,10 +1367,8 @@ void evalGenericCommand(client *c, int evalsha) {
* script timeout was detected. */
aeCreateFileEvent
(
server
.
el
,
c
->
fd
,
AE_READABLE
,
readQueryFromClient
,
c
);
if
(
server
.
masterhost
&&
server
.
master
&&
!
(
server
.
master
->
flags
&
CLIENT_UNBLOCKED
))
{
server
.
master
->
flags
|=
CLIENT_UNBLOCKED
;
listAddNodeTail
(
server
.
unblocked_clients
,
server
.
master
);
}
if
(
server
.
masterhost
&&
server
.
master
)
queueClientForReprocessing
(
server
.
master
);
}
server
.
lua_caller
=
NULL
;
...
...
src/server.h
浏览文件 @
6c001bfc
...
...
@@ -1884,6 +1884,7 @@ sds luaCreateFunction(client *c, lua_State *lua, robj *body);
void
processUnblockedClients
(
void
);
void
blockClient
(
client
*
c
,
int
btype
);
void
unblockClient
(
client
*
c
);
void
queueClientForReprocessing
(
client
*
c
);
void
replyToBlockedClientTimedOut
(
client
*
c
);
int
getTimeoutFromObjectOrReply
(
client
*
c
,
robj
*
object
,
mstime_t
*
timeout
,
int
unit
);
void
disconnectAllBlockedClients
(
void
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录