summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;