[3.0] 10e4f97 Add a set of VFP method functions which can do various sanity asserts for us in a single place.
Tollef Fog Heen
tfheen at varnish-cache.org
Wed Jun 6 13:09:19 CEST 2012
commit 10e4f9727fe0c04a895d3e1dc6c8b56605d53ac2
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Jun 6 10:49:38 2012 +0200
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
diff --git a/bin/varnishd/cache_esi_fetch.c b/bin/varnishd/cache_esi_fetch.c
index 7e636c8..ab86ac8 100644
--- a/bin/varnishd/cache_esi_fetch.c
+++ b/bin/varnishd/cache_esi_fetch.c
@@ -335,7 +335,6 @@ vfp_esi_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
int i;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- AZ(sp->wrk->fetch_failed);
AN(sp->wrk->vep);
assert(sp->wrk->htc == htc);
if (sp->wrk->is_gzip && sp->wrk->do_gunzip)
diff --git a/bin/varnishd/cache_fetch.c b/bin/varnishd/cache_fetch.c
index cdc2fd8..460cce9 100644
--- a/bin/varnishd/cache_fetch.c
+++ b/bin/varnishd/cache_fetch.c
@@ -77,6 +77,40 @@ FetchError(const struct sess *sp, const char *error)
}
/*--------------------------------------------------------------------
+ * 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
*
* This fetch-processor does nothing but store the object.
@@ -237,7 +271,7 @@ fetch_straight(struct sess *sp, struct http_conn *htc, ssize_t cl)
} else if (cl == 0)
return (0);
- i = sp->wrk->vfp->bytes(sp, htc, cl);
+ i = VFP_Bytes(sp, htc, cl);
if (i <= 0) {
return (FetchError(sp, "straight insufficient bytes"));
}
@@ -296,7 +330,7 @@ fetch_chunked(struct sess *sp, struct http_conn *htc)
if (cl < 0)
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);
i = HTC_Read(sp->wrk, htc, buf, 1);
@@ -318,7 +352,7 @@ fetch_eof(struct sess *sp, struct http_conn *htc)
int i;
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)
return (-1);
return (0);
@@ -521,24 +555,24 @@ FetchBody(struct sess *sp)
break;
case BS_LENGTH:
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);
mklen = 1;
- if (w->vfp->end(sp))
+ if (VFP_End(sp))
cls = -1;
break;
case BS_CHUNKED:
- w->vfp->begin(sp, cl);
+ VFP_Begin(sp, cl);
cls = fetch_chunked(sp, w->htc);
mklen = 1;
- if (w->vfp->end(sp))
+ if (VFP_End(sp))
cls = -1;
break;
case BS_EOF:
- w->vfp->begin(sp, cl);
+ VFP_Begin(sp, cl);
cls = fetch_eof(sp, w->htc);
mklen = 1;
- if (w->vfp->end(sp))
+ if (VFP_End(sp))
cls = -1;
break;
case BS_ERROR:
diff --git a/bin/varnishd/cache_gzip.c b/bin/varnishd/cache_gzip.c
index 3087a6b..07bdcac 100644
--- a/bin/varnishd/cache_gzip.c
+++ b/bin/varnishd/cache_gzip.c
@@ -465,7 +465,6 @@ vfp_gunzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
size_t dl;
const void *dp;
- AZ(sp->wrk->fetch_failed);
vg = sp->wrk->vgz_rx;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
AZ(vg->vz.avail_in);
@@ -543,7 +542,6 @@ vfp_gzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
size_t dl;
const void *dp;
- AZ(sp->wrk->fetch_failed);
vg = sp->wrk->vgz_rx;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
AZ(vg->vz.avail_in);
@@ -632,7 +630,6 @@ vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
const void *dp;
struct storage *st;
- AZ(sp->wrk->fetch_failed);
vg = sp->wrk->vgz_rx;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
AZ(vg->vz.avail_in);
More information about the varnish-commit
mailing list