mirror of
http://github.com/valkey-io/valkey
synced 2024-11-22 00:52:38 +00:00
networking: optimize unlinkClient() in freeClient()
This commit is contained in:
parent
c7613cf34e
commit
239b08574c
@ -135,7 +135,12 @@ client *createClient(int fd) {
|
|||||||
c->peerid = NULL;
|
c->peerid = NULL;
|
||||||
listSetFreeMethod(c->pubsub_patterns,decrRefCountVoid);
|
listSetFreeMethod(c->pubsub_patterns,decrRefCountVoid);
|
||||||
listSetMatchMethod(c->pubsub_patterns,listMatchObjects);
|
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);
|
initClientMultiState(c);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@ -752,9 +757,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);
|
||||||
|
@ -2215,6 +2215,7 @@ void replicationResurrectCachedMaster(int newfd) {
|
|||||||
|
|
||||||
/* Re-add to the list of clients. */
|
/* Re-add to the list of clients. */
|
||||||
listAddNodeTail(server.clients,server.master);
|
listAddNodeTail(server.clients,server.master);
|
||||||
|
server.master->client_list_node = listLast(server.clients);
|
||||||
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));
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user