[master] 3a4edf1 Centralize the updating of the fetch_obj->len field.
Poul-Henning Kamp
phk at varnish-cache.org
Tue Mar 27 13:32:13 CEST 2012
commit 3a4edf1da8924e3bbfe3d9a1f87e34b5e57ea506
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Mar 27 08:30:51 2012 +0000
Centralize the updating of the fetch_obj->len field.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 8f9b6d9..073eb75 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -216,6 +216,8 @@ struct dstat {
/* Fetch processors --------------------------------------------------*/
+void VFP_update_length(const struct busyobj *, ssize_t);
+
typedef void vfp_begin_f(struct busyobj *, size_t );
typedef int vfp_bytes_f(struct busyobj *, struct http_conn *, ssize_t);
typedef int vfp_end_f(struct busyobj *);
diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c
index 6699117..c9cc689 100644
--- a/bin/varnishd/cache/cache_esi_fetch.c
+++ b/bin/varnishd/cache/cache_esi_fetch.c
@@ -103,7 +103,7 @@ vfp_esi_bytes_uu(struct busyobj *bo, const struct vef_priv *vef,
return (wl);
VEP_Parse(bo, (const char *)st->ptr + st->len, wl);
st->len += wl;
- bo->fetch_obj->len += wl;
+ VFP_update_length(bo, wl);
bytes -= wl;
}
return (1);
@@ -140,7 +140,7 @@ vfp_esi_bytes_gu(struct busyobj *bo, const struct vef_priv *vef,
i = VGZ_Gunzip(vg, &dp, &dl);
xxxassert(i == VGZ_OK || i == VGZ_END);
VEP_Parse(bo, dp, dl);
- bo->fetch_obj->len += dl;
+ VFP_update_length(bo, dl);
}
return (1);
}
@@ -217,7 +217,7 @@ vfp_vep_callback(struct busyobj *bo, ssize_t l, enum vgz_flag flg)
}
i = VGZ_Gzip(vef->vgz, &dp, &dl, flg);
vef->tot += dl;
- bo->fetch_obj->len += dl;
+ VFP_update_length(bo, dl);
} while (!VGZ_IbufEmpty(vef->vgz) ||
(flg != VGZ_NORMAL && VGZ_ObufFull(vef->vgz)));
assert(VGZ_IbufEmpty(vef->vgz));
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 0246f1b..e019702 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -113,6 +113,17 @@ VFP_End(struct busyobj *bo)
assert(bo->state == BOS_FAILED);
}
+void
+VFP_update_length(const struct busyobj *bo, ssize_t l)
+{
+
+ CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+ CHECK_OBJ_NOTNULL(bo->fetch_obj, OBJECT_MAGIC);
+ if (l == 0)
+ return;
+ assert(l > 0);
+ bo->fetch_obj->len += l;
+}
/*--------------------------------------------------------------------
* VFP_NOP
@@ -165,7 +176,7 @@ vfp_nop_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
if (wl <= 0)
return (wl);
st->len += wl;
- bo->fetch_obj->len += wl;
+ VFP_update_length(bo, wl);
bytes -= wl;
}
return (1);
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index 343bd35..ca40903 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -468,7 +468,7 @@ vfp_gunzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
i = VGZ_Gunzip(vg, &dp, &dl);
if (i != VGZ_OK && i != VGZ_END)
return(FetchError(bo, "Gunzip data error"));
- bo->fetch_obj->len += dl;
+ VFP_update_length(bo, dl);
}
assert(i == Z_OK || i == Z_STREAM_END);
return (1);
@@ -543,7 +543,7 @@ vfp_gzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
return(-1);
i = VGZ_Gzip(vg, &dp, &dl, VGZ_NORMAL);
assert(i == Z_OK);
- bo->fetch_obj->len += dl;
+ VFP_update_length(bo, dl);
}
return (1);
}
@@ -569,7 +569,7 @@ vfp_gzip_end(struct busyobj *bo)
if (VGZ_ObufStorage(bo, vg))
return(-1);
i = VGZ_Gzip(vg, &dp, &dl, VGZ_FINISH);
- bo->fetch_obj->len += dl;
+ VFP_update_length(bo, dl);
} while (i != Z_STREAM_END);
VGZ_UpdateObj(vg, bo->fetch_obj);
if (VGZ_Destroy(&vg) != VGZ_END)
@@ -627,7 +627,7 @@ vfp_testgzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
bytes -= wl;
VGZ_Ibuf(vg, st->ptr + st->len, wl);
st->len += wl;
- bo->fetch_obj->len += wl;
+ VFP_update_length(bo, wl);
while (!VGZ_IbufEmpty(vg)) {
VGZ_Obuf(vg, vg->m_buf, vg->m_sz);
More information about the varnish-commit
mailing list