[master] f6c846c Add statistics to VFP's: number of calls and number of bytes returned.

Poul-Henning Kamp phk at FreeBSD.org
Mon Sep 15 08:37:56 CEST 2014


commit f6c846c384336d7d6555f55da342f0a08a4b7d35
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Sep 15 06:37:06 2014 +0000

    Add statistics to VFP's:  number of calls and number of bytes returned.
    
    Now I just need to figure out where to stuff them.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 7c18ae9..df8b562 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -210,6 +210,8 @@ struct vfp_entry {
 	intptr_t		priv2;
 	enum vfp_status		closed;
 	VTAILQ_ENTRY(vfp_entry)	list;
+	uint64_t		calls;
+	uint64_t		bytes_out;
 };
 
 VTAILQ_HEAD(vfp_entry_s, vfp_entry);
@@ -229,7 +231,6 @@ struct vfp_ctx {
 	struct vsl_log		*vsl;
 	struct http		*http;
 	struct http		*esi_req;
-	uint64_t		bodybytes;
 };
 
 /*--------------------------------------------------------------------
diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c
index fda8cb6..bec9225 100644
--- a/bin/varnishd/cache/cache_fetch_proc.c
+++ b/bin/varnishd/cache/cache_fetch_proc.c
@@ -165,19 +165,23 @@ VFP_Suck(struct vfp_ctx *vc, void *p, ssize_t *lp)
 	vc->vfp_nxt = VTAILQ_NEXT(vfe, list);
 
 	if (vfe->closed == VFP_NULL) {
+		/* Layer asked to be bypassed when opened */
 		vp = VFP_Suck(vc, p, lp);
 	} else if (vfe->closed == VFP_OK) {
 		vp = vfe->vfp->pull(vc, vfe, p, lp);
-		if (vp == VFP_END || vp == VFP_ERROR) {
-			vfe->closed = vp;
-		} else if (vp != VFP_OK)
+		if (vp != VFP_OK && vp != VFP_END && vp != VFP_ERROR) {
 			(void)VFP_Error(vc, "Fetch filter %s returned %d",
 			    vfe->vfp->name, vp);
+			vp = VFP_ERROR;
+		}
+		vfe->closed = vp;
 	} else {
 		/* Already closed filter */
 		*lp = 0;
 		vp = vfe->closed;
 	}
+	vfe->calls++;
+	vfe->bytes_out = *lp;
 	vc->vfp_nxt = vfe;
 	return (vp);
 }



More information about the varnish-commit mailing list