Commit 18c88fbd authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make statistics a caller task and simply V1L_FlushRelease()

parent bc31f5c1
......@@ -953,7 +953,7 @@ void V1L_Chunked(const struct worker *w);
void V1L_EndChunk(const struct worker *w);
void V1L_Reserve(struct worker *w, int *fd, struct vsl_log *, double t0);
unsigned V1L_Flush(const struct worker *w);
unsigned V1L_FlushRelease(struct worker *w, uint64_t *pacc);
unsigned V1L_FlushRelease(struct worker *w);
unsigned V1L_Write(const struct worker *w, const void *ptr, int len);
/* cache_session.c [SES] */
......
......@@ -56,7 +56,7 @@ ved_include(struct req *preq, const char *src, const char *host)
if (preq->esi_level >= cache_param->max_esi_depth)
return;
(void)V1L_FlushRelease(preq->wrk, NULL);
(void)V1L_FlushRelease(preq->wrk);
/* Take a workspace snapshot */
wrk_ws_wm = WS_Snapshot(wrk->aws); /* XXX ? */
......
......@@ -381,7 +381,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
!(req->res_mode & RES_ESI_CHILD))
V1L_EndChunk(req->wrk);
if ((V1L_FlushRelease(req->wrk, NULL) || ois != OIS_DONE) &&
if ((V1L_FlushRelease(req->wrk) || ois != OIS_DONE) &&
req->sp->fd >= 0)
SES_Close(req->sp, SC_REM_CLOSE);
}
......@@ -50,14 +50,14 @@
static int __match_proto__(req_body_iter_f)
vbf_iter_req_body(struct req *req, void *priv, void *ptr, size_t l)
{
struct worker *wrk;
struct busyobj *bo;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CAST_OBJ_NOTNULL(wrk, priv, WORKER_MAGIC);
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
if (l > 0) {
(void)V1L_Write(wrk, ptr, l);
if (V1L_Flush(wrk))
bo->acct.bereq_bodybytes += V1L_Write(bo->wrk, ptr, l);
if (V1L_Flush(bo->wrk))
return (-1);
}
return (0);
......@@ -82,7 +82,6 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
int retry = -1;
int i, j, first;
struct http_conn *htc;
ssize_t hdrbytes;
int do_chunked = 0;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
......@@ -113,7 +112,7 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
(void)VTCP_blocking(vc->fd); /* XXX: we should timeout instead */
V1L_Reserve(wrk, &vc->fd, bo->vsl, bo->t_prev);
hdrbytes = HTTP1_Write(wrk, hp, HTTP1_Req);
bo->acct.bereq_hdrbytes = HTTP1_Write(wrk, hp, HTTP1_Req);
/* Deal with any message-body the request might (still) have */
i = 0;
......@@ -121,7 +120,7 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
if (bo->req != NULL) {
if (do_chunked)
V1L_Chunked(wrk);
i = VRB_Iterate(bo->req, vbf_iter_req_body, wrk);
i = VRB_Iterate(bo->req, vbf_iter_req_body, bo);
if (bo->req->req_body_status == REQ_BODY_TAKEN) {
retry = -1;
......@@ -136,11 +135,7 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
V1L_EndChunk(wrk);
}
j = V1L_FlushRelease(wrk, &bo->acct.bereq_hdrbytes);
if (bo->acct.bereq_hdrbytes > hdrbytes) {
bo->acct.bereq_bodybytes = bo->acct.bereq_hdrbytes - hdrbytes;
bo->acct.bereq_hdrbytes = hdrbytes;
}
j = V1L_FlushRelease(wrk);
if (j != 0 || i != 0) {
VSLb(bo->vsl, SLT_FetchError, "backend write error: %d (%s)",
errno, strerror(errno));
......
......@@ -93,19 +93,20 @@ V1L_Reserve(struct worker *wrk, int *fd, struct vsl_log *vsl, double t0)
wrk->v1l = v1l;
}
static void
v1l_release(struct worker *wrk, uint64_t *pacc)
unsigned
V1L_FlushRelease(struct worker *wrk)
{
struct v1l *v1l;
unsigned u;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
u = V1L_Flush(wrk);
v1l = wrk->v1l;
wrk->v1l = NULL;
CHECK_OBJ_NOTNULL(v1l, V1L_MAGIC);
if (pacc != NULL)
*pacc += v1l->cnt;
WS_Release(wrk->aws, 0);
WS_Reset(wrk->aws, NULL);
return (u);
}
static void
......@@ -210,18 +211,6 @@ V1L_Flush(const struct worker *wrk)
return (v1l->werr);
}
unsigned
V1L_FlushRelease(struct worker *wrk, uint64_t *pacc)
{
unsigned u;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
AN(wrk->v1l->wfd);
u = V1L_Flush(wrk);
v1l_release(wrk, pacc);
return (u);
}
unsigned
V1L_Write(const struct worker *wrk, const void *ptr, int len)
{
......
......@@ -99,7 +99,6 @@ V1P_Process(struct req *req, struct busyobj *bo)
struct pollfd fds[2];
int i, fd;
struct acct_pipe acct_pipe;
ssize_t hdrbytes;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC);
......@@ -125,17 +124,13 @@ V1P_Process(struct req *req, struct busyobj *bo)
(void)VTCP_blocking(fd);
V1L_Reserve(wrk, &fd, bo->vsl, req->t_req);
hdrbytes = HTTP1_Write(wrk, bo->bereq, HTTP1_Req);
acct_pipe.bereq += HTTP1_Write(wrk, bo->bereq, HTTP1_Req);
if (req->htc->pipeline_b != NULL)
(void)V1L_Write(wrk, req->htc->pipeline_b,
acct_pipe.in += V1L_Write(wrk, req->htc->pipeline_b,
req->htc->pipeline_e - req->htc->pipeline_b);
i = V1L_FlushRelease(wrk, &acct_pipe.bereq);
if (acct_pipe.bereq > hdrbytes) {
acct_pipe.in = acct_pipe.bereq - hdrbytes;
acct_pipe.bereq = hdrbytes;
}
i = V1L_FlushRelease(wrk);
VSLb_ts_req(req, "Pipe", W_TIM_real(wrk));
......
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