r2125 - trunk/varnish-cache/bin/varnishd

des at projects.linpro.no des at projects.linpro.no
Fri Oct 19 11:05:10 CEST 2007


Author: des
Date: 2007-10-19 11:05:10 +0200 (Fri, 19 Oct 2007)
New Revision: 2125

Modified:
   trunk/varnish-cache/bin/varnishd/cache_fetch.c
Log:
Simplify


Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c	2007-10-19 08:55:46 UTC (rev 2124)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c	2007-10-19 09:05:10 UTC (rev 2125)
@@ -260,9 +260,8 @@
 	struct bereq *bereq;
 	int mklen, is_head;
 	struct http_conn htc[1];
-	int i;
-	int content_length, content_written;
-	int read;
+	unsigned long content_length;
+	int i, read;
 	char *ptr, *endp;
 	char *p = NULL;
 
@@ -297,18 +296,18 @@
 	 * pipelined bytes to the backend as well
 	 */
 	if (http_GetHdr(sp->http, H_Content_Length, &ptr)) {
-		endp = ptr + strlen(ptr);
-		content_length = (int)strtol(ptr, &endp, 10);
-		content_written = 0;
-		while (content_written < content_length) {
+		content_length = strtoul(ptr, &endp, 10);
+		/* XXX should check result of conversion */
+		while (content_length) {
 			p = malloc(content_length);
 			read = HTC_Read(sp->htc, p, content_length);
-			content_written += WRK_Write(w, p, read);
+			WRK_Write(w, p, read);
 			if (WRK_Flush(w)) {
 				VBE_UpdateHealth(sp, vc, -1);
 				VBE_ClosedFd(sp->wrk, vc);
 				return (__LINE__);
 			}
+			content_length -= read;
 			free(p);
 		}
 	}




More information about the varnish-commit mailing list