From: phk Date: Sat, 16 Sep 2006 21:45:27 +0000 (+0000) Subject: Duh! We need to count stats in per workerthread and summarize into X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6957081abfea811e7f7aee1142e6ae67c6e0c58;p=varnish Duh! We need to count stats in per workerthread and summarize into session, otherwise we cannot correctly summarize into srcaddr and global. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1040 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index a4a3a190..73c5d50f 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -114,6 +114,7 @@ struct worker { struct VCL_conf *vcl; struct srcaddr *srcaddr; + struct acct acct; }; struct workreq { diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index a7ccde3d..29ebba40 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -284,7 +284,7 @@ cnt_fetch(struct sess *sp) 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 @@ cnt_first(struct sess *sp) 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 @@ static int cnt_passbody(struct sess *sp) { - sp->acct.pass++; + sp->wrk->acct.pass++; AN(sp->vbc); PassBody(sp); AZ(sp->vbc); @@ -610,7 +610,7 @@ static int cnt_pipe(struct sess *sp) { - sp->acct.pipe++; + sp->wrk->acct.pipe++; PipeSession(sp); sp->step = STP_DONE; return (0); @@ -662,7 +662,7 @@ cnt_recv(struct sess *sp) 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); diff --git a/varnish-cache/bin/varnishd/cache_pass.c b/varnish-cache/bin/varnishd/cache_pass.c index 25e6316c..c116cfb2 100644 --- a/varnish-cache/bin/varnishd/cache_pass.c +++ b/varnish-cache/bin/varnishd/cache_pass.c @@ -49,7 +49,7 @@ pass_straight(struct sess *sp, int fd, struct http *hp, char *bi) 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 @@ pass_chunked(struct sess *sp, int fd, struct http *hp) /* 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 @@ pass_chunked(struct sess *sp, int fd, struct http *hp) 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 @@ PassBody(struct sess *sp) 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); diff --git a/varnish-cache/bin/varnishd/cache_response.c b/varnish-cache/bin/varnishd/cache_response.c index 80658039..f0dcacea 100644 --- a/varnish-cache/bin/varnishd/cache_response.c +++ b/varnish-cache/bin/varnishd/cache_response.c @@ -127,7 +127,7 @@ RES_Error(struct sess *sp, int code, const char *expl) "\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 @@ res_do_304(struct sess *sp) 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 @@ RES_WriteObj(struct sess *sp) 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 @@ RES_WriteObj(struct sess *sp) 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 diff --git a/varnish-cache/bin/varnishd/cache_session.c b/varnish-cache/bin/varnishd/cache_session.c index bb055786..0ed3cadd 100644 --- a/varnish-cache/bin/varnishd/cache_session.c +++ b/varnish-cache/bin/varnishd/cache_session.c @@ -195,19 +195,20 @@ ses_sum_acct(struct acct *sum, struct acct *inc) 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); - 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); + 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); } LOCK(&stat_mtx); VSL_stats->s_sess += a->sess;