comparison src/c/http.c @ 1944:68c8ffc4ae69

Make HTTP keepalive switch between available connections to improve throughput
author Adam Chlipala <adam@chlipala.net>
date Sat, 28 Dec 2013 06:27:08 -0500
parents 9f3597979e98
children 8b1692660dac
comparison
equal deleted inserted replaced
1943:3ecd0b6360eb 1944:68c8ffc4ae69
264 if (rr == SERVED || rr == FAILED) { 264 if (rr == SERVED || rr == FAILED) {
265 if (should_keepalive) { 265 if (should_keepalive) {
266 // In case any other requests are queued up, shift 266 // In case any other requests are queued up, shift
267 // unprocessed part of buffer to front. 267 // unprocessed part of buffer to front.
268 int kept = back - after; 268 int kept = back - after;
269 memmove(buf, after, kept); 269
270 back = buf + kept; 270 if (/kept == 0) {
271 // No pipelining going on here.
272 // We'd might as well try to switch to a different connection,
273 // while we wait for more input on this one.
274 uw_enqueue(sock);
275 sock = 0;
276 } else {
277 // More input! Move it to the front and continue in this loop.
278 memmove(buf, after, kept);
279 back = buf + kept;
280 }
271 } else { 281 } else {
272 close(sock); 282 close(sock);
273 sock = 0; 283 sock = 0;
274 } 284 }
275 } else if (rr == KEEP_OPEN) 285 } else if (rr == KEEP_OPEN)