[master] 8e8a894 Give busyobj its own "t_fetch" timestamp, (== req->t_req) and only pass req to FetchHdr if we intend to send the body over.

Poul-Henning Kamp phk at varnish-cache.org
Mon May 13 12:35:16 CEST 2013


commit 8e8a8942bd154b36bf81da45cf5fdccd7bfc3562
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon May 13 10:34:40 2013 +0000

    Give busyobj its own "t_fetch" timestamp, (== req->t_req) and
    only pass req to FetchHdr if we intend to send the body over.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 0049eec..4a5cc3a 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -501,6 +501,7 @@ struct busyobj {
 	 * is recycled.
 	 */
 	unsigned		refcount;
+	double			t_fetch;
 
 	uint8_t			*vary;
 	unsigned		is_gzip;
@@ -815,7 +816,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 worker *wrk, struct busyobj *bo, struct req *req,
-    int need_host_hdr, int sendbody);
+    int need_host_hdr);
 void FetchBody(struct worker *w, void *bo);
 void Fetch_Init(void);
 
diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c
index ffe108a..5124dc4 100644
--- a/bin/varnishd/cache/cache_busyobj.c
+++ b/bin/varnishd/cache/cache_busyobj.c
@@ -145,6 +145,8 @@ VBO_GetBusyObj(struct worker *wrk, struct req *req)
 	bo->vcl = req->vcl;
 	VCL_Ref(bo->vcl);
 
+	bo->t_fetch = req->t_req;
+
 	return (bo);
 }
 
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index fd74b0f..62d0815 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -358,7 +358,7 @@ fetch_iter_req_body(struct req *req, void *priv, void *ptr, size_t l)
 
 int
 FetchHdr(struct worker *wrk, struct busyobj *bo, struct req *req,
-    int need_host_hdr, int sendbody)
+    int need_host_hdr)
 {
 	struct vbc *vc;
 	struct http *hp;
@@ -368,15 +368,11 @@ FetchHdr(struct worker *wrk, struct busyobj *bo, struct req *req,
 	struct http_conn *htc;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
-	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	CHECK_OBJ_ORNULL(req, REQ_MAGIC);
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	htc = &bo->htc;
 
-	AN(req->director);
-	AZ(req->obj);
-
-	CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
-	AN(req->objcore->flags & OC_F_BUSY);
+	AN(bo->director);
 
 	hp = bo->bereq;
 
@@ -398,18 +394,16 @@ FetchHdr(struct worker *wrk, struct busyobj *bo, struct req *req,
 		VDI_AddHostHeader(bo->bereq, vc);
 
 	(void)VTCP_blocking(vc->fd);	/* XXX: we should timeout instead */
-	WRW_Reserve(wrk, &vc->fd, bo->vsl, req->t_req);	/* XXX t_resp ? */
+	WRW_Reserve(wrk, &vc->fd, bo->vsl, bo->t_fetch);
 	(void)HTTP1_Write(wrk, hp, 0);	/* XXX: stats ? */
 
 	/* Deal with any message-body the request might (still) have */
 	i = 0;
 
-	if (sendbody) {
+	if (req != NULL) {
 		i = HTTP1_IterateReqBody(req, fetch_iter_req_body, NULL);
 		if (req->req_body_status == REQ_BODY_DONE)
 			retry = -1;
-	} else {
-		i = HTTP1_DiscardReqBody(req);
 	}
 
 	if (WRW_FlushRelease(wrk) || i != 0) {
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 24c4cf1..3c87406 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -371,8 +371,8 @@ cnt_fetch(struct worker *wrk, struct req *req)
 
 	req->acct_req.fetch++;
 
-	i = FetchHdr(wrk, bo, req, need_host_hdr,
-	    req->objcore->objhead == NULL);
+	i = FetchHdr(wrk, bo, req->objcore->objhead == NULL ? req : NULL,
+	    need_host_hdr);
 	/*
 	 * If we recycle a backend connection, there is a finite chance
 	 * that the backend closed it before we get a request to it.
@@ -380,10 +380,13 @@ cnt_fetch(struct worker *wrk, struct req *req)
 	 */
 	if (i == 1) {
 		VSC_C_main->backend_retry++;
-		i = FetchHdr(wrk, bo, req, need_host_hdr,
-		    req->objcore->objhead == NULL);
+		i = FetchHdr(wrk, bo,
+		    req->objcore->objhead == NULL ? req : NULL, need_host_hdr);
 	}
 
+	if (req->objcore->objhead != NULL)
+		(void)HTTP1_DiscardReqBody(req);	// XXX
+
 	if (i) {
 		wrk->handling = VCL_RET_ERROR;
 		req->err_code = 503;



More information about the varnish-commit mailing list