Turn the cached master into the current master, using the file descriptor * passed as argument as the socket for the new master. * * This function is called when successfully setup a partial resynchronization * so the stream of data that we'll receive will start from were this * master left. */
| 2989 | * so the stream of data that we'll receive will start from were this |
| 2990 | * master left. */ |
| 2991 | void replicationResurrectCachedMaster(connection *conn) { |
| 2992 | server.master = server.cached_master; |
| 2993 | server.cached_master = NULL; |
| 2994 | server.master->conn = conn; |
| 2995 | connSetPrivateData(server.master->conn, server.master); |
| 2996 | server.master->flags &= ~(CLIENT_CLOSE_AFTER_REPLY|CLIENT_CLOSE_ASAP); |
| 2997 | server.master->authenticated = 1; |
| 2998 | server.master->lastinteraction = server.unixtime; |
| 2999 | server.repl_state = REPL_STATE_CONNECTED; |
| 3000 | server.repl_down_since = 0; |
| 3001 | |
| 3002 | /* Fire the master link modules event. */ |
| 3003 | moduleFireServerEvent(REDISMODULE_EVENT_MASTER_LINK_CHANGE, |
| 3004 | REDISMODULE_SUBEVENT_MASTER_LINK_UP, |
| 3005 | NULL); |
| 3006 | |
| 3007 | /* Re-add to the list of clients. */ |
| 3008 | linkClient(server.master); |
| 3009 | if (connSetReadHandler(server.master->conn, readQueryFromClient)) { |
| 3010 | serverLog(LL_WARNING,"Error resurrecting the cached master, impossible to add the readable handler: %s", strerror(errno)); |
| 3011 | freeClientAsync(server.master); /* Close ASAP. */ |
| 3012 | } |
| 3013 | |
| 3014 | /* We may also need to install the write handler as well if there is |
| 3015 | * pending data in the write buffers. */ |
| 3016 | if (clientHasPendingReplies(server.master)) { |
| 3017 | if (connSetWriteHandler(server.master->conn, sendReplyToClient)) { |
| 3018 | serverLog(LL_WARNING,"Error resurrecting the cached master, impossible to add the writable handler: %s", strerror(errno)); |
| 3019 | freeClientAsync(server.master); /* Close ASAP. */ |
| 3020 | } |
| 3021 | } |
| 3022 | } |
| 3023 | |
| 3024 | /* ------------------------- MIN-SLAVES-TO-WRITE --------------------------- */ |
| 3025 |
no test coverage detected