[master] dfc78bf Centralize counting of beresp.bodybytes
Poul-Henning Kamp
phk at FreeBSD.org
Mon Sep 15 08:45:41 CEST 2014
commit dfc78bfab0e481816dfa30a8035c9bf0d606cc73
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Sep 15 06:45:24 2014 +0000
Centralize counting of beresp.bodybytes
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 79db1dd..c4b4332 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -479,6 +479,7 @@ vbf_fetch_body_helper(struct busyobj *bo)
AZ(vfc->failed);
vfps = VFP_Suck(vfc, ptr, &l);
if (l > 0 && vfps != VFP_ERROR) {
+ bo->acct.beresp_bodybytes += l;
VBO_extend(bo, l);
if (est >= l)
est -= l;
@@ -622,7 +623,6 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
if (bo->htc->body_status != BS_NONE) {
assert(bo->htc->body_status != BS_ERROR);
vbf_fetch_body_helper(bo);
- bo->acct.beresp_bodybytes = bo->vfc->bodybytes;
}
if (bo->vfc->failed && !bo->do_stream) {
diff --git a/bin/varnishd/cache/cache_http1_vfp.c b/bin/varnishd/cache/cache_http1_vfp.c
index 4e2fa29..33a48c5 100644
--- a/bin/varnishd/cache/cache_http1_vfp.c
+++ b/bin/varnishd/cache/cache_http1_vfp.c
@@ -75,7 +75,6 @@ v1f_pull_chunked(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr,
lr = HTTP1_Read(htc, buf, 1);
if (lr <= 0)
return (VFP_Error(vc, "chunked read err"));
- vc->bodybytes += lr;
} while (vct_islws(buf[0]));
if (!vct_ishex(buf[0]))
@@ -88,7 +87,6 @@ v1f_pull_chunked(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr,
if (lr <= 0)
return (VFP_Error(vc,
"chunked read err"));
- vc->bodybytes += lr;
} while (u == 1 && buf[0] == '0' && buf[u] == '0');
if (!vct_ishex(buf[u]))
break;
@@ -102,7 +100,6 @@ v1f_pull_chunked(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr,
lr = HTTP1_Read(htc, buf + u, 1);
if (lr <= 0)
return (VFP_Error(vc, "chunked read err"));
- vc->bodybytes += lr;
}
if (buf[u] != '\n')
@@ -125,7 +122,6 @@ v1f_pull_chunked(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr,
lr = HTTP1_Read(htc, ptr, l);
if (lr <= 0)
return (VFP_Error(vc, "straight insufficient bytes"));
- vc->bodybytes += lr;
*lp = lr;
vfe->priv2 -= lr;
if (vfe->priv2 == 0)
@@ -136,7 +132,6 @@ v1f_pull_chunked(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr,
i = HTTP1_Read(htc, buf, 1);
if (i <= 0)
return (VFP_Error(vc, "chunked read err"));
- vc->bodybytes += i;
if (buf[0] == '\r' && HTTP1_Read(htc, buf, 1) <= 0)
return (VFP_Error(vc, "chunked read err"));
if (buf[0] != '\n')
@@ -173,7 +168,6 @@ v1f_pull_straight(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p,
if (vfe->priv2 < l)
l = vfe->priv2;
lr = HTTP1_Read(htc, p, l);
- vc->bodybytes += lr;
if (lr <= 0)
return (VFP_Error(vc, "straight insufficient bytes"));
*lp = lr;
@@ -212,7 +206,6 @@ v1f_pull_eof(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p,
if (lr == 0)
return (VFP_END);
*lp = lr;
- vc->bodybytes += lr;
return (VFP_OK);
}
More information about the varnish-commit
mailing list