r575 - in trunk/varnish-cache: bin/varnishd include

phk at projects.linpro.no phk at projects.linpro.no
Mon Jul 31 22:27:02 CEST 2006


Author: phk
Date: 2006-07-31 22:27:02 +0200 (Mon, 31 Jul 2006)
New Revision: 575

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_fetch.c
   trunk/varnish-cache/bin/varnishd/cache_http.c
   trunk/varnish-cache/include/shmlog_tags.h
Log:
Log the headers we store in the object under ObjHeader so that
we don't get two confusing batches of TxHeader in the sessions logentries.


Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2006-07-31 19:18:26 UTC (rev 574)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2006-07-31 20:27:02 UTC (rev 575)
@@ -66,7 +66,8 @@
 	char			*f;		/* first (F)ree byte */
 	char			*e;		/* (E)nd of buffer */
 
-	unsigned		conds;		/* If-* headers present */
+	unsigned char		conds;		/* If-* headers present */
+	unsigned char		objlog;
 
 	struct http_hdr		hd[MAX_HTTP_HDRS];
 	unsigned		nhd;

Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c	2006-07-31 19:18:26 UTC (rev 574)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c	2006-07-31 20:27:02 UTC (rev 575)
@@ -222,8 +222,15 @@
 	if (http_GetHdr(vc->http, H_Last_Modified, &b))
 		sp->obj->last_modified = TIM_parse(b);
 
+	/*
+	 * We borrow the sessions workspace and http header for building the
+	 * headers to store in the object, then copy them over there.
+	 * The actual headers to reply with are built later on over in
+	 * cache_response.c
+	 */
 	sp->http->f = sp->http->v;
 	sp->http->nhd = HTTP_HDR_FIRST;
+	sp->http->objlog = 1;	/* log as SLT_ObjHeader */
 	http_CopyResp(sp->fd, sp->http, vc->http);
 	http_FilterHeader(sp->fd, sp->http, vc->http, HTTPH_A_INS);
 	
@@ -234,10 +241,13 @@
 			cls = fetch_chunked(sp, vc->fd, vc->http);
 		else 
 			cls = fetch_eof(sp, vc->fd, vc->http);
-		http_PrintfHeader(sp->fd, sp->http, "Content-Length: %u", sp->obj->len);
+		http_PrintfHeader(sp->fd, sp->http,
+		    "Content-Length: %u", sp->obj->len);
 	} else
 		cls = 0;
+	sp->http->objlog = 0;
 	http_CopyHttp(&sp->obj->http, sp->http);
+	sp->http->f = sp->http->v;
 
 	if (http_GetHdr(vc->http, H_Connection, &b) && !strcasecmp(b, "close"))
 		cls = 1;

Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c	2006-07-31 19:18:26 UTC (rev 574)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c	2006-07-31 20:27:02 UTC (rev 575)
@@ -22,6 +22,9 @@
 #define VSLH(ax, bx, cx, dx) \
 	VSLR((ax), (bx), (cx)->hd[(dx)].b, (cx)->hd[(dx)].e);
 
+#define VSLHT(bx, cx, dx) \
+	VSLH((cx)->objlog ? SLT_ObjHeader : SLT_TxHeader, bx, cx, dx)
+
 /*--------------------------------------------------------------------*/
 
 void
@@ -588,7 +591,7 @@
 	if (to->nhd < MAX_HTTP_HDRS) {
 		to->hd[to->nhd].b = fm->hd[n].b;
 		to->hd[to->nhd].e = fm->hd[n].e;
-		VSLH(SLT_TxHeader, fd, to, to->nhd);
+		VSLHT(fd, to, to->nhd);
 		to->nhd++;
 	} else  {
 		VSL_stats->losthdr++;
@@ -624,7 +627,7 @@
 		n = to->nhd++;
 	to->hd[n].b = (void*)(uintptr_t)hdr;
 	to->hd[n].e = strchr(hdr, '\0');
-	VSLH(SLT_TxHeader, fd, to, n);
+	VSLHT(fd, to, n);
 }
 
 /*--------------------------------------------------------------------*/
@@ -646,7 +649,7 @@
 		to->hd[to->nhd].b = to->f;
 		to->hd[to->nhd].e = to->f + n;
 		to->f += n + 1;
-		VSLH(SLT_TxHeader, fd, to, to->nhd);
+		VSLHT(fd, to, to->nhd);
 		to->nhd++;
 	}
 	va_end(ap);

Modified: trunk/varnish-cache/include/shmlog_tags.h
===================================================================
--- trunk/varnish-cache/include/shmlog_tags.h	2006-07-31 19:18:26 UTC (rev 574)
+++ trunk/varnish-cache/include/shmlog_tags.h	2006-07-31 20:27:02 UTC (rev 575)
@@ -32,6 +32,7 @@
 SLTM(Protocol)
 SLTM(RxHeader)
 SLTM(TxHeader)
+SLTM(ObjHeader)
 SLTM(LostHeader)
 SLTM(TTL)
 SLTM(VCL_acl)




More information about the varnish-commit mailing list