r132 - in trunk/varnish-cache: bin/varnishd include lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Thu Apr 6 11:33:19 CEST 2006


Author: phk
Date: 2006-04-06 11:33:19 +0200 (Thu, 06 Apr 2006)
New Revision: 132

Modified:
   trunk/varnish-cache/bin/varnishd/cache_httpd.c
   trunk/varnish-cache/bin/varnishd/cache_pass.c
   trunk/varnish-cache/bin/varnishd/cache_pipe.c
   trunk/varnish-cache/include/vcl_lang.h
   trunk/varnish-cache/lib/libvcl/vcl_fixed_token.c
Log:
Rename hdr_end to a more sensible rcv_ptr which points to the first
unaccounted for character in the buffer.

Do Id Keyword



Modified: trunk/varnish-cache/bin/varnishd/cache_httpd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_httpd.c	2006-04-06 09:30:46 UTC (rev 131)
+++ trunk/varnish-cache/bin/varnishd/cache_httpd.c	2006-04-06 09:33:19 UTC (rev 132)
@@ -165,7 +165,7 @@
 			continue;
 		break;
 	}
-	sp->hdr_end = ++p - sp->rcv;
+	sp->rcv_ptr = ++p - sp->rcv;
 
 	event_del(sp->rd_e);
 	sp->sesscb(sp);

Modified: trunk/varnish-cache/bin/varnishd/cache_pass.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pass.c	2006-04-06 09:30:46 UTC (rev 131)
+++ trunk/varnish-cache/bin/varnishd/cache_pass.c	2006-04-06 09:33:19 UTC (rev 132)
@@ -45,11 +45,13 @@
 		 * If client wants only this one request, piping is safer
 		 * and cheaper
 		 */
+		VSL(SLT_HandlingPass, sp->fd, "pipe");
 		PipeSession(w, sp);
 		return;
 	}
 	fd = VBE_GetFd(sp->backend, &fd_token);
 	assert(fd != -1);
+	VSL(SLT_HandlingPass, sp->fd, "%d", fd);
 
 	HttpdBuildSbuf(0, 1, w->sb, sp);
 	i = write(fd, sbuf_data(w->sb), sbuf_len(w->sb));
@@ -60,6 +62,10 @@
 	memset(&sp2, 0, sizeof sp2);
 	sp2.rd_e = &w->e1;
 	sp2.fd = fd;
+	/*
+	 * XXX: It might be cheaper to avoid the event_engine and simply
+	 * XXX: read(2) the header
+	 */
 	HttpdGetHead(&sp2, w->eb, PassReturn);
 	event_base_loop(w->eb, 0);
 	HttpdAnalyze(&sp2, 2);
@@ -74,11 +80,12 @@
 		i &= ~O_NONBLOCK;
 		i = fcntl(sp2.fd, F_SETFL, i);
 		assert(i != -1);
-		i = sp2.rcv_len - sp2.hdr_end;
+		i = sp2.rcv_len - sp2.rcv_ptr;
 		if (i > 0) {
-			j = write(sp->fd, sp2.rcv + sp2.hdr_end, i);
+			j = write(sp->fd, sp2.rcv + sp2.rcv_ptr, i);
 			assert(j == i);
 			cl -= i;
+			sp2.rcv_ptr += i;
 		}
 		while (cl > 0) {
 			j = sizeof buf;
@@ -97,13 +104,10 @@
 		assert(cl == 0);
 	}
 
-	if (sp->rcv_len > sp->hdr_end) {
-		memmove(sp->rcv, sp->rcv + sp->hdr_end,
-		    sp->rcv_len - sp->hdr_end);
-		sp->rcv_len -= sp->hdr_end;
-		sp->rcv[sp->rcv_len] = '\0';
-	} else {
-		sp->rcv_len = 0;
-		sp->rcv[sp->rcv_len] = '\0';
-	}
+	/* XXX: this really belongs in the acceptor */
+	if (sp->rcv_len > sp->rcv_ptr)
+		memmove(sp->rcv, sp->rcv + sp->rcv_ptr,
+		    sp->rcv_len - sp->rcv_ptr);
+	sp->rcv_len -= sp->rcv_ptr;
+	sp->rcv_ptr = 0;
 }

Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pipe.c	2006-04-06 09:30:46 UTC (rev 131)
+++ trunk/varnish-cache/bin/varnishd/cache_pipe.c	2006-04-06 09:33:19 UTC (rev 132)
@@ -14,6 +14,7 @@
 #include <event.h>
 
 #include "libvarnish.h"
+#include "shmlog.h"
 #include "vcl_lang.h"
 #include "cache.h"
 
@@ -50,13 +51,14 @@
 
 	fd = VBE_GetFd(sp->backend, &fd_token);
 	assert(fd != -1);
+	VSL(SLT_HandlingPipe, sp->fd, "%d", fd);
 
 	HttpdBuildSbuf(0, 0, w->sb, sp);
 	i = write(fd, sbuf_data(w->sb), sbuf_len(w->sb));
 	assert(i == sbuf_len(w->sb));
-	i = sp->rcv_len - sp->hdr_end;
+	i = sp->rcv_len - sp->rcv_ptr;
 	if (i > 0) {
-		j = write(sp->fd, sp->rcv + sp->hdr_end, i);
+		j = write(sp->fd, sp->rcv + sp->rcv_ptr, i);
 		assert(j == i);
 	}
 

Modified: trunk/varnish-cache/include/vcl_lang.h
===================================================================
--- trunk/varnish-cache/include/vcl_lang.h	2006-04-06 09:30:46 UTC (rev 131)
+++ trunk/varnish-cache/include/vcl_lang.h	2006-04-06 09:33:19 UTC (rev 132)
@@ -49,7 +49,7 @@
 	/* Receive buffer for HTTP header */
 	char			rcv[VCA_RXBUFSIZE + 1];
 	unsigned		rcv_len;
-	unsigned		hdr_end;
+	unsigned		rcv_ptr;
 
 	/* HTTP request info, points into rcv */
 	struct httphdr		http;


Property changes on: trunk/varnish-cache/include/vcl_lang.h
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: trunk/varnish-cache/lib/libvcl/vcl_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcl_fixed_token.c	2006-04-06 09:30:46 UTC (rev 131)
+++ trunk/varnish-cache/lib/libvcl/vcl_fixed_token.c	2006-04-06 09:33:19 UTC (rev 132)
@@ -477,7 +477,7 @@
 	fputs("	/* Receive buffer for HTTP header */\n", f);
 	fputs("	char			rcv[VCA_RXBUFSIZE + 1];\n", f);
 	fputs("	unsigned		rcv_len;\n", f);
-	fputs("	unsigned		hdr_end;\n", f);
+	fputs("	unsigned		rcv_ptr;\n", f);
 	fputs("\n", f);
 	fputs("	/* HTTP request info, points into rcv */\n", f);
 	fputs("	struct httphdr		http;\n", f);


Property changes on: trunk/varnish-cache/lib/libvcl/vcl_fixed_token.c
___________________________________________________________________
Name: svn:keywords
   + Id




More information about the varnish-commit mailing list