summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2020-05-27 12:08:52 +0200
committerantirez <antirez@gmail.com>2020-05-27 12:08:52 +0200
commit0471dcaf919140191270b18a99746990f45dbcf1 (patch)
tree56669874052eddfd4d9f215de142e090d043dfef
parent2eb2f3635fd6c3cc382f0ab66d80abdc8d69d01e (diff)
downloadredis-0471dcaf919140191270b18a99746990f45dbcf1.tar.gz
Revert "Make disconnectSlaves() synchronous in the base case."
This reverts commit adc5df1bc3289cb1d786e0ef515ab9acde03bf52.
-rw-r--r--src/networking.c17
-rw-r--r--src/replication.c10
-rw-r--r--src/server.h2
3 files changed, 9 insertions, 20 deletions
diff --git a/src/networking.c b/src/networking.c
index bb682db4c..111f525e7 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -1037,25 +1037,14 @@ static void freeClientArgv(client *c) {
/* Close all the slaves connections. This is useful in chained replication
* when we resync with our own master and want to force all our slaves to
- * resync with us as well.
- *
- * If 'async' is non-zero we free the clients asynchronously. This is needed
- * when we call this function from a context where in the chain of the
- * callers somebody is iterating the list of clients. For instance when
- * CLIENT KILL TYPE master is called, caching the master client may
- * adjust the meaningful offset of replication, and in turn call
- * discionectSlaves(). Since CLIENT KILL iterates the clients this is
- * not safe. */
-void disconnectSlaves(int async) {
+ * resync with us as well. */
+void disconnectSlaves(void) {
listIter li;
listNode *ln;
listRewind(server.slaves,&li);
while((ln = listNext(&li))) {
listNode *ln = listFirst(server.slaves);
- if (async)
- freeClientAsync((client*)ln->value);
- else
- freeClient((client*)ln->value);
+ freeClientAsync((client*)ln->value);
}
}
diff --git a/src/replication.c b/src/replication.c
index a41497c08..ed2f316f5 100644
--- a/src/replication.c
+++ b/src/replication.c
@@ -2086,7 +2086,7 @@ int slaveTryPartialResynchronization(connection *conn, int read_reply) {
memcpy(server.cached_master->replid,new,sizeof(server.replid));
/* Disconnect all the sub-slaves: they need to be notified. */
- disconnectSlaves(0);
+ disconnectSlaves();
}
}
@@ -2359,7 +2359,7 @@ void syncWithMaster(connection *conn) {
* as well, if we have any sub-slaves. The master may transfer us an
* entirely different data set and we have no way to incrementally feed
* our slaves after that. */
- disconnectSlaves(0); /* Force our slaves to resync with us as well. */
+ disconnectSlaves(); /* Force our slaves to resync with us as well. */
freeReplicationBacklog(); /* Don't allow our chained slaves to PSYNC. */
/* Fall back to SYNC if needed. Otherwise psync_result == PSYNC_FULLRESYNC
@@ -2506,7 +2506,7 @@ void replicationSetMaster(char *ip, int port) {
/* Force our slaves to resync with us as well. They may hopefully be able
* to partially resync with us, but we can notify the replid change. */
- disconnectSlaves(0);
+ disconnectSlaves();
cancelReplicationHandshake();
/* Before destroying our master state, create a cached master using
* our own parameters, to later PSYNC with the new master. */
@@ -2553,7 +2553,7 @@ void replicationUnsetMaster(void) {
* of the replication ID change (see shiftReplicationId() call). However
* the slaves will be able to partially resync with us, so it will be
* a very fast reconnection. */
- disconnectSlaves(0);
+ disconnectSlaves();
server.repl_state = REPL_STATE_NONE;
/* We need to make sure the new master will start the replication stream
@@ -2788,7 +2788,7 @@ void replicationCacheMaster(client *c) {
* from the stream and their offset would no longer match: upon
* disconnection they will also trim the final PINGs and will be able
* to incrementally sync without issues. */
- if (offset_adjusted) disconnectSlaves(1);
+ if (offset_adjusted) disconnectSlaves();
}
/* If the "meaningful" offset, that is the offset without the final PINGs
diff --git a/src/server.h b/src/server.h
index 2d17d69c8..f835bf5e9 100644
--- a/src/server.h
+++ b/src/server.h
@@ -1660,7 +1660,7 @@ int getClientType(client *c);
int getClientTypeByName(char *name);
char *getClientTypeName(int class);
void flushSlavesOutputBuffers(void);
-void disconnectSlaves(int async);
+void disconnectSlaves(void);
int listenToPort(int port, int *fds, int *count);
void pauseClients(mstime_t duration);
int clientsArePaused(void);