Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
97192e2d
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,发现更多精彩内容 >>
未验证
提交
97192e2d
编写于
11月 22, 2018
作者:
S
Salvatore Sanfilippo
提交者:
GitHub
11月 22, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5569 from maximebedard/backport-4497
Backport #4497 to redis 4
上级
54b17f98
1908aba7
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
19 addition
and
5 deletion
+19
-5
src/networking.c
src/networking.c
+16
-4
src/replication.c
src/replication.c
+1
-1
src/server.h
src/server.h
+2
-0
未找到文件。
src/networking.c
浏览文件 @
97192e2d
...
@@ -67,6 +67,16 @@ int listMatchObjects(void *a, void *b) {
...
@@ -67,6 +67,16 @@ int listMatchObjects(void *a, void *b) {
return
equalStringObjects
(
a
,
b
);
return
equalStringObjects
(
a
,
b
);
}
}
/* This function links the client to the global linked list of clients.
* unlinkClient() does the opposite, among other things. */
void
linkClient
(
client
*
c
)
{
listAddNodeTail
(
server
.
clients
,
c
);
/* Note that we remember the linked list node where the client is stored,
* this way removing the client in unlinkClient() will not require
* a linear scan, but just a constant time operation. */
c
->
client_list_node
=
listLast
(
server
.
clients
);
}
client
*
createClient
(
int
fd
)
{
client
*
createClient
(
int
fd
)
{
client
*
c
=
zmalloc
(
sizeof
(
client
));
client
*
c
=
zmalloc
(
sizeof
(
client
));
...
@@ -133,9 +143,10 @@ client *createClient(int fd) {
...
@@ -133,9 +143,10 @@ client *createClient(int fd) {
c
->
pubsub_channels
=
dictCreate
(
&
objectKeyPointerValueDictType
,
NULL
);
c
->
pubsub_channels
=
dictCreate
(
&
objectKeyPointerValueDictType
,
NULL
);
c
->
pubsub_patterns
=
listCreate
();
c
->
pubsub_patterns
=
listCreate
();
c
->
peerid
=
NULL
;
c
->
peerid
=
NULL
;
c
->
client_list_node
=
NULL
;
listSetFreeMethod
(
c
->
pubsub_patterns
,
decrRefCountVoid
);
listSetFreeMethod
(
c
->
pubsub_patterns
,
decrRefCountVoid
);
listSetMatchMethod
(
c
->
pubsub_patterns
,
listMatchObjects
);
listSetMatchMethod
(
c
->
pubsub_patterns
,
listMatchObjects
);
if
(
fd
!=
-
1
)
li
stAddNodeTail
(
server
.
clients
,
c
);
if
(
fd
!=
-
1
)
li
nkClient
(
c
);
initClientMultiState
(
c
);
initClientMultiState
(
c
);
return
c
;
return
c
;
}
}
...
@@ -752,9 +763,10 @@ void unlinkClient(client *c) {
...
@@ -752,9 +763,10 @@ void unlinkClient(client *c) {
* fd is already set to -1. */
* fd is already set to -1. */
if
(
c
->
fd
!=
-
1
)
{
if
(
c
->
fd
!=
-
1
)
{
/* Remove from the list of active clients. */
/* Remove from the list of active clients. */
ln
=
listSearchKey
(
server
.
clients
,
c
);
if
(
c
->
client_list_node
)
{
serverAssert
(
ln
!=
NULL
);
listDelNode
(
server
.
clients
,
c
->
client_list_node
);
listDelNode
(
server
.
clients
,
ln
);
c
->
client_list_node
=
NULL
;
}
/* Unregister async I/O handlers and close the socket. */
/* Unregister async I/O handlers and close the socket. */
aeDeleteFileEvent
(
server
.
el
,
c
->
fd
,
AE_READABLE
);
aeDeleteFileEvent
(
server
.
el
,
c
->
fd
,
AE_READABLE
);
...
...
src/replication.c
浏览文件 @
97192e2d
...
@@ -2226,7 +2226,7 @@ void replicationResurrectCachedMaster(int newfd) {
...
@@ -2226,7 +2226,7 @@ void replicationResurrectCachedMaster(int newfd) {
server
.
repl_down_since
=
0
;
server
.
repl_down_since
=
0
;
/* Re-add to the list of clients. */
/* Re-add to the list of clients. */
li
stAddNodeTail
(
server
.
clients
,
server
.
master
);
li
nkClient
(
server
.
master
);
if
(
aeCreateFileEvent
(
server
.
el
,
newfd
,
AE_READABLE
,
if
(
aeCreateFileEvent
(
server
.
el
,
newfd
,
AE_READABLE
,
readQueryFromClient
,
server
.
master
))
{
readQueryFromClient
,
server
.
master
))
{
serverLog
(
LL_WARNING
,
"Error resurrecting the cached master, impossible to add the readable handler: %s"
,
strerror
(
errno
));
serverLog
(
LL_WARNING
,
"Error resurrecting the cached master, impossible to add the readable handler: %s"
,
strerror
(
errno
));
...
...
src/server.h
浏览文件 @
97192e2d
...
@@ -723,6 +723,7 @@ typedef struct client {
...
@@ -723,6 +723,7 @@ typedef struct client {
dict
*
pubsub_channels
;
/* channels a client is interested in (SUBSCRIBE) */
dict
*
pubsub_channels
;
/* channels a client is interested in (SUBSCRIBE) */
list
*
pubsub_patterns
;
/* patterns a client is interested in (SUBSCRIBE) */
list
*
pubsub_patterns
;
/* patterns a client is interested in (SUBSCRIBE) */
sds
peerid
;
/* Cached peer ID. */
sds
peerid
;
/* Cached peer ID. */
listNode
*
client_list_node
;
/* list node in client list */
/* Response buffer */
/* Response buffer */
int
bufpos
;
int
bufpos
;
...
@@ -1393,6 +1394,7 @@ int handleClientsWithPendingWrites(void);
...
@@ -1393,6 +1394,7 @@ int handleClientsWithPendingWrites(void);
int
clientHasPendingReplies
(
client
*
c
);
int
clientHasPendingReplies
(
client
*
c
);
void
unlinkClient
(
client
*
c
);
void
unlinkClient
(
client
*
c
);
int
writeToClient
(
int
fd
,
client
*
c
,
int
handler_installed
);
int
writeToClient
(
int
fd
,
client
*
c
,
int
handler_installed
);
void
linkClient
(
client
*
c
);
#ifdef __GNUC__
#ifdef __GNUC__
void
addReplyErrorFormat
(
client
*
c
,
const
char
*
fmt
,
...)
void
addReplyErrorFormat
(
client
*
c
,
const
char
*
fmt
,
...)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录