r1040 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Sat Sep 16 23:45:28 CEST 2006


Author: phk
Date: 2006-09-16 23:45:27 +0200 (Sat, 16 Sep 2006)
New Revision: 1040

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/cache_pass.c
   trunk/varnish-cache/bin/varnishd/cache_response.c
   trunk/varnish-cache/bin/varnishd/cache_session.c
Log:
Duh!  We need to count stats in per workerthread and summarize into
session, otherwise we cannot correctly summarize into srcaddr and global.


Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2006-09-16 21:35:44 UTC (rev 1039)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2006-09-16 21:45:27 UTC (rev 1040)
@@ -114,6 +114,7 @@
 
 	struct VCL_conf		*vcl;
 	struct srcaddr		*srcaddr;
+	struct acct		acct;
 };
 
 struct workreq {

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2006-09-16 21:35:44 UTC (rev 1039)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2006-09-16 21:45:27 UTC (rev 1040)
@@ -284,7 +284,7 @@
 		AZ(sp->vbc);
 		HSH_Ref(sp->obj); /* get another, STP_DELIVER will deref */
 		HSH_Unbusy(sp->obj);
-		sp->acct.fetch++;
+		sp->wrk->acct.fetch++;
 		sp->step = STP_DELIVER;
 		return (0);
 	}
@@ -304,7 +304,7 @@
 	assert(sp->xid == 0);
 	VCA_Prep(sp);
 	sp->wrk->idle = sp->t_open.tv_sec;
-	sp->acct.sess++;
+	sp->wrk->acct.sess++;
 	SES_RefSrcAddr(sp);
 	do 
 		i = http_RecvSome(sp->fd, sp->http);
@@ -583,7 +583,7 @@
 cnt_passbody(struct sess *sp)
 {
 
-	sp->acct.pass++;
+	sp->wrk->acct.pass++;
 	AN(sp->vbc);
 	PassBody(sp);
 	AZ(sp->vbc);
@@ -610,7 +610,7 @@
 cnt_pipe(struct sess *sp)
 {
 
-	sp->acct.pipe++;
+	sp->wrk->acct.pipe++;
 	PipeSession(sp);
 	sp->step = STP_DONE;
 	return (0);
@@ -662,7 +662,7 @@
 	AZ(sp->obj);
 	AZ(sp->vbc);
 
-	sp->acct.req++;
+	sp->wrk->acct.req++;
 	done = http_DissectRequest(sp->http, sp->fd);
 	if (done != 0) {
 		RES_Error(sp, done, NULL);

Modified: trunk/varnish-cache/bin/varnishd/cache_pass.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pass.c	2006-09-16 21:35:44 UTC (rev 1039)
+++ trunk/varnish-cache/bin/varnishd/cache_pass.c	2006-09-16 21:45:27 UTC (rev 1040)
@@ -49,7 +49,7 @@
 			vca_close_session(sp, "backend closed");
 			return (1);
 		}
-		sp->acct.bodybytes += WRK_Write(sp->wrk, buf, i);
+		sp->wrk->acct.bodybytes += WRK_Write(sp->wrk, buf, i);
 		if (WRK_Flush(sp->wrk))
 			vca_close_session(sp, "remote closed");
 		cl -= i;
@@ -104,7 +104,7 @@
 
 		/* we just received the final zero-length chunk */
 		if (u == 0) {
-			sp->acct.bodybytes += WRK_Write(sp->wrk, p, q - p);
+			sp->wrk->acct.bodybytes += WRK_Write(sp->wrk, p, q - p);
 			break;
 		}
 
@@ -118,7 +118,7 @@
 			j = u;
 			if (bp - p < j)
 				j = bp - p;
-			sp->acct.bodybytes += WRK_Write(sp->wrk, p, j);
+			sp->wrk->acct.bodybytes += WRK_Write(sp->wrk, p, j);
 			WRK_Flush(sp->wrk);
 			p += j;
 			assert(u >= j);
@@ -164,7 +164,7 @@
 	if (http_HdrIs(vc->http, H_Transfer_Encoding, "chunked"))
 		http_PrintfHeader(sp->fd, sp->http, "Transfer-Encoding: chunked");
 	WRK_Reset(sp->wrk, &sp->fd);
-	sp->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1);
+	sp->wrk->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1);
 
 	if (http_GetHdr(vc->http, H_Content_Length, &b))
 		cls = pass_straight(sp, vc->fd, vc->http, b);

Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c	2006-09-16 21:35:44 UTC (rev 1039)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c	2006-09-16 21:45:27 UTC (rev 1040)
@@ -127,7 +127,7 @@
 		"</HTML>\r\n");
 	vsb_finish(sb);
 	WRK_Reset(sp->wrk, &sp->fd);
