diff --git a/src/cluster.c b/src/cluster.c index ec119717db6b6db391ec720c2991adbee04e93f3..e1c12c60e806d8e78b375e43544e78facaada656 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 625eb04e7d7a18fe75f7f5e9e5e04d33c0834b14..b2788c2530873b930afa5dd16750fdf92a84c5da 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 */