[experimental-ims] 5cd69e0 Eliminate obj arg to FetchBody()

Poul-Henning Kamp phk at FreeBSD.org
Thu Dec 18 10:27:40 CET 2014


commit 5cd69e085bf15d84ad30233a72c52817def66ca2
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Mar 5 10:36:52 2012 +0000

    Eliminate obj arg to FetchBody()
    
    Mostly by:	martin

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index bdc3659..dceac39 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -748,7 +748,7 @@ struct storage *FetchStorage(struct busyobj *, ssize_t sz);
 int FetchError(struct busyobj *, const char *error);
 int FetchError2(struct busyobj *, const char *error, const char *more);
 int FetchHdr(struct sess *sp, int need_host_hdr, int sendbody);
-int FetchBody(struct worker *w, struct busyobj *bo, struct object *obj);
+int FetchBody(struct worker *w, struct busyobj *bo);
 int FetchReqBody(const struct sess *sp, int sendbody);
 void Fetch_Init(void);
 
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 6e6d54f..9cbc905 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -830,8 +830,10 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req)
 
 	req->storage_hint = NULL;
 
-	if (bo->do_gzip ||
-	    (bo->is_gzip && !bo->do_gunzip))
+	AZ(bo->fetch_obj);
+	bo->fetch_obj = req->obj;
+
+	if (bo->do_gzip || (bo->is_gzip && !bo->do_gunzip))
 		req->obj->gziped = 1;
 
 	if (vary != NULL) {
@@ -903,7 +905,8 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req)
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 
 	/* Use unmodified headers*/
-	i = FetchBody(wrk, bo, req->obj);
+	i = FetchBody(wrk, bo);
+	bo->fetch_obj = NULL;
 
 	http_Teardown(bo->bereq);
 	http_Teardown(bo->beresp);
@@ -1115,6 +1118,8 @@ cnt_lookup(struct sess *sp, struct worker *wrk, struct req *req)
 
 	/* If we inserted a new object it's a miss */
 	if (oc->flags & OC_F_BUSY) {
+		CHECK_OBJ_NOTNULL(oc->busyobj, BUSYOBJ_MAGIC);
+		assert(oc->busyobj == req->busyobj);
 		wrk->stats.cache_miss++;
 
 		if (req->vary_l != NULL) {
@@ -1130,7 +1135,6 @@ cnt_lookup(struct sess *sp, struct worker *wrk, struct req *req)
 		req->vary_e = NULL;
 
 		req->objcore = oc;
-		CHECK_OBJ_NOTNULL(req->busyobj, BUSYOBJ_MAGIC);
 		sp->step = STP_MISS;
 		return (0);
 	}
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index bb725a2..1dae8b9 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -493,18 +493,19 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
 /*--------------------------------------------------------------------*/
 
 int
-FetchBody(struct worker *wrk, struct busyobj *bo, struct object *obj)
+FetchBody(struct worker *wrk, struct busyobj *bo)
 {
 	int cls;
 	struct storage *st;
 	int mklen;
 	ssize_t cl;
 	struct http_conn *htc;
+	struct object *obj;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
-	AZ(bo->fetch_obj);
 	CHECK_OBJ_NOTNULL(bo->vbc, VBC_MAGIC);
+	obj = bo->fetch_obj;
 	CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC);
 	CHECK_OBJ_NOTNULL(obj->http, HTTP_MAGIC);
 
@@ -525,7 +526,6 @@ FetchBody(struct worker *wrk, struct busyobj *bo, struct object *obj)
 	AZ(bo->vgz_rx);
 	AZ(VTAILQ_FIRST(&obj->store));
 
-	bo->fetch_obj = obj;
 	bo->fetch_failed = 0;
 
 	/* XXX: pick up estimate from objdr ? */
@@ -578,8 +578,6 @@ FetchBody(struct worker *wrk, struct busyobj *bo, struct object *obj)
 	 */
 	AZ(vfp_nop_end(bo));
 
-	bo->fetch_obj = NULL;
-
 	VSLb(bo->vsl, SLT_Fetch_Body, "%u(%s) cls %d mklen %d",
 	    bo->body_status, body_status(bo->body_status),
 	    cls, mklen);



More information about the varnish-commit mailing list