-	sp->acct.hdrbytes += WRK_Write(sp->wrk, vsb_data(sb), vsb_len(sb));
+	sp->wrk->acct.hdrbytes += WRK_Write(sp->wrk, vsb_data(sb), vsb_len(sb));
 	WRK_Flush(sp->wrk);
 	VSL(SLT_TxStatus, sp->id, "%d", code);
 	VSL(SLT_TxProtocol, sp->id, "HTTP/1.1");
@@ -158,7 +158,7 @@
 	if (sp->doclose != NULL)
 		http_SetHeader(sp->fd, sp->http, "Connection: close");
 	WRK_Reset(sp->wrk, &sp->fd);
-	sp->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1);
+	sp->wrk->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1);
 	if (WRK_Flush(sp->wrk))
 		vca_close_session(sp, "remote closed");
 }
@@ -216,7 +216,7 @@
 	if (sp->doclose != NULL)
 		http_SetHeader(sp->fd, sp->http, "Connection: close");
 	WRK_Reset(sp->wrk, &sp->fd);
-	sp->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1);
+	sp->wrk->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1);
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	
 	if (sp->wantbody) {
@@ -225,7 +225,7 @@
 			CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
 			AN(st->stevedore);
 			u += st->len;
-			sp->acct.bodybytes += st->len;
+			sp->wrk->acct.bodybytes += st->len;
 #ifdef HAVE_SENDFILE
 			/*
 			 * XXX: the overhead of setting up senddile is not

Modified: trunk/varnish-cache/bin/varnishd/cache_session.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_session.c	2006-09-16 21:35:44 UTC (rev 1039)
+++ trunk/varnish-cache/bin/varnishd/cache_session.c	2006-09-16 21:45:27 UTC (rev 1040)
@@ -195,19 +195,20 @@
 void
 SES_Charge(struct sess *sp)
 {
-	struct acct *a = &sp->acct;
-	struct acct *b;
+	struct acct *a = &sp->wrk->acct;
+	struct acct b;
 
+	ses_sum_acct(&sp->acct, a);
 	if (sp->srcaddr != NULL) {
 		CHECK_OBJ(sp->srcaddr, SRCADDR_MAGIC);
 		LOCK(&sp->srcaddr->sah->mtx);
-		b = &sp->srcaddr->acct;
-		ses_sum_acct(b, a);
+		ses_sum_acct(&sp->srcaddr->acct, a);
+		b = sp->srcaddr->acct;
+		UNLOCK(&sp->srcaddr->sah->mtx);
 		VSL(SLT_StatAddr, 0, "%s 0 %d %ju %ju %ju %ju %ju %ju %ju",
-		    sp->srcaddr->addr, sp->t_end.tv_sec - b->first,
-		    b->sess, b->req, b->pipe, b->pass,
-		    b->fetch, b->hdrbytes, b->bodybytes);
-		UNLOCK(&sp->srcaddr->sah->mtx);
+		    sp->srcaddr->addr, sp->t_end.tv_sec - b.first,
+		    b.sess, b.req, b.pipe, b.pass,
+		    b.fetch, b.hdrbytes, b.bodybytes);
 	}
 	LOCK(&stat_mtx);
 	VSL_stats->s_sess += a->sess;




More information about the varnish-commit mailing list