add linkClient(): adds the client and caches the list node.

We have this operation in two places: when caching the master and
when linking a new client after the client creation. By having an API
for this we avoid incurring in errors when modifying one of the two
places forgetting the other. The function is also a good place where to
document why we cache the linked list node.

Related to #4497 and #4210.
This commit is contained in:
antirez
2017-12-05 15:59:56 +01:00
committed by Maxime Bedard
parent 239b08574c
commit 1908aba73d
3 changed files with 14 additions and 8 deletions

View File

@ -2214,8 +2214,7 @@ void replicationResurrectCachedMaster(int newfd) {
server.repl_down_since = 0;
/* Re-add to the list of clients. */
listAddNodeTail(server.clients,server.master);
server.master->client_list_node = listLast(server.clients);
linkClient(server.master);
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));