summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-03-11 11:16:18 +0100
committerantirez <antirez@gmail.com>2014-03-11 15:02:41 +0100
commit117557192edf39a948ced1706b50ffc7854c6a49 (patch)
tree2139dbadc29f357c612660a9e47cb7acd036c9c5
parent01eee56f4f0d8bdc2decdcf527417b4de48411bc (diff)
downloadredis-117557192edf39a948ced1706b50ffc7854c6a49.tar.gz
Cluster: clusterCloseAllSlots() added.
-rw-r--r--src/cluster.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/cluster.c b/src/cluster.c
index 59a711806..b9737490a 100644
--- a/src/cluster.c
+++ b/src/cluster.c
@@ -68,6 +68,7 @@ int bitmapTestBit(unsigned char *bitmap, int pos);
void clusterDoBeforeSleep(int flags);
void clusterSendUpdate(clusterLink *link, clusterNode *node);
void resetManualFailover(void);
+void clusterCloseAllSlots(void);
/* -----------------------------------------------------------------------------
* Initialization
@@ -309,12 +310,8 @@ void clusterInit(void) {
server.cluster->last_vote_epoch = 0;
server.cluster->stats_bus_messages_sent = 0;
server.cluster->stats_bus_messages_received = 0;
- memset(server.cluster->migrating_slots_to,0,
- sizeof(server.cluster->migrating_slots_to));
- memset(server.cluster->importing_slots_from,0,
- sizeof(server.cluster->importing_slots_from));
- memset(server.cluster->slots,0,
- sizeof(server.cluster->slots));
+ memset(server.cluster->slots,0, sizeof(server.cluster->slots));
+ clusterCloseAllSlots();
if (clusterLoadConfig(server.cluster_configfile) == REDIS_ERR) {
/* No configuration found. We will just use the random name provided
* by the createClusterNode() function. */
@@ -2716,6 +2713,15 @@ int clusterDelNodeSlots(clusterNode *node) {
return deleted;
}
+/* Clear the migrating / importing state for all the slots.
+ * This is useful at initialization and when turning a master into slave. */
+void clusterCloseAllSlots(void) {
+ memset(server.cluster->migrating_slots_to,0,
+ sizeof(server.cluster->migrating_slots_to));
+ memset(server.cluster->importing_slots_from,0,
+ sizeof(server.cluster->importing_slots_from));
+}
+
/* -----------------------------------------------------------------------------
* Cluster state evaluation function
* -------------------------------------------------------------------------- */