]> err.no Git - varnish/commitdiff
Duh! We need to count stats in per workerthread and summarize into
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 16 Sep 2006 21:45:27 +0000 (21:45 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 16 Sep 2006 21:45:27 +0000 (21:45 +0000)
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

varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_center.c
varnish-cache/bin/varnishd/cache_pass.c
varnish-cache/bin/varnishd/cache_response.c
varnish-cache/bin/varnishd/cache_session.c

index a4a3a190bce26cf263db50959b8a09e8a53c6f84..73c5d50f7c2c68b385154ca2953f50ae66874a3c 100644 (file)
@@ -114,6 +114,7 @@ struct worker {
 
        struct VCL_conf         *vcl;
        struct srcaddr          *srcaddr;
+       struct acct             acct;
 };
 
 struct workreq {
index a7ccde3d40bad680e235b1819014f3e6cb7214de..29ebba4014c49760885035974400ff9efcef4576 100644 (file)
@@ -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);
index 25e6316ce05fd8222ab9cc8895129e7ab10e10ea..c116cfb2edbd8470673ea3aea64f09ef9290786f 100644 (file)
@@ -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);
index 806580398bcbcf3443333f03444ad425955a3de2..f0dcacea0a0b04339ba3c1f1c9835cd56ca3ad67 100644 (file)
@@ -127,7 +127,7 @@ RES_Error(struct sess *sp, int code, const char *expl)
                "</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 @@ 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
index bb05578642484ab3c17ee9b04fc6c1c8d6730726..0ed3cadd0682bbced6751565124186377fb19424 100644 (file)
@@ -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;