r2132 - in branches/1.2: . bin/varnishd

des at projects.linpro.no des at projects.linpro.no
Fri Oct 19 12:00:20 CEST 2007


Author: des
Date: 2007-10-19 12:00:20 +0200 (Fri, 19 Oct 2007)
New Revision: 2132

Modified:
   branches/1.2/
   branches/1.2/bin/varnishd/cache.h
   branches/1.2/bin/varnishd/cache_center.c
   branches/1.2/bin/varnishd/cache_fetch.c
   branches/1.2/bin/varnishd/cache_httpconn.c
Log:
Merged revisions 2115,2117-2120,2122-2130 via svnmerge from 
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache

........
  r2115 | cecilihf | 2007-10-18 15:38:45 +0200 (Thu, 18 Oct 2007) | 3 lines
  
  Make pass mode work for POST requests. Solves ticket #47.
........
  r2122 | phk | 2007-10-19 10:50:50 +0200 (Fri, 19 Oct 2007) | 3 lines
  
  Fix pipelining: don't expect the fd to become readable before we
  look for complete requests.
........
  r2123 | cecilihf | 2007-10-19 10:51:40 +0200 (Fri, 19 Oct 2007) | 2 lines
  
  Improved handling of pass for POST requests.
........
  r2124 | des | 2007-10-19 10:55:46 +0200 (Fri, 19 Oct 2007) | 2 lines
  
  Style & whitespace
........
  r2125 | des | 2007-10-19 11:05:10 +0200 (Fri, 19 Oct 2007) | 2 lines
  
  Simplify
........
  r2126 | des | 2007-10-19 11:09:17 +0200 (Fri, 19 Oct 2007) | 4 lines
  
  Move malloc() / free() out of the loop, and plug a leak.  Ideally, we
  shouldn't need to malloc() / free() at all, but I don't have time to
  figure out how to avoid it right now.
........
  r2130 | des | 2007-10-19 11:47:53 +0200 (Fri, 19 Oct 2007) | 2 lines
  
  Use an 8 kB stack buffer instead of a heap buffer.
........



Property changes on: branches/1.2
___________________________________________________________________
Name: svnmerge-integrated
   - /trunk/varnish-cache:1-2101,2104-2107,2116
   + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130

Modified: branches/1.2/bin/varnishd/cache.h
===================================================================
--- branches/1.2/bin/varnishd/cache.h	2007-10-19 09:48:35 UTC (rev 2131)
+++ branches/1.2/bin/varnishd/cache.h	2007-10-19 10:00:20 UTC (rev 2132)
@@ -488,6 +488,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: branches/1.2/bin/varnishd/cache_center.c
===================================================================
--- branches/1.2/bin/varnishd/cache_center.c	2007-10-19 09:48:35 UTC (rev 2131)
+++ branches/1.2/bin/varnishd/cache_center.c	2007-10-19 10:00:20 UTC (rev 2132)
@@ -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: branches/1.2/bin/varnishd/cache_fetch.c
===================================================================
--- branches/1.2/bin/varnishd/cache_fetch.c	2007-10-19 09:48:35 UTC (rev 2131)
+++ branches/1.2/bin/varnishd/cache_fetch.c	2007-10-19 10:00:20 UTC (rev 2132)
@@ -261,6 +261,7 @@
 	int mklen, is_head;
 	struct http_conn htc[1];
 	int i;
+	char *ptr, *endp;
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
@@ -287,6 +288,34 @@
 		return (__LINE__);
 	WRK_Reset(w, &vc->fd);
 	http_Write(w, hp, 0);
+
+	/*
+	 * If a POST request was passed to fetch, we must send any
+	 * pipelined bytes to the backend as well
+	 */
+	if (http_GetHdr(sp->http, H_Content_Length, &ptr)) {
+		unsigned long content_length;
+		char buf[8192];
+		int read;
+
+		content_length = strtoul(ptr, &endp, 10);
+		/* XXX should check result of conversion */
+		while (content_length) {
+			if (content_length > sizeof buf)
+				read = sizeof buf;
+			else
+				read = content_length;
+			read = HTC_Read(sp->htc, buf, read);
+			WRK_Write(w, buf, read);
+			if (WRK_Flush(w)) {
+				VBE_UpdateHealth(sp, vc, -1);
+				VBE_ClosedFd(sp->wrk, vc);
+				return (__LINE__);
+			}
+			content_length -= read;
+		}
+	}
+
 	if (WRK_Flush(w)) {
 		VBE_UpdateHealth(sp, vc, -1);
 		VBE_ClosedFd(sp->wrk, vc);

Modified: branches/1.2/bin/varnishd/cache_httpconn.c
===================================================================
--- branches/1.2/bin/varnishd/cache_httpconn.c	2007-10-19 09:48:35 UTC (rev 2131)
+++ branches/1.2/bin/varnishd/cache_httpconn.c	2007-10-19 10:00:20 UTC (rev 2132)
@@ -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