r2045 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Wed Sep 26 20:59:28 CEST 2007


Author: phk
Date: 2007-09-26 20:59:28 +0200 (Wed, 26 Sep 2007)
New Revision: 2045

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/cache_fetch.c
   trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
Convert the received request and pipelined bytes into txt's.


Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2007-09-26 18:56:18 UTC (rev 2044)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2007-09-26 18:59:28 UTC (rev 2045)
@@ -118,8 +118,8 @@
 #define HTTP_MAGIC		0x6428b5c9
 
 	struct ws		ws[1];
-	char			*rx_s, *rx_e;	/* Received Request */
-	char			*pl_s, *pl_e;	/* Pipelined bytes */
+	txt			rx;		/* Received Request */
+	txt			pl;		/* Pipelined bytes */
 
 	unsigned char		conds;		/* If-* headers present */
 	enum httpwhence 	logtag;

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2007-09-26 18:56:18 UTC (rev 2044)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2007-09-26 18:59:28 UTC (rev 2045)
@@ -229,7 +229,7 @@
 		sp->step = STP_RECV;
 		return (0);
 	}
-	if (sp->http->pl_s < sp->http->pl_e) {
+	if (sp->http->pl.b < sp->http->pl.e) {
 		VSL_stats->sess_readahead++;
 		sp->step = STP_AGAIN;
 		return (0);

Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c	2007-09-26 18:56:18 UTC (rev 2044)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c	2007-09-26 18:59:28 UTC (rev 2045)
@@ -326,7 +326,7 @@
 	CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
 	/* Filter into object */
 	hp2 = &sp->obj->http;
-	len = pdiff(hp->rx_s, hp->rx_e);
+	len = pdiff(hp->rx.b, hp->rx.e);
 	len += 256;		/* margin for content-length etc */
 
 	CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);

Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c	2007-09-26 18:56:18 UTC (rev 2044)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c	2007-09-26 18:59:28 UTC (rev 2045)
@@ -321,20 +321,20 @@
 http_GetTail(struct http *hp, unsigned len, char **b, char **e)
 {
 
-	if (hp->pl_s >= hp->pl_e)
+	if (hp->pl.b >= hp->pl.e)
 		return (0);
 
 	if (len == 0)
-		len = pdiff(hp->pl_s, hp->pl_e);
+		len = pdiff(hp->pl.b, hp->pl.e);
 
-	if (hp->pl_s + len > hp->pl_e)
-		len = pdiff(hp->pl_s, hp->pl_e);
+	if (hp->pl.b + len > hp->pl.e)
+		len = pdiff(hp->pl.b, hp->pl.e);
 	if (len == 0)
 		return (0);
-	*b = hp->pl_s;
-	*e = hp->pl_s + len;
-	hp->pl_s += len;
-	assert(hp->pl_s <= hp->pl_e);
+	*b = hp->pl.b;
+	*e = hp->pl.b + len;
+	hp->pl.b += len;
+	assert(hp->pl.b <= hp->pl.e);
 	return (1);
 }
 
@@ -349,17 +349,17 @@
 	char *b = p;
 
 	u = 0;
-	if (hp->pl_s < hp->pl_e) {
-		u = pdiff(hp->pl_s, hp->pl_e);
+	if (hp->pl.b < hp->pl.e) {
+		u = pdiff(hp->pl.b, hp->pl.e);
 		if (u > len)
 			u = len;
-		memcpy(b, hp->pl_s, u);
-		hp->pl_s += u;
+		memcpy(b, hp->pl.b, u);
+		hp->pl.b += u;
 		b += u;
 		len -= u;
 	}
-	if (hp->pl_e == hp->pl_s)
-		hp->pl_s = hp->pl_e = NULL;
+	if (hp->pl.e == hp->pl.b)
+		hp->pl.b = hp->pl.e = NULL;
 	if (len > 0) {
 		i = read(fd, b, len);
 		if (i < 0)		/* XXX i == 0 ?? */
@@ -410,8 +410,8 @@
 	hp->nhd = HTTP_HDR_FIRST;
 	hp->conds = 0;
 	r = NULL;		/* For FlexeLint */
-	assert(p < hp->rx_e);	/* http_header_complete() guarantees this */
-	for (; p < hp->rx_e; p = r) {
+	assert(p < hp->rx.e);	/* http_header_complete() guarantees this */
+	for (; p < hp->rx.e; p = r) {
 		/* XXX: handle continuation lines */
 		q = strchr(p, '\n');
 		assert(q != NULL);
@@ -449,11 +449,11 @@
 	char *p;
 
 	CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
-	/* Assert a NUL at rx_e */
-	assert(hp->rx_s < hp->rx_e);
+	/* Assert a NUL at rx.e */
+	assert(hp->rx.b < hp->rx.e);
 	hp->logtag = HTTP_Rx;
 
-	for (p = hp->rx_s ; isspace(*p); p++)
+	for (p = hp->rx.b ; isspace(*p); p++)
 		continue;
 
 	/* First, the request type (GET/HEAD etc) */
@@ -468,7 +468,7 @@
 	while (isspace(*p) && *p != '\n')
 		p++;
 	if (*p == '\n') {
-		WSLR(w, SLT_HttpGarbage, fd, hp->rx_s, hp->rx_e);
+		WSLR(w, SLT_HttpGarbage, fd, hp->rx.b, hp->rx.e);
 		return (400);
 	}
 	hp->hd[HTTP_HDR_URL].b = p;
@@ -477,7 +477,7 @@
 	hp->hd[HTTP_HDR_URL].e = p;
 	WSLH(w, HTTP_T_URL, fd, hp, HTTP_HDR_URL);
 	if (*p == '\n') {
-		WSLR(w, SLT_HttpGarbage, fd, hp->rx_s, hp->rx_e);
+		WSLR(w, SLT_HttpGarbage, fd, hp->rx.b, hp->rx.e);
 		return (400);
 	}
 	*p++ = '\0';
@@ -486,7 +486,7 @@
 	while (isspace(*p) && *p != '\n')
 		p++;
 	if (*p == '\n') {
-		WSLR(w, SLT_HttpGarbage, fd, hp->rx_s, hp->rx_e);
+		WSLR(w, SLT_HttpGarbage, fd, hp->rx.b, hp->rx.e);
 		return (400);
 	}
 	hp->hd[HTTP_HDR_PROTO].b = p;
@@ -499,7 +499,7 @@
 	while (isspace(*p) && *p != '\n')
 		p++;
 	if (*p != '\n') {
-		WSLR(w, SLT_HttpGarbage, fd, hp->rx_s, hp->rx_e);
+		WSLR(w, SLT_HttpGarbage, fd, hp->rx.b, hp->rx.e);
 		return (400);
 	}
 	*p++ = '\0';
@@ -515,15 +515,15 @@
 	char *p, *q;
 
 	CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
-	/* Assert a NUL at rx_e */
-	assert(hp->rx_s < hp->rx_e);
+	/* Assert a NUL at rx.e */
+	assert(hp->rx.b < hp->rx.e);
 	hp->logtag = HTTP_Rx;
 
-	for (p = hp->rx_s ; isspace(*p); p++)
+	for (p = hp->rx.b ; isspace(*p); p++)
 		continue;
 
 	if (memcmp(p, "HTTP/1.", 7)) {
-		WSLR(w, SLT_HttpGarbage, fd, hp->rx_s, hp->rx_e);
+		WSLR(w, SLT_HttpGarbage, fd, hp->rx.b, hp->rx.e);
 		return (400);
 	}
 	/* First, protocol */
@@ -571,12 +571,12 @@
 	char *p;
 
 	CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
-	assert(*hp->rx_e == '\0');
+	assert(*hp->rx.e == '\0');
 	/* Skip any leading white space */
-	for (p = hp->rx_s ; p < hp->rx_e && isspace(*p); p++)
+	for (p = hp->rx.b ; p < hp->rx.e && isspace(*p); p++)
 		continue;
-	if (p >= hp->rx_e) {
-		hp->rx_e = hp->rx_s;
+	if (p >= hp->rx.e) {
+		hp->rx.e = hp->rx.b;
 		return (0);
 	}
 	while (1) {
@@ -591,11 +591,11 @@
 			break;
 	}
 	p++;
-	WS_ReleaseP(hp->ws, hp->rx_e);
-	if (p != hp->rx_e) {
-		hp->pl_s = p;
-		hp->pl_e = hp->rx_e;
-		hp->rx_e = p;
+	WS_ReleaseP(hp->ws, hp->rx.e);
+	if (p != hp->rx.e) {
+		hp->pl.b = p;
+		hp->pl.e = hp->rx.e;
+		hp->rx.e = p;
 	}
 	/* XXX: Check this stuff... */
 	return (1);
@@ -612,22 +612,22 @@
 	WS_Assert(hp->ws);
 	WS_Reset(hp->ws);
 	WS_Reserve(hp->ws, 0);
-	hp->rx_s = hp->ws->f;
-	hp->rx_e = hp->rx_s;
-	if (hp->pl_s != NULL) {
-		l = pdiff(hp->pl_s, hp->pl_e);
-		memmove(hp->rx_s, hp->pl_s, l);
-		hp->rx_e = hp->rx_s + l;
-		hp->pl_s = hp->pl_e = NULL;
+	hp->rx.b = hp->ws->f;
+	hp->rx.e = hp->rx.b;
+	if (hp->pl.b != NULL) {
+		l = pdiff(hp->pl.b, hp->pl.e);
+		memmove(hp->rx.b, hp->pl.b, l);
+		hp->rx.e = hp->rx.b + l;
+		hp->pl.b = hp->pl.e = NULL;
 	}
-	*hp->rx_e = '\0';
+	*hp->rx.e = '\0';
 }
 
 int
 http_RecvPrepAgain(struct http *hp)
 {
 	http_RecvPrep(hp);
-	if (hp->rx_s == hp->rx_e)
+	if (hp->rx.b == hp->rx.e)
 		return (0);
 	return (http_header_complete(hp));
 }
@@ -640,35 +640,35 @@
 	unsigned l;
 	int i;
 
-	l = pdiff(hp->rx_e, hp->ws->e) - 1;
+	l = pdiff(hp->rx.e, hp->ws->e) - 1;
 	l /= 2;		/* Don't fill all of workspace with read-ahead */
 	if (l <= 1) {
 		VSL(SLT_HttpError, fd, "Received too much");
-		VSLR(SLT_HttpGarbage, fd, hp->rx_s, hp->rx_e);
-		hp->rx_s = hp->rx_e = NULL;
+		VSLR(SLT_HttpGarbage, fd, hp->rx.b, hp->rx.e);
+		hp->rx.b = hp->rx.e = NULL;
 		WS_Release(hp->ws, 0);
 		return (1);
 	}
 	errno = 0;
-	i = read(fd, hp->rx_e, l - 1);
+	i = read(fd, hp->rx.e, l - 1);
 	if (i > 0) {
-		hp->rx_e += i;
-		*hp->rx_e = '\0';
+		hp->rx.e += i;
+		*hp->rx.e = '\0';
 		if (http_header_complete(hp))
 			return(0);
 		return (-1);
 	}
 
-	if (hp->rx_e != hp->rx_s) {
+	if (hp->rx.e != hp->rx.b) {
 		VSL(SLT_HttpError, fd,
 		    "Received (only) %d bytes, errno %d",
-		    hp->rx_e - hp->rx_s, errno);
-		VSLR(SLT_Debug, fd, hp->rx_s, hp->rx_e);
+		    hp->rx.e - hp->rx.b, errno);
+		VSLR(SLT_Debug, fd, hp->rx.b, hp->rx.e);
 	} else if (errno == 0)
 		VSL(SLT_HttpError, fd, "Received nothing");
 	else
 		VSL(SLT_HttpError, fd, "Received errno %d", errno);
-	hp->rx_s = hp->rx_e = NULL;
+	hp->rx.b = hp->rx.e = NULL;
 	WS_Release(hp->ws, 0);
 	return(2);
 }




More information about the varnish-commit mailing list