Commit 10e4f972 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Tollef Fog Heen

Add a set of VFP method functions which can do various sanity asserts for us in a single place.

Conflicts:

	bin/varnishd/cache/cache_esi_fetch.c
	bin/varnishd/cache_fetch.c
	bin/varnishd/cache_gzip.c
parent 0f72c5ae
...@@ -335,7 +335,6 @@ vfp_esi_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes) ...@@ -335,7 +335,6 @@ vfp_esi_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
int i; int i;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
AZ(sp->wrk->fetch_failed);
AN(sp->wrk->vep); AN(sp->wrk->vep);
assert(sp->wrk->htc == htc); assert(sp->wrk->htc == htc);
if (sp->wrk->is_gzip && sp->wrk->do_gunzip) if (sp->wrk->is_gzip && sp->wrk->do_gunzip)
......
...@@ -76,6 +76,40 @@ FetchError(const struct sess *sp, const char *error) ...@@ -76,6 +76,40 @@ FetchError(const struct sess *sp, const char *error)
return(FetchError2(sp, error, NULL)); return(FetchError2(sp, error, NULL));
} }
/*--------------------------------------------------------------------
* VFP method functions
*/
static void
VFP_Begin(struct sess *sp, size_t estimate)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
AN(sp->wrk->vfp);
sp->wrk->vfp->begin(sp, estimate);
}
static int
VFP_Bytes(struct sess *sp, struct http_conn *htc, ssize_t sz)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
AN(sp->wrk->vfp);
CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
AZ(sp->wrk->fetch_failed);
return (sp->wrk->vfp->bytes(sp, htc, sz));
}
static int
VFP_End(struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
AN(sp->wrk->vfp);
return (sp->wrk->vfp->end(sp));
}
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
* VFP_NOP * VFP_NOP
* *
...@@ -237,7 +271,7 @@ fetch_straight(struct sess *sp, struct http_conn *htc, ssize_t cl) ...@@ -237,7 +271,7 @@ fetch_straight(struct sess *sp, struct http_conn *htc, ssize_t cl)
} else if (cl == 0) } else if (cl == 0)
return (0); return (0);
i = sp->wrk->vfp->bytes(sp, htc, cl); i = VFP_Bytes(sp, htc, cl);
if (i <= 0) { if (i <= 0) {
return (FetchError(sp, "straight insufficient bytes")); return (FetchError(sp, "straight insufficient bytes"));
} }
...@@ -296,7 +330,7 @@ fetch_chunked(struct sess *sp, struct http_conn *htc) ...@@ -296,7 +330,7 @@ fetch_chunked(struct sess *sp, struct http_conn *htc)
if (cl < 0) if (cl < 0)
return (FetchError(sp,"chunked header number syntax")); return (FetchError(sp,"chunked header number syntax"));
if (cl > 0 && sp->wrk->vfp->bytes(sp, htc, cl) <= 0) if (cl > 0 && VFP_Bytes(sp, htc, cl) <= 0)
return (-1); return (-1);
i = HTC_Read(sp->wrk, htc, buf, 1); i = HTC_Read(sp->wrk, htc, buf, 1);
...@@ -318,7 +352,7 @@ fetch_eof(struct sess *sp, struct http_conn *htc) ...@@ -318,7 +352,7 @@ fetch_eof(struct sess *sp, struct http_conn *htc)
int i; int i;
assert(sp->wrk->body_status == BS_EOF); assert(sp->wrk->body_status == BS_EOF);
i = sp->wrk->vfp->bytes(sp, htc, SSIZE_MAX); i = VFP_Bytes(sp, htc, SSIZE_MAX);
if (i < 0) if (i < 0)
return (-1); return (-1);
return (0); return (0);
...@@ -521,24 +555,24 @@ FetchBody(struct sess *sp) ...@@ -521,24 +555,24 @@ FetchBody(struct sess *sp)
break; break;
case BS_LENGTH: case BS_LENGTH:
cl = fetch_number(sp->wrk->h_content_length, 10); cl = fetch_number(sp->wrk->h_content_length, 10);
w->vfp->begin(sp, cl > 0 ? cl : 0); VFP_Begin(sp, cl > 0 ? cl : 0);
cls = fetch_straight(sp, w->htc, cl); cls = fetch_straight(sp, w->htc, cl);
mklen = 1; mklen = 1;
if (w->vfp->end(sp)) if (VFP_End(sp))
cls = -1; cls = -1;
break; break;
case BS_CHUNKED: case BS_CHUNKED:
w->vfp->begin(sp, cl); VFP_Begin(sp, cl);
cls = fetch_chunked(sp, w->htc); cls = fetch_chunked(sp, w->htc);
mklen = 1; mklen = 1;
if (w->vfp->end(sp)) if (VFP_End(sp))
cls = -1; cls = -1;
break; break;
case BS_EOF: case BS_EOF:
w->vfp->begin(sp, cl); VFP_Begin(sp, cl);
cls = fetch_eof(sp, w->htc); cls = fetch_eof(sp, w->htc);
mklen = 1; mklen = 1;
if (w->vfp->end(sp)) if (VFP_End(sp))
cls = -1; cls = -1;
break; break;
case BS_ERROR: case BS_ERROR:
......
...@@ -465,7 +465,6 @@ vfp_gunzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes) ...@@ -465,7 +465,6 @@ vfp_gunzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
size_t dl; size_t dl;
const void *dp; const void *dp;
AZ(sp->wrk->fetch_failed);
vg = sp->wrk->vgz_rx; vg = sp->wrk->vgz_rx;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
AZ(vg->vz.avail_in); AZ(vg->vz.avail_in);
...@@ -543,7 +542,6 @@ vfp_gzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes) ...@@ -543,7 +542,6 @@ vfp_gzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
size_t dl; size_t dl;
const void *dp; const void *dp;
AZ(sp->wrk->fetch_failed);
vg = sp->wrk->vgz_rx; vg = sp->wrk->vgz_rx;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
AZ(vg->vz.avail_in); AZ(vg->vz.avail_in);
...@@ -632,7 +630,6 @@ vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes) ...@@ -632,7 +630,6 @@ vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
const void *dp; const void *dp;
struct storage *st; struct storage *st;
AZ(sp->wrk->fetch_failed);
vg = sp->wrk->vgz_rx; vg = sp->wrk->vgz_rx;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
AZ(vg->vz.avail_in); 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