diff options
author | antirez <antirez@gmail.com> | 2015-09-30 16:56:02 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2015-09-30 17:10:03 +0200 |
commit | 1e7153831dc4b03bf6e116430aa55a87707658a7 (patch) | |
tree | 102f665e25bdb5fe1b276ed260428d005890ad08 /src/replication.c | |
parent | fdb3be939ec30be0d39ea639c3988be8b1516c2c (diff) | |
download | redis-1e7153831dc4b03bf6e116430aa55a87707658a7.tar.gz |
Refactoring: unlinkClient() added to lower freeClient() complexity.
Diffstat (limited to 'src/replication.c')
-rw-r--r-- | src/replication.c | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/src/replication.c b/src/replication.c index 6b5f44dd8..7ab646362 100644 --- a/src/replication.c +++ b/src/replication.c @@ -1846,36 +1846,16 @@ void replicationSendAck(void) { * handshake in order to reactivate the cached master. */ void replicationCacheMaster(client *c) { - listNode *ln; - serverAssert(server.master != NULL && server.cached_master == NULL); serverLog(LL_NOTICE,"Caching the disconnected master state."); - /* Remove from the list of clients, we don't want this client to be - * listed by CLIENT LIST or processed in any way by batch operations. */ - ln = listSearchKey(server.clients,c); - serverAssert(ln != NULL); - listDelNode(server.clients,ln); - - /* Remove from the list of clients with pending writes as well. */ - if (c->flags & CLIENT_PENDING_WRITE) { - ln = listSearchKey(server.clients_pending_write,c); - if (ln) listDelNode(server.clients_pending_write,ln); - } + /* Unlink the client from the server structures. */ + unlinkClient(c); /* Save the master. Server.master will be set to null later by * replicationHandleMasterDisconnection(). */ server.cached_master = server.master; - /* Remove the event handlers and close the socket. We'll later reuse - * the socket of the new connection with the master during PSYNC. */ - aeDeleteFileEvent(server.el,c->fd,AE_READABLE); - aeDeleteFileEvent(server.el,c->fd,AE_WRITABLE); - close(c->fd); - - /* Set fd to -1 so that we can safely call freeClient(c) later. */ - c->fd = -1; - /* Invalidate the Peer ID cache. */ if (c->peerid) { sdsfree(c->peerid); |