summaryrefslogtreecommitdiff
path: root/src/c
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2013-12-28 06:27:08 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2013-12-28 06:27:08 -0500
commite7abdeb8485ae016524bfafeea749efd543a9c2f (patch)
tree14aefb466c5bb013f4d0aee50edc4a8494b9f0ea /src/c
parent698214e8d588850082397705aee2a7cef09fa236 (diff)
Make HTTP keepalive switch between available connections to improve throughput
Diffstat (limited to 'src/c')
-rw-r--r--src/c/http.c14
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;