Commit 3a4edf1d authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Centralize the updating of the fetch_obj->len field.

parent c5a1c750
......@@ -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 *);
......
......@@ -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));
......
......@@ -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);
......
......@@ -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);
......
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