From 4e1861155f2dfc52e357b9253ea894c6f7959a06 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 15 Jan 2014 16:44:06 +0100 Subject: [PATCH] Cluster: clusterBlacklistAddNode() key lookup fixed. We can't lookup by node->name that's not an SDS string but a plain C array in the node structure. --- src/cluster.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index 143ade27..866d6745 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -708,10 +708,14 @@ void clusterBlacklistAddNode(clusterNode *node) { sds id = sdsnewlen(node->name,REDIS_CLUSTER_NAMELEN); clusterBlacklistCleanup(); - if (dictAdd(server.cluster->nodes_black_list,id,NULL) == DICT_ERR) - sdsfree(id); /* Key was already there. */ - de = dictFind(server.cluster->nodes_black_list,node->name); + if (dictAdd(server.cluster->nodes_black_list,id,NULL) == DICT_OK) { + /* If the key was added, duplicate the sds string representation of + * the key for the next lookup. We'll free it at the end. */ + id = sdsdup(id); + } + de = dictFind(server.cluster->nodes_black_list,id); dictSetUnsignedIntegerVal(de,time(NULL)); + sdsfree(id); } /* Return non-zero if the specified node ID exists in the blacklist. -- GitLab