Commit b399a62f authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add a set of VFP method functions which can do various sanity asserts

for us in a single place.
parent 5cd69e08
......@@ -346,7 +346,6 @@ vfp_esi_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
vef = bo->vef_priv;
CHECK_OBJ_NOTNULL(vef, VEF_MAGIC);
AZ(bo->fetch_failed);
AN(bo->vep);
assert(&bo->htc == htc);
if (bo->is_gzip && bo->do_gunzip)
......
......@@ -72,6 +72,40 @@ FetchError(struct busyobj *bo, const char *error)
return(FetchError2(bo, error, NULL));
}
/*--------------------------------------------------------------------
* VFP method functions
*/
static void
VFP_Begin(struct busyobj *bo, size_t estimate)
{
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
AN(bo->vfp);
bo->vfp->begin(bo, estimate);
}
static int
VFP_Bytes(struct busyobj *bo, struct http_conn *htc, ssize_t sz)
{
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
AN(bo->vfp);
CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
AZ(bo->fetch_failed);
return (bo->vfp->bytes(bo, htc, sz));
}
static int
VFP_End(struct busyobj *bo)
{
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
AN(bo->vfp);
return (bo->vfp->end(bo));
}
/*--------------------------------------------------------------------
* VFP_NOP
*
......@@ -235,7 +269,7 @@ fetch_straight(struct busyobj *bo, struct http_conn *htc, ssize_t cl)
} else if (cl == 0)
return (0);
i = bo->vfp->bytes(bo, htc, cl);
i = VFP_Bytes(bo, htc, cl);
if (i <= 0)
return (FetchError(bo, "straight insufficient bytes"));
return (0);
......@@ -292,7 +326,7 @@ fetch_chunked(struct busyobj *bo, struct http_conn *htc)
if (cl < 0)
return (FetchError(bo,"chunked header number syntax"));
if (cl > 0 && bo->vfp->bytes(bo, htc, cl) <= 0)
if (cl > 0 && VFP_Bytes(bo, htc, cl) <= 0)
return (-1);
i = HTC_Read(htc, buf, 1);
......@@ -314,7 +348,7 @@ fetch_eof(struct busyobj *bo, struct http_conn *htc)
int i;
assert(bo->body_status == BS_EOF);
i = bo->vfp->bytes(bo, htc, SSIZE_MAX);
i = VFP_Bytes(bo, htc, SSIZE_MAX);
if (i < 0)
return (-1);
return (0);
......@@ -541,24 +575,24 @@ FetchBody(struct worker *wrk, struct busyobj *bo)
break;
case BS_LENGTH:
cl = fetch_number(bo->h_content_length, 10);
bo->vfp->begin(bo, cl > 0 ? cl : 0);
VFP_Begin(bo, cl > 0 ? cl : 0);
cls = fetch_straight(bo, htc, cl);
mklen = 1;
if (bo->vfp->end(bo))
if (VFP_End(bo))
cls = -1;
break;
case BS_CHUNKED:
bo->vfp->begin(bo, cl);
VFP_Begin(bo, cl);
cls = fetch_chunked(bo, htc);
mklen = 1;
if (bo->vfp->end(bo))
if (VFP_End(bo))
cls = -1;
break;
case BS_EOF:
bo->vfp->begin(bo, cl);
VFP_Begin(bo, cl);
cls = fetch_eof(bo, htc);
mklen = 1;
if (bo->vfp->end(bo))
if (VFP_End(bo))
cls = -1;
break;
case BS_ERROR:
......
......@@ -448,7 +448,6 @@ vfp_gunzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
const void *dp;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
AZ(bo->fetch_failed);
vg = bo->vgz_rx;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
AZ(vg->vz.avail_in);
......@@ -526,7 +525,6 @@ vfp_gzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
const void *dp;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
AZ(bo->fetch_failed);
vg = bo->vgz_rx;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
AZ(vg->vz.avail_in);
......@@ -613,7 +611,6 @@ vfp_testgzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
struct storage *st;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
AZ(bo->fetch_failed);
vg = bo->vgz_rx;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
AZ(vg->vz.avail_in);
......
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