From: phk Date: Sat, 16 Sep 2006 21:20:37 +0000 (+0000) Subject: Account directly into the session. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4facb52a5b835c040e00b8e75cf75e58c4a33f40;p=varnish Account directly into the session. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1038 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 6746ef02..a581386c 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -112,7 +112,6 @@ struct worker { unsigned niov; size_t liov; - struct acct acct; struct VCL_conf *vcl; }; diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index 29ebba40..a7ccde3d 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->wrk->acct.fetch++; + sp->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->wrk->acct.sess++; + sp->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->wrk->acct.pass++; + sp->acct.pass++; AN(sp->vbc); PassBody(sp); AZ(sp->vbc); @@ -610,7 +610,7 @@ static int cnt_pipe(struct sess *sp) { - sp->wrk->acct.pipe++; + sp->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->wrk->acct.req++; + sp->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 c116cfb2..25e6316c 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->wrk->acct.bodybytes += WRK_Write(sp->wrk, buf, i); + sp->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->wrk->acct.bodybytes += WRK_Write(sp->wrk, p, q - p); + sp->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->wrk->acct.bodybytes += WRK_Write(sp->wrk, p, j); + sp->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->wrk->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1); + sp->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 f0dcacea..80658039 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->wrk->acct.hdrbytes += WRK_Write(sp->wrk, vsb_data(sb), vsb_len(sb)); + sp->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->wrk->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1); + sp->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->wrk->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1); + sp->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->wrk->acct.bodybytes += st->len; + sp->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 a20c6744..6b4be702 100644 --- a/varnish-cache/bin/varnishd/cache_session.c +++ b/varnish-cache/bin/varnishd/cache_session.c @@ -198,11 +198,9 @@ ses_sum_acct(struct acct *sum, struct acct *inc) void SES_Charge(struct sess *sp) { - struct acct *a = &sp->wrk->acct; + struct acct *a = &sp->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);