From c2eb4a606f5bf534de6b6f68ed4051afdd5e3aa1 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 25 Feb 2013 11:23:04 +0100 Subject: [PATCH] Cluster: use CountKeysInSlot() when we just need the count. --- src/cluster.c | 8 +------- src/redis.h | 1 + 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index ec119717..e1c12c60 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -1534,13 +1534,7 @@ void clusterCommand(redisClient *c) { if (server.cluster->slots[slot] == server.cluster->myself && n != server.cluster->myself) { - int numkeys; - robj **keys; - - keys = zmalloc(sizeof(robj*)*1); - numkeys = GetKeysInSlot(slot, keys, 1); - zfree(keys); - if (numkeys != 0) { + if (CountKeysInSlot(slot) != 0) { addReplyErrorFormat(c, "Can't assign hashslot %d to a different node while I still hold keys for this hash slot.", slot); return; } diff --git a/src/redis.h b/src/redis.h index 625eb04e..b2788c25 100644 --- a/src/redis.h +++ b/src/redis.h @@ -1227,6 +1227,7 @@ int selectDb(redisClient *c, int id); void signalModifiedKey(redisDb *db, robj *key); void signalFlushedDb(int dbid); unsigned int GetKeysInSlot(unsigned int hashslot, robj **keys, unsigned int count); +unsigned int CountKeysInSlot(unsigned int hashslot); int verifyClusterConfigWithData(void); /* API to get key arguments from commands */