r2122 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Fri Oct 19 10:50:50 CEST 2007


Author: phk
Date: 2007-10-19 10:50:50 +0200 (Fri, 19 Oct 2007)
New Revision: 2122

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/cache_httpconn.c
Log:
Fix pipelining: don't expect the fd to become readable before we
look for complete requests.


Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2007-10-18 19:09:33 UTC (rev 2121)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2007-10-19 08:50:50 UTC (rev 2122)
@@ -491,6 +491,7 @@
 int HTC_Reinit(struct http_conn *htc);
 int HTC_Rx(struct http_conn *htc);
 int HTC_Read(struct http_conn *htc, void *d, unsigned len);
+int HTC_Complete(struct http_conn *htc);
 
 #define HTTPH(a, b, c, d, e, f, g) extern char b[];
 #include "http_headers.h"

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2007-10-18 19:09:33 UTC (rev 2121)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2007-10-19 08:50:50 UTC (rev 2122)
@@ -89,9 +89,9 @@
 
 	assert(sp->xid == 0);
 
-	do 
+	i = HTC_Complete(sp->htc);
+	while (i == 0)
 		i = HTC_Rx(sp->htc);
-	while (i == 0);
 	if (i == 1) {
 		sp->step = STP_RECV;
 	} else {

Modified: trunk/varnish-cache/bin/varnishd/cache_httpconn.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_httpconn.c	2007-10-18 19:09:33 UTC (rev 2121)
+++ trunk/varnish-cache/bin/varnishd/cache_httpconn.c	2007-10-19 08:50:50 UTC (rev 2122)
@@ -124,6 +124,30 @@
 }
 
 /*--------------------------------------------------------------------
+ *
+ */
+
+int
+HTC_Complete(struct http_conn *htc)
+{
+	int i;
+
+	CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
+	i = htc_header_complete(&htc->rxbuf);
+	if (i < 0) 
+		htc->rxbuf.e = htc->rxbuf.b;
+	if (i <= 0)
+		return (0);
+	WS_ReleaseP(htc->ws, htc->rxbuf.e);
+	if (htc->rxbuf.b + i < htc->rxbuf.e) {
+		htc->pipeline.b = htc->rxbuf.b + i;
+		htc->pipeline.e = htc->rxbuf.e;
+		htc->rxbuf.e = htc->pipeline.b;
+	}
+	return (1);
+}
+
+/*--------------------------------------------------------------------
  * Receive more HTTP protocol bytes
  * Returns:
  *	-2 overflow
@@ -151,18 +175,7 @@
 	}
 	htc->rxbuf.e += i;
 	*htc->rxbuf.e = '\0';
-	i = htc_header_complete(&htc->rxbuf);
-	if (i < 0) 
-		htc->rxbuf.e = htc->rxbuf.b;
-	if (i <= 0)
-		return (0);
-	WS_ReleaseP(htc->ws, htc->rxbuf.e);
-	if (htc->rxbuf.b + i < htc->rxbuf.e) {
-		htc->pipeline.b = htc->rxbuf.b + i;
-		htc->pipeline.e = htc->rxbuf.e;
-		htc->rxbuf.e = htc->pipeline.b;
-	}
-	return (1);
+	return (HTC_Complete(htc));
 }
 
 int




More information about the varnish-commit mailing list