hufei01 / redis

Automatically exported from code.google.com/p/redis
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Pipelining doesn't work #233

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The protocol spec mentions pipelining should work. I run the following:

perl -le'$\="\r\n"; print "multi"; print "SET foo:$_ $_" for 1 .. 10; print
"exec"' | nc localhost 6379

I expect 10 keys to be set, instead:

+OK
+QUEUED
-ERR unknown command 'foo:2'
+QUEUED
-ERR unknown command 'oo:4'
+QUEUED
-ERR unknown command ':6'
+QUEUED
-ERR unknown command '8'
+QUEUED
-ERR unknown command '10'
*5
+OK
+OK
+OK
+OK
+OK

Only 5 are set, the rest of the commands are garbled. This is with git head
7aaaad507060b131ff18d4637ea63499828076d6.

Original issue reported on code.google.com by dgl...@gmail.com on 29 Apr 2010 at 8:46

GoogleCodeExporter commented 9 years ago
Hello,

did you noticed all the -ERR? :)
You are talking the protocol in the wrong way, please check the protocol 
specification for more information.

Regards,
Salvatore

Original comment by anti...@gmail.com on 29 Apr 2010 at 8:49

GoogleCodeExporter commented 9 years ago
That's a good point, I was thinking in terms of redis-cli...

Could I offer the following patch to linenoise.c, so it's possible to pipe to 
it like I tried to originally? :)

diff --git a/linenoise.c b/linenoise.c
index 4e17da2..fbe5e7d 100644
--- a/linenoise.c
+++ b/linenoise.c
@@ -336,15 +336,24 @@ up_down_arrow:
 static int linenoiseRaw(char *buf, size_t buflen, const char *prompt) {
     int fd = STDIN_FILENO;
     int count;
+    char *end;

     if (buflen == 0) {
         errno = EINVAL;
         return -1;
     }
-    if (enableRawMode(fd) == -1) return -1;
-    count = linenoisePrompt(fd, buf, buflen, prompt);
-    disableRawMode(fd);
-    printf("\n");
+    if (enableRawMode(fd) == -1) {
+        /* not a terminal, fall back to fgets. */
+        if (fgets(buf, buflen, stdin) == NULL)
+            return -1;
+        end = strchr(buf, '\n');
+        *end = '\0';
+        count = strlen(buf);
+    } else {
+        count = linenoisePrompt(fd, buf, buflen, prompt);
+        disableRawMode(fd);
+        printf("\n");
+    }
     return count;
 }

(Sorry to change the issue slightly.)

Original comment by dgl...@gmail.com on 29 Apr 2010 at 11:42

GoogleCodeExporter commented 9 years ago
Hello, thanks, I did not applied the exact patch but the result is the same ;)

Thanks!
Salvatore

Original comment by anti...@gmail.com on 30 Apr 2010 at 7:22

GoogleCodeExporter commented 9 years ago

Original comment by pcnoordh...@gmail.com on 26 Jun 2010 at 9:54