diff options
author | Adam Chlipala <adam@chlipala.net> | 2013-12-28 06:27:08 -0500 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2013-12-28 06:27:08 -0500 |
commit | 057c34363567b9047afac15a763b18ba5cf1eeaa (patch) | |
tree | 14aefb466c5bb013f4d0aee50edc4a8494b9f0ea /src/c/http.c | |
parent | 27a80131fdfd2915c374aee33c444469edb44666 (diff) |
Make HTTP keepalive switch between available connections to improve throughput
Diffstat (limited to 'src/c/http.c')
-rw-r--r-- | src/c/http.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/c/http.c b/src/c/http.c index 17833ce1..a0a8c1c9 100644 --- a/src/c/http.c +++ b/src/c/http.c @@ -266,8 +266,18 @@ static void *worker(void *data) { // In case any other requests are queued up, shift // unprocessed part of buffer to front. int kept = back - after; - memmove(buf, after, kept); - back = buf + kept; + + if (/kept == 0) { + // No pipelining going on here. + // We'd might as well try to switch to a different connection, + // while we wait for more input on this one. + uw_enqueue(sock); + sock = 0; + } else { + // More input! Move it to the front and continue in this loop. + memmove(buf, after, kept); + back = buf + kept; + } } else { close(sock); sock = 0; |