Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
239b0857
Commit
239b0857
authored
Nov 30, 2017
by
zhaozhao.zz
Committed by
Maxime Bedard
Nov 13, 2018
Browse files
networking: optimize unlinkClient() in freeClient()
parent
c7613cf3
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/networking.c
View file @
239b0857
...
...
@@ -135,7 +135,12 @@ client *createClient(int fd) {
c
->
peerid
=
NULL
;
listSetFreeMethod
(
c
->
pubsub_patterns
,
decrRefCountVoid
);
listSetMatchMethod
(
c
->
pubsub_patterns
,
listMatchObjects
);
if
(
fd
!=
-
1
)
listAddNodeTail
(
server
.
clients
,
c
);
if
(
fd
!=
-
1
)
{
listAddNodeTail
(
server
.
clients
,
c
);
c
->
client_list_node
=
listLast
(
server
.
clients
);
}
else
{
c
->
client_list_node
=
NULL
;
}
initClientMultiState
(
c
);
return
c
;
}
...
...
@@ -752,9 +757,10 @@ void unlinkClient(client *c) {
* fd is already set to -1. */
if
(
c
->
fd
!=
-
1
)
{
/* Remove from the list of active clients. */
ln
=
listSearchKey
(
server
.
clients
,
c
);
serverAssert
(
ln
!=
NULL
);
listDelNode
(
server
.
clients
,
ln
);
if
(
c
->
client_list_node
)
{
listDelNode
(
server
.
clients
,
c
->
client_list_node
);
c
->
client_list_node
=
NULL
;
}
/* Unregister async I/O handlers and close the socket. */
aeDeleteFileEvent
(
server
.
el
,
c
->
fd
,
AE_READABLE
);
...
...
src/replication.c
View file @
239b0857
...
...
@@ -2215,6 +2215,7 @@ void replicationResurrectCachedMaster(int newfd) {
/* Re-add to the list of clients. */
listAddNodeTail
(
server
.
clients
,
server
.
master
);
server
.
master
->
client_list_node
=
listLast
(
server
.
clients
);
if
(
aeCreateFileEvent
(
server
.
el
,
newfd
,
AE_READABLE
,
readQueryFromClient
,
server
.
master
))
{
serverLog
(
LL_WARNING
,
"Error resurrecting the cached master, impossible to add the readable handler: %s"
,
strerror
(
errno
));
...
...
src/server.h
View file @
239b0857
...
...
@@ -723,6 +723,7 @@ typedef struct client {
dict
*
pubsub_channels
;
/* channels a client is interested in (SUBSCRIBE) */
list
*
pubsub_patterns
;
/* patterns a client is interested in (SUBSCRIBE) */
sds
peerid
;
/* Cached peer ID. */
listNode
*
client_list_node
;
/* list node in client list */
/* Response buffer */
int
bufpos
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment