From: Didier Spezia <didier.06@gmail.com>
Date: Sat, 18 Dec 2010 09:58:50 +0000 (+0100)
Subject: Add wait states to deal with many connections.
X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/f474a5bd4e80157235dac13326edaa99181fb120

Add wait states to deal with many connections.
---

diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c
index ab0d9230..df3b85fd 100644
--- a/src/redis-benchmark.c
+++ b/src/redis-benchmark.c
@@ -278,11 +278,22 @@ static client createClient(int replytype) {
 }
 
 static void createMissingClients(client c) {
+    int n = 0;
+
     while(config.liveclients < config.numclients) {
         client new = createClient(c->replytype);
         new->obuf = sdsdup(c->obuf);
         if (config.randomkeys) randomizeClientKey(c);
+
+        /* Listen backlog is quite limited on most systems */
+        if (++n > 64) {
+            usleep(50000);
+            n = 0;
+        }
     }
+
+    /* Start the timer once the connection are established */
+    config.start = mstime();
 }
 
 static int compareLatency(const void *a, const void *b) {