[master] 18c88fb Make statistics a caller task and simply V1L_FlushRelease()
Poul-Henning Kamp
phk at FreeBSD.org
Wed Oct 22 23:19:40 CEST 2014
commit 18c88fbd6eae4429966aa6f217d4c96f01dfa527
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Oct 22 21:18:57 2014 +0000
Make statistics a caller task and simply V1L_FlushRelease()
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 6b63de3..e058fed 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -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] */
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index 886bec2..5f13e9b 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -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 ? */
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index 29c8171..2198085 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -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);
}
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index 77b3675..3124812 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -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));
diff --git a/bin/varnishd/http1/cache_http1_line.c b/bin/varnishd/http1/cache_http1_line.c
index 95c668f..4e2f027 100644
--- a/bin/varnishd/http1/cache_http1_line.c
+++ b/bin/varnishd/http1/cache_http1_line.c
@@ -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
@@ -211,18 +212,6 @@ V1L_Flush(const struct worker *wrk)
}
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)
{
struct v1l *v1l;
diff --git a/bin/varnishd/http1/cache_http1_pipe.c b/bin/varnishd/http1/cache_http1_pipe.c
index c83b6c8..87b7256 100644
--- a/bin/varnishd/http1/cache_http1_pipe.c
+++ b/bin/varnishd/http1/cache_http1_pipe.c
@@ -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));
More information about the varnish-commit
mailing list