r148 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Tue Apr 25 08:52:27 CEST 2006


Author: phk
Date: 2006-04-25 08:52:26 +0200 (Tue, 25 Apr 2006)
New Revision: 148

Modified:
   trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
Add an end pointer so allocation size can be changed on the fly


Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c	2006-04-25 06:48:56 UTC (rev 147)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c	2006-04-25 06:52:26 UTC (rev 148)
@@ -30,6 +30,7 @@
 	void			*arg;
 
 	char			*s;		/* start of buffer */
+	char			*e;		/* end of buffer */
 	char			*v;		/* valid bytes */
 	char			*t;		/* start of trailing data */
 
@@ -57,7 +58,9 @@
 	hp->s = malloc(http_bufsize);
 	assert(hp->s != NULL);
 
+	hp->e = hp->s + http_bufsize;
 	hp->v = hp->s;
+	hp->t = hp->s;
 
 	hp->hdr = malloc(sizeof *hp->hdr * http_nhdr);
 	assert(hp->hdr != NULL);
@@ -230,8 +233,8 @@
 	char *p;
 	int i;
 
-	assert(hp->v < hp->s + http_bufsize);
-	i = read(fd, hp->v, (hp->s + http_bufsize) - hp->v);
+	assert(hp->v < hp->e);
+	i = read(fd, hp->v, hp->e - hp->v);
 	if (i <= 0) {
 		if (hp->v != hp->s)
 			VSL(SLT_SessionClose, fd,
@@ -263,6 +266,11 @@
 	}
 	hp->t = ++p;
 
+#if 0
+printf("Head:\n%#H\n", hp->s, hp->t - hp->s);
+printf("Tail:\n%#H\n", hp->t, hp->v - hp->t);
+#endif
+
 	event_del(&hp->ev);
 	if (hp->callback != NULL)
 		hp->callback(hp->arg, 1);
@@ -275,8 +283,11 @@
 {
 
 	assert(hp != NULL);
+	VSL(SLT_Debug, fd, "%s s %p t %p v %p", __func__, hp->s, hp->t, hp->v);
+	assert(hp->t == hp->s || hp->t == hp->v);	/* XXX pipelining */
 	hp->callback = func;
 	hp->arg = arg;
+	hp->v = hp->s;
 	hp->t = hp->s;
 	event_set(&hp->ev, fd, EV_READ | EV_PERSIST, http_read_f, hp);
 	event_base_set(eb, &hp->ev);




More information about the varnish-commit mailing list