Commit d2d5427f authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Tollef Fog Heen

Move acct_tmp to worker instead of session and report # gunziped

bytes rather than storage size when we gunzip for delivery.

Fixes	#992
parent a504a3f8
......@@ -353,6 +353,8 @@ struct worker {
#define RES_ESI_CHILD (1<<5)
#define RES_GUNZIP (1<<6)
/* Temporary accounting */
struct acct acct_tmp;
};
/* Work Request for worker thread ------------------------------------*/
......@@ -601,7 +603,6 @@ struct sess {
struct sessmem *mem;
struct workreq workreq;
struct acct acct_tmp;
struct acct acct_req;
struct acct acct_ses;
......
......@@ -870,7 +870,7 @@ cnt_fetchbody(struct sess *sp)
AN(sp->obj->objcore->ban);
HSH_Unbusy(sp);
}
sp->acct_tmp.fetch++;
sp->wrk->acct_tmp.fetch++;
sp->step = STP_PREPRESP;
return (0);
}
......@@ -927,7 +927,7 @@ cnt_streambody(struct sess *sp)
} else {
sp->doclose = "Stream error";
}
sp->acct_tmp.fetch++;
sp->wrk->acct_tmp.fetch++;
sp->director = NULL;
sp->restarts = 0;
......@@ -969,7 +969,7 @@ cnt_first(struct sess *sp)
HTC_Init(sp->htc, sp->ws, sp->fd, params->http_req_size,
params->http_req_hdr_len);
sp->wrk->lastused = sp->t_open;
sp->acct_tmp.sess++;
sp->wrk->acct_tmp.sess++;
sp->step = STP_WAIT;
return (0);
......@@ -1277,7 +1277,7 @@ cnt_pass(struct sess *sp)
return (0);
}
assert(sp->handling == VCL_RET_PASS);
sp->acct_tmp.pass++;
sp->wrk->acct_tmp.pass++;
sp->sendbody = 1;
sp->step = STP_FETCH;
return (0);
......@@ -1315,7 +1315,7 @@ cnt_pipe(struct sess *sp)
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
sp->acct_tmp.pipe++;
sp->wrk->acct_tmp.pipe++;
WS_Reset(sp->wrk->ws, NULL);
http_Setup(sp->wrk->bereq, sp->wrk->ws);
http_FilterHeader(sp, HTTPH_R_PIPE);
......@@ -1464,7 +1464,7 @@ cnt_start(struct sess *sp)
sp->wrk->stats.client_req++;
sp->t_req = TIM_real();
sp->wrk->lastused = sp->t_req;
sp->acct_tmp.req++;
sp->wrk->acct_tmp.req++;
/* Assign XID and log */
sp->xid = ++xids; /* XXX not locked */
......@@ -1619,6 +1619,9 @@ CNT_Session(struct sess *sp)
AZ(w->is_gunzip);
AZ(w->do_gunzip);
AZ(w->do_esi);
#define ACCT(foo) AZ(w->acct_tmp.foo);
#include "acct_fields.h"
#undef ACCT
assert(WRW_IsReleased(w));
}
......
......@@ -378,6 +378,7 @@ VGZ_WrwGunzip(const struct sess *sp, struct vgz *vg, const void *ibuf,
return (-1);
}
if (obufl == *obufp || i == VGZ_STUCK) {
sp->wrk->acct_tmp.bodybytes += *obufp;
(void)WRW_Write(sp->wrk, obuf, *obufp);
(void)WRW_Flush(sp->wrk);
*obufp = 0;
......
......@@ -175,7 +175,6 @@ res_WriteGunzipObj(struct sess *sp)
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
u += st->len;
sp->acct_tmp.bodybytes += st->len; /* XXX ? */
VSC_C_main->n_objwrite++;
i = VGZ_WrwGunzip(sp, vg,
......@@ -195,7 +194,7 @@ res_WriteGunzipObj(struct sess *sp)
/*--------------------------------------------------------------------*/
static void
res_WriteDirObj(struct sess *sp, ssize_t low, ssize_t high)
res_WriteDirObj(const struct sess *sp, ssize_t low, ssize_t high)
{
ssize_t u = 0;
size_t ptr, off, len;
......@@ -227,7 +226,7 @@ res_WriteDirObj(struct sess *sp, ssize_t low, ssize_t high)
ptr += len;
sp->acct_tmp.bodybytes += len;
sp->wrk->acct_tmp.bodybytes += len;
#ifdef SENDFILE_WORKS
/*
* XXX: the overhead of setting up sendfile is not
......@@ -292,7 +291,7 @@ RES_WriteObj(struct sess *sp)
* Send HTTP protocol header, unless interior ESI object
*/
if (!(sp->wrk->res_mode & RES_ESI_CHILD))
sp->acct_tmp.hdrbytes +=
sp->wrk->acct_tmp.hdrbytes +=
http_Write(sp->wrk, sp->wrk->resp, 1);
if (!sp->wantbody)
......@@ -348,7 +347,7 @@ RES_StreamStart(struct sess *sp)
http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp,
"Content-Length: %s", sp->wrk->h_content_length);
sp->acct_tmp.hdrbytes +=
sp->wrk->acct_tmp.hdrbytes +=
http_Write(sp->wrk, sp->wrk->resp, 1);
if (sp->wrk->res_mode & RES_CHUNKED)
......
......@@ -80,7 +80,7 @@ static struct lock stat_mtx;
void
SES_Charge(struct sess *sp)
{
struct acct *a = &sp->acct_tmp;
struct acct *a = &sp->wrk->acct_tmp;
#define ACCT(foo) \
sp->wrk->stats.s_##foo += a->foo; \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment