Repository: redis/redis

Issue:
[BUG] Protocol error in redis-benchmark
**Describe the bug**

A protocol error happens when running `redis-benchmark`.

**To reproduce**

Run the redis server with the default configuration and verbose logging.
Run `redis-benchmark -P 1 -t set -n 1 -c 1 -d 50000000`

**Expected behavior**

The benchmark should finish without errors.

**Additional information**

I'm using Ubuntu 20.04 LTS in a VM. I built redis from the 6.2.6 branch with SSL/TLS.



Discussion:

Patch:
diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c
index 86421e33f5d..16c0d8d64ef 100644
--- a/src/redis-benchmark.c
+++ b/src/redis-benchmark.c
@@ -632,6 +632,9 @@ static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
                         fprintf(stderr, "Error writing to the server: %s\n", strerror(errno));
                     freeClient(c);
                     return;
+                } else if (nwritten > 0) {
+                    c->written += nwritten;
+                    return;
                 }
             } else {
                 aeDeleteFileEvent(el,c->context->fd,AE_WRITABLE);