r5029 - in branches/2.1: . varnish-cache/bin/varnishd varnish-cache/bin/varnishtest/tests varnish-cache/include varnish-cache/lib/libvarnish varnish-cache/lib/libvcl

tfheen at varnish-cache.org tfheen at varnish-cache.org
Tue Jul 6 14:51:04 CEST 2010


Author: tfheen
Date: 2010-07-06 14:51:04 +0200 (Tue, 06 Jul 2010)
New Revision: 5029

Modified:
   branches/2.1/
   branches/2.1/varnish-cache/bin/varnishd/cache.h
   branches/2.1/varnish-cache/bin/varnishd/cache_acceptor.c
   branches/2.1/varnish-cache/bin/varnishd/cache_backend.h
   branches/2.1/varnish-cache/bin/varnishd/cache_backend_cfg.c
   branches/2.1/varnish-cache/bin/varnishd/cache_center.c
   branches/2.1/varnish-cache/bin/varnishd/cache_esi.c
   branches/2.1/varnish-cache/bin/varnishd/cache_response.c
   branches/2.1/varnish-cache/bin/varnishd/cache_session.c
   branches/2.1/varnish-cache/bin/varnishd/vparam.h
   branches/2.1/varnish-cache/bin/varnishtest/tests/c00019.vtc
   branches/2.1/varnish-cache/bin/varnishtest/tests/r00325.vtc
   branches/2.1/varnish-cache/bin/varnishtest/tests/r00416.vtc
   branches/2.1/varnish-cache/bin/varnishtest/tests/v00011.vtc
   branches/2.1/varnish-cache/include/vct.h
   branches/2.1/varnish-cache/include/vev.h
   branches/2.1/varnish-cache/lib/libvarnish/tcp.c
   branches/2.1/varnish-cache/lib/libvarnish/vev.c
   branches/2.1/varnish-cache/lib/libvcl/vcc_dir_random.c
Log:
Merge r4989: Fix a problem with accounting of ESI transactions

In particular make the Length header match the actual composite object
sent to the client.




Property changes on: branches/2.1
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk:4637,4640,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981
   + /trunk:4637,4640,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981,4989

Modified: branches/2.1/varnish-cache/bin/varnishd/cache.h
===================================================================
--- branches/2.1/varnish-cache/bin/varnishd/cache.h	2010-07-06 12:44:37 UTC (rev 5028)
+++ branches/2.1/varnish-cache/bin/varnishd/cache.h	2010-07-06 12:51:04 UTC (rev 5029)
@@ -430,8 +430,9 @@
 	struct sessmem		*mem;
 
 	struct workreq		workreq;
-	struct acct		acct;
+	struct acct		acct_tmp;
 	struct acct		acct_req;
+	struct acct		acct_ses;
 
 #if defined(HAVE_EPOLL_CTL)
 	struct epoll_event ev;

Modified: branches/2.1/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- branches/2.1/varnish-cache/bin/varnishd/cache_acceptor.c	2010-07-06 12:44:37 UTC (rev 5028)
+++ branches/2.1/varnish-cache/bin/varnishd/cache_acceptor.c	2010-07-06 12:51:04 UTC (rev 5029)
@@ -177,7 +177,7 @@
 		VSL(SLT_SessionOpen, sp->fd, "%s %s %s",
 		    sp->addr, sp->port, sp->mylsock->name);
 	}
-	sp->acct.first = sp->t_open;
+	sp->acct_ses.first = sp->t_open;
 	if (need_test)
 		sock_test(sp->fd);
 	if (need_linger)


Property changes on: branches/2.1/varnish-cache/bin/varnishd/cache_backend.h
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/bin/varnishd/cache_backend.h:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981
   + /trunk/varnish-cache/bin/varnishd/cache_backend.h:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/bin/varnishd/cache_backend_cfg.c
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981
   + /trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981,4989

Modified: branches/2.1/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- branches/2.1/varnish-cache/bin/varnishd/cache_center.c	2010-07-06 12:44:37 UTC (rev 5028)
+++ branches/2.1/varnish-cache/bin/varnishd/cache_center.c	2010-07-06 12:51:04 UTC (rev 5029)
@@ -241,31 +241,33 @@
 		sp->vcl = NULL;
 	}
 
+	SES_Charge(sp);
+
 	sp->t_end = TIM_real();
 	sp->wrk->lastused = sp->t_end;
 	if (sp->xid == 0) {
 		sp->t_req = sp->t_end;
 		sp->t_resp = sp->t_end;
-	} else {
+	} else if (sp->esis == 0) {
 		dp = sp->t_resp - sp->t_req;
 		da = sp->t_end - sp->t_resp;
 		dh = sp->t_req - sp->t_open;
+		/* XXX: Add StatReq == StatSess */
 		WSP(sp, SLT_Length, "%u", sp->acct_req.bodybytes);
 		WSL(sp->wrk, SLT_ReqEnd, sp->id, "%u %.9f %.9f %.9f %.9f %.9f",
 		    sp->xid, sp->t_req, sp->t_end, dh, dp, da);
 	}
-
 	sp->xid = 0;
 	sp->t_open = sp->t_end;
 	sp->t_resp = NAN;
 	WSL_Flush(sp->wrk, 0);
 
 	/* If we did an ESI include, don't mess up our state */
-	if (sp->esis > 0) {
-		SES_Charge(sp);
+	if (sp->esis > 0) 
 		return (1);
-	}
 
+	memset(&sp->acct_req, 0, sizeof sp->acct_req);
+
 	sp->t_req = NAN;
 
 	if (sp->fd >= 0 && sp->doclose != NULL) {
@@ -277,8 +279,6 @@
 		vca_close_session(sp, sp->doclose);
 	}
 
-	SES_Charge(sp);
-
 	if (sp->fd < 0) {
 		sp->wrk->stats.sess_closed++;
 		sp->wrk = NULL;
@@ -648,7 +648,7 @@
 		AN(sp->obj->ban);
 		HSH_Unbusy(sp);
 	}
-	sp->acct_req.fetch++;
+	sp->acct_tmp.fetch++;
 	sp->wrk->bereq = NULL;
 	sp->wrk->beresp = NULL;
 	sp->wrk->beresp1 = NULL;
@@ -680,7 +680,7 @@
 	/* Receive a HTTP protocol request */
 	HTC_Init(sp->htc, sp->ws, sp->fd);
 	sp->wrk->lastused = sp->t_open;
-	sp->acct_req.sess++;
+	sp->acct_tmp.sess++;
 
 	sp->step = STP_WAIT;
 	return (0);
@@ -947,7 +947,7 @@
 		return (0);
 	}
 	assert(sp->handling == VCL_RET_PASS);
-	sp->acct_req.pass++;
+	sp->acct_tmp.pass++;
 	sp->sendbody = 1;
 	sp->step = STP_FETCH;
 	return (0);
@@ -985,7 +985,7 @@
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
 
-	sp->acct_req.pipe++;
+	sp->acct_tmp.pipe++;
 	WS_Reset(sp->wrk->ws, NULL);
 	sp->wrk->bereq = sp->wrk->http[0];
 	http_Setup(sp->wrk->bereq, sp->wrk->ws);
@@ -1109,7 +1109,7 @@
 	sp->wrk->stats.client_req++;
 	sp->t_req = TIM_real();
 	sp->wrk->lastused = sp->t_req;
-	sp->acct_req.req++;
+	sp->acct_tmp.req++;
 
 	/* Assign XID and log */
 	sp->xid = ++xids;				/* XXX not locked */

Modified: branches/2.1/varnish-cache/bin/varnishd/cache_esi.c
===================================================================
--- branches/2.1/varnish-cache/bin/varnishd/cache_esi.c	2010-07-06 12:44:37 UTC (rev 5028)
+++ branches/2.1/varnish-cache/bin/varnishd/cache_esi.c	2010-07-06 12:51:04 UTC (rev 5029)
@@ -863,6 +863,7 @@
 	char *ws_wm;
 	struct http http_save;
 	struct esidata *ed;
+	unsigned sxid;
 
 	w = sp->wrk;
 	WRW_Reserve(w, &sp->fd);
@@ -873,7 +874,7 @@
 		if (Tlen(eb->verbatim)) {
 			if (sp->http->protover >= 1.1)
 				(void)WRW_Write(w, eb->chunk_length, -1);
-			sp->acct_req.bodybytes += WRW_Write(w,
+			sp->acct_tmp.bodybytes += WRW_Write(w,
 			    eb->verbatim.b, Tlen(eb->verbatim));
 			if (sp->http->protover >= 1.1)
 				(void)WRW_Write(w, "\r\n", -1);
@@ -923,6 +924,7 @@
 		/* Client content already taken care of */
 		http_Unset(sp->http, H_Content_Length);
 
+		sxid = sp->xid;
 		while (1) {
 			sp->wrk = w;
 			CNT_Session(sp);
@@ -933,6 +935,7 @@
 			DSL(0x20, SLT_Debug, sp->id, "loop waiting for ESI");
 			(void)usleep(10000);
 		}
+		sp->xid = sxid;
 		AN(sp->wrk);
 		assert(sp->step == STP_DONE);
 		sp->esis--;

Modified: branches/2.1/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- branches/2.1/varnish-cache/bin/varnishd/cache_response.c	2010-07-06 12:44:37 UTC (rev 5028)
+++ branches/2.1/varnish-cache/bin/varnishd/cache_response.c	2010-07-06 12:51:04 UTC (rev 5029)
@@ -259,7 +259,7 @@
 
 		if (sp->esis == 0)
 			/* no headers for interior ESI includes */
-			sp->acct_req.hdrbytes +=
+			sp->acct_tmp.hdrbytes +=
 			    http_Write(sp->wrk, sp->wrk->resp, 1);
 
 		if (WRW_FlushRelease(sp->wrk)) {
@@ -284,7 +284,7 @@
 		    http_GetHdr(sp->http, H_Range, &r))
 			res_dorange(sp, r, &low, &high);
 
-		sp->acct_req.hdrbytes += http_Write(sp->wrk, sp->wrk->resp, 1);
+		sp->acct_tmp.hdrbytes += http_Write(sp->wrk, sp->wrk->resp, 1);
 	} else if (!sp->disable_esi &&
 	    sp->esis > 0 &&
 	    sp->http->protover >= 1.1 &&
@@ -330,7 +330,7 @@
 
 		ptr += len;
 
-		sp->acct_req.bodybytes += len;
+		sp->acct_tmp.bodybytes += len;
 #ifdef SENDFILE_WORKS
 		/*
 		 * XXX: the overhead of setting up sendfile is not

Modified: branches/2.1/varnish-cache/bin/varnishd/cache_session.c
===================================================================
--- branches/2.1/varnish-cache/bin/varnishd/cache_session.c	2010-07-06 12:44:37 UTC (rev 5028)
+++ branches/2.1/varnish-cache/bin/varnishd/cache_session.c	2010-07-06 12:51:04 UTC (rev 5029)
@@ -84,11 +84,12 @@
 void
 SES_Charge(struct sess *sp)
 {
-	struct acct *a = &sp->acct_req;
+	struct acct *a = &sp->acct_tmp;
 
-#define ACCT(foo)	\
+#define ACCT(foo)				\
 	sp->wrk->stats.s_##foo += a->foo;	\
-	sp->acct.foo += a->foo;		\
+	sp->acct_req.foo += a->foo;		\
+	sp->acct_ses.foo += a->foo;		\
 	a->foo = 0;
 #include "acct_fields.h"
 #undef ACCT
@@ -248,7 +249,7 @@
 void
 SES_Delete(struct sess *sp)
 {
-	struct acct *b = &sp->acct;
+	struct acct *b = &sp->acct_ses;
 	struct sessmem *sm;
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);


Property changes on: branches/2.1/varnish-cache/bin/varnishd/vparam.h
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/bin/varnishd/vparam.h:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981
   + /trunk/varnish-cache/bin/varnishd/vparam.h:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/bin/varnishtest/tests/c00019.vtc
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/bin/varnishtest/tests/c00019.vtc:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981
   + /trunk/varnish-cache/bin/varnishtest/tests/c00019.vtc:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/bin/varnishtest/tests/r00325.vtc
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/bin/varnishtest/tests/r00325.vtc:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981
   + /trunk/varnish-cache/bin/varnishtest/tests/r00325.vtc:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/bin/varnishtest/tests/r00416.vtc
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/bin/varnishtest/tests/r00416.vtc:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981
   + /trunk/varnish-cache/bin/varnishtest/tests/r00416.vtc:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/bin/varnishtest/tests/v00011.vtc
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/bin/varnishtest/tests/v00011.vtc:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981
   + /trunk/varnish-cache/bin/varnishtest/tests/v00011.vtc:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/include/vct.h
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/include/vct.h:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981
   + /trunk/varnish-cache/include/vct.h:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/include/vev.h
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/include/vev.h:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981
   + /trunk/varnish-cache/include/vev.h:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/lib/libvarnish/tcp.c
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/lib/libvarnish/tcp.c:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981
   + /trunk/varnish-cache/lib/libvarnish/tcp.c:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/lib/libvarnish/vev.c
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/lib/libvarnish/vev.c:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981
   + /trunk/varnish-cache/lib/libvarnish/vev.c:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/lib/libvcl/vcc_dir_random.c
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/lib/libvcl/vcc_dir_random.c:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981
   + /trunk/varnish-cache/lib/libvcl/vcc_dir_random.c:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4818,4829,4865-4867,4977,4980-4981,4989




More information about the varnish-commit mailing list