[master] e6e9569 Repatriate VFP_Fetch_Body() with cache_fetch.c, it's not really a VFP function but rather a fetch function calling VFP.
Poul-Henning Kamp
phk at FreeBSD.org
Wed Sep 3 12:57:06 CEST 2014
commit e6e956995d50a26a3d9703eecc4189ac1d70a5b1
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Sep 3 10:56:23 2014 +0000
Repatriate VFP_Fetch_Body() with cache_fetch.c, it's not really
a VFP function but rather a fetch function calling VFP.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 08e8714..4e7046f 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -910,7 +910,6 @@ void VBF_Fetch(struct worker *wrk, struct req *req,
/* cache_fetch_proc.c */
enum vfp_status VFP_GetStorage(struct vfp_ctx *, ssize_t *sz, uint8_t **ptr);
void VFP_Init(void);
-void VFP_Fetch_Body(struct busyobj *bo);
/* cache_gzip.c */
struct vgz;
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 001cd79..b4c4457 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -393,6 +393,73 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
/*--------------------------------------------------------------------
*/
+static void
+vbf_fetch_body_helper(struct busyobj *bo)
+{
+ ssize_t l;
+ uint8_t *ptr;
+ enum vfp_status vfps = VFP_ERROR;
+ ssize_t est;
+ struct vfp_ctx *vfc;
+
+ CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+ vfc = bo->vfc;
+ CHECK_OBJ_NOTNULL(vfc, VFP_CTX_MAGIC);
+
+ AN(vfc->vfp_nxt);
+
+ est = bo->content_length;
+ if (est < 0)
+ est = 0;
+
+ do {
+ if (bo->abandon) {
+ /*
+ * A pass object and delivery was terminted
+ * We don't fail the fetch, in order for hit-for-pass
+ * objects to be created.
+ */
+ AN(vfc->oc->flags & OC_F_PASS);
+ VSLb(vfc->vsl, SLT_FetchError,
+ "Pass delivery abandoned");
+ vfps = VFP_END;
+ bo->doclose = SC_RX_BODY;
+ break;
+ }
+ AZ(vfc->failed);
+ l = est;
+ assert(l >= 0);
+ if (VFP_GetStorage(vfc, &l, &ptr) != VFP_OK) {
+ bo->doclose = SC_RX_BODY;
+ break;
+ }
+
+ AZ(vfc->failed);
+ vfps = VFP_Suck(vfc, ptr, &l);
+ if (l > 0 && vfps != VFP_ERROR) {
+ VBO_extend(bo, l);
+ if (est >= l)
+ est -= l;
+ else
+ est = 0;
+ }
+ } while (vfps == VFP_OK);
+
+ if (vfps == VFP_ERROR) {
+ AN(vfc->failed);
+ (void)VFP_Error(vfc, "Fetch Pipeline failed to process");
+ bo->doclose = SC_RX_BODY;
+ }
+
+ VFP_Close(vfc);
+
+ if (!bo->do_stream)
+ ObjTrimStore(vfc->oc, bo->stats);
+}
+
+/*--------------------------------------------------------------------
+ */
+
static enum fetch_step
vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
{
@@ -512,7 +579,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
if (bo->htc.body_status != BS_NONE) {
assert(bo->htc.body_status != BS_ERROR);
- VFP_Fetch_Body(bo);
+ vbf_fetch_body_helper(bo);
bo->acct.beresp_bodybytes = bo->vfc->bodybytes;
}
diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c
index b44abd4..b8ee0b9 100644
--- a/bin/varnishd/cache/cache_fetch_proc.c
+++ b/bin/varnishd/cache/cache_fetch_proc.c
@@ -113,8 +113,8 @@ VFP_Setup(struct vfp_ctx *vc)
/**********************************************************************
*/
-static void
-vfp_suck_fini(struct vfp_ctx *vc)
+void
+VFP_Close(struct vfp_ctx *vc)
{
struct vfp_entry *vfe;
@@ -136,7 +136,7 @@ VFP_Open(struct vfp_ctx *vc)
if (vfe->closed != VFP_OK && vfe->closed != VFP_NULL) {
(void)VFP_Error(vc, "Fetch filter %s failed to open",
vfe->vfp->name);
- vfp_suck_fini(vc);
+ VFP_Close(vc);
return (-1);
}
}
@@ -182,71 +182,6 @@ VFP_Suck(struct vfp_ctx *vc, void *p, ssize_t *lp)
/*--------------------------------------------------------------------
*/
-
-void
-VFP_Fetch_Body(struct busyobj *bo)
-{
- ssize_t l;
- uint8_t *ptr;
- enum vfp_status vfps = VFP_ERROR;
- ssize_t est;
- struct vfp_ctx *vfc;
-
- CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
- vfc = bo->vfc;
- CHECK_OBJ_NOTNULL(vfc, VFP_CTX_MAGIC);
-
- AN(vfc->vfp_nxt);
-
- est = bo->content_length;
- if (est < 0)
- est = 0;
-
- do {
- if (bo->abandon) {
- /*
- * A pass object and delivery was terminted
- * We don't fail the fetch, in order for hit-for-pass
- * objects to be created.
- */
- AN(vfc->oc->flags & OC_F_PASS);
- VSLb(vfc->vsl, SLT_FetchError,
- "Pass delivery abandoned");
- vfps = VFP_END;
- bo->doclose = SC_RX_BODY;
- break;
- }
- AZ(vfc->failed);
- l = est;
- assert(l >= 0);
- if (VFP_GetStorage(vfc, &l, &ptr) != VFP_OK) {
- bo->doclose = SC_RX_BODY;
- break;
- }
-
- AZ(vfc->failed);
- vfps = VFP_Suck(vfc, ptr, &l);
- if (l > 0 && vfps != VFP_ERROR) {
- VBO_extend(bo, l);
- if (est >= l)
- est -= l;
- else
- est = 0;
- }
- } while (vfps == VFP_OK);
-
- if (vfps == VFP_ERROR) {
- AN(vfc->failed);
- (void)VFP_Error(vfc, "Fetch Pipeline failed to process");
- bo->doclose = SC_RX_BODY;
- }
-
- vfp_suck_fini(vfc);
-
- if (!bo->do_stream)
- ObjTrimStore(vfc->oc, bo->stats);
-}
-
struct vfp_entry *
VFP_Push(struct vfp_ctx *vc, const struct vfp *vfp, int top)
{
diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h
index 584bf77..a5a705a 100644
--- a/bin/varnishd/cache/cache_filter.h
+++ b/bin/varnishd/cache/cache_filter.h
@@ -64,6 +64,7 @@ extern const struct vfp vfp_esi_gzip;
struct vfp_entry *VFP_Push(struct vfp_ctx *, const struct vfp *, int top);
void VFP_Setup(struct vfp_ctx *vc);
int VFP_Open(struct vfp_ctx *bo);
+void VFP_Close(struct vfp_ctx *bo);
enum vfp_status VFP_Suck(struct vfp_ctx *, void *p, ssize_t *lp);
enum vfp_status VFP_Error(struct vfp_ctx *, const char *fmt, ...)
__printflike(2, 3);
More information about the varnish-commit
mailing list