]> git.saurik.com Git - redis.git/blobdiff - redis-cli.c
update RPOPLPUSH to support dual encoding
[redis.git] / redis-cli.c
index 08c8e2d572230d5619e1a9fae1e4796b03d252c8..2daa7c4614958cae3caef96ba6d382a3032f5000 100644 (file)
@@ -252,18 +252,17 @@ static int cliSendCommand(int argc, char **argv, int repeat) {
         return 1;
     }
 
+    /* Build the command to send */
+    cmd = sdscatprintf(sdsempty(),"*%d\r\n",argc);
+    for (j = 0; j < argc; j++) {
+        cmd = sdscatprintf(cmd,"$%lu\r\n",
+            (unsigned long)sdslen(argv[j]));
+        cmd = sdscatlen(cmd,argv[j],sdslen(argv[j]));
+        cmd = sdscatlen(cmd,"\r\n",2);
+    }
+
     while(repeat--) {
-        /* Build the command to send */
-        cmd = sdscatprintf(sdsempty(),"*%d\r\n",argc);
-        for (j = 0; j < argc; j++) {
-            cmd = sdscatprintf(cmd,"$%lu\r\n",
-                (unsigned long)sdslen(argv[j]));
-            cmd = sdscatlen(cmd,argv[j],sdslen(argv[j]));
-            cmd = sdscatlen(cmd,"\r\n",2);
-        }
         anetWrite(fd,cmd,sdslen(cmd));
-        sdsfree(cmd);
-
         while (config.monitor_mode) {
             cliReadSingleLineReply(fd,0);
         }
@@ -277,7 +276,6 @@ static int cliSendCommand(int argc, char **argv, int repeat) {
         }
 
         retval = cliReadReply(fd);
-
         if (retval) {
             return retval;
         }