mirror of
https://github.com/fluencelabs/redis
synced 2025-06-14 17:51:21 +00:00
Merge pull request #4497 from soloestoy/optimize-unlink-client
networking: optimize unlinkClient() in freeClient()
This commit is contained in:
@ -136,7 +136,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;
|
||||
}
|
||||
@ -744,9 +749,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);
|
||||
|
Reference in New Issue
Block a user