]> git.saurik.com Git - redis.git/commitdiff
Fixed semantics of CLUSTER SETSLOT, SELECT now only denied in cluster mode if selecte...
authorantirez <antirez@gmail.com>
Thu, 5 May 2011 16:10:02 +0000 (18:10 +0200)
committerantirez <antirez@gmail.com>
Thu, 5 May 2011 16:10:02 +0000 (18:10 +0200)
src/cluster.c
src/db.c

index e8ca51cf2a3f77d43167165ed1ef6257d54ddcec..d8eca519f0ad6b1af128ff9f7cbdac01d297c934 100644 (file)
@@ -1219,11 +1219,11 @@ void clusterCommand(redisClient *c) {
             return;
         }
         slot = (unsigned int) aux;
-        if (server.cluster.slots[slot] != server.cluster.myself) {
-            addReplyErrorFormat(c,"I'm not the owner of hash slot %u",slot);
-            return;
-        }
         if (!strcasecmp(c->argv[3]->ptr,"migrating") && c->argc == 5) {
+            if (server.cluster.slots[slot] != server.cluster.myself) {
+                addReplyErrorFormat(c,"I'm not the owner of hash slot %u",slot);
+                return;
+            }
             if ((n = clusterLookupNode(c->argv[4]->ptr)) == NULL) {
                 addReplyErrorFormat(c,"I don't know about node %s",
                     (char*)c->argv[4]->ptr);
@@ -1231,6 +1231,11 @@ void clusterCommand(redisClient *c) {
             }
             server.cluster.migrating_slots_to[slot] = n;
         } else if (!strcasecmp(c->argv[3]->ptr,"importing") && c->argc == 5) {
+            if (server.cluster.slots[slot] == server.cluster.myself) {
+                addReplyErrorFormat(c,
+                    "I'm already the owner of hash slot %u",slot);
+                return;
+            }
             if ((n = clusterLookupNode(c->argv[4]->ptr)) == NULL) {
                 addReplyErrorFormat(c,"I don't know about node %s",
                     (char*)c->argv[3]->ptr);
index 670e2bce4e850496a783dc8992d1dc1414bb1caf..354f904569b71a47ce693aaa2ea1f4a47949a9c8 100644 (file)
--- a/src/db.c
+++ b/src/db.c
@@ -317,7 +317,7 @@ void existsCommand(redisClient *c) {
 void selectCommand(redisClient *c) {
     int id = atoi(c->argv[1]->ptr);
 
-    if (server.cluster_enabled) {
+    if (server.cluster_enabled && id != 0) {
         addReplyError(c,"SELECT is not allowed in cluster mode");
         return;
     }