[master] c8c3d31 Change args to FetchHdr() to lower levels.

Poul-Henning Kamp phk at varnish-cache.org
Mon May 13 11:29:02 CEST 2013


commit c8c3d314ce532ff2a93cef20fa9ecfef966cea24
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon May 13 09:28:47 2013 +0000

    Change args to FetchHdr() to lower levels.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index a28bf98..0049eec 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -814,7 +814,8 @@ void EXP_NukeLRU(struct worker *wrk, struct vsl_log *vsl, struct lru *lru);
 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 req *req, int need_host_hdr, int sendbody);
+int FetchHdr(struct worker *wrk, struct busyobj *bo, struct req *req,
+    int need_host_hdr, int sendbody);
 void FetchBody(struct worker *w, void *bo);
 void Fetch_Init(void);
 
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 951e367..fd74b0f 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -357,21 +357,18 @@ fetch_iter_req_body(struct req *req, void *priv, void *ptr, size_t l)
  */
 
 int
-FetchHdr(struct req *req, int need_host_hdr, int sendbody)
+FetchHdr(struct worker *wrk, struct busyobj *bo, struct req *req,
+    int need_host_hdr, int sendbody)
 {
 	struct vbc *vc;
-	struct worker *wrk;
-	struct busyobj *bo;
 	struct http *hp;
 	enum htc_status_e hs;
 	int retry = -1;
 	int i, first;
 	struct http_conn *htc;
 
-	wrk = req->wrk;
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
-	bo = req->busyobj;
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	htc = &bo->htc;
 
@@ -385,7 +382,7 @@ FetchHdr(struct req *req, int need_host_hdr, int sendbody)
 
 	bo->vbc = VDI_GetFd(NULL, bo);
 	if (bo->vbc == NULL) {
-		VSLb(req->vsl, SLT_FetchError, "no backend connection");
+		VSLb(bo->vsl, SLT_FetchError, "no backend connection");
 		return (-1);
 	}
 	vc = bo->vbc;
@@ -408,8 +405,7 @@ FetchHdr(struct req *req, int need_host_hdr, int sendbody)
 	i = 0;
 
 	if (sendbody) {
-		i = HTTP1_IterateReqBody(req,
-		    fetch_iter_req_body, NULL);
+		i = HTTP1_IterateReqBody(req, fetch_iter_req_body, NULL);
 		if (req->req_body_status == REQ_BODY_DONE)
 			retry = -1;
 	} else {
@@ -417,8 +413,7 @@ FetchHdr(struct req *req, int need_host_hdr, int sendbody)
 	}
 
 	if (WRW_FlushRelease(wrk) || i != 0) {
-		VSLb(req->vsl, SLT_FetchError,
-		    "backend write error: %d (%s)",
+		VSLb(bo->vsl, SLT_FetchError, "backend write error: %d (%s)",
 		    errno, strerror(errno));
 		VDI_CloseFd(&bo->vbc);
 		/* XXX: other cleanup ? */
@@ -440,7 +435,7 @@ FetchHdr(struct req *req, int need_host_hdr, int sendbody)
 	do {
 		hs = HTTP1_Rx(htc);
 		if (hs == HTTP1_OVERFLOW) {
-			VSLb(req->vsl, SLT_FetchError,
+			VSLb(bo->vsl, SLT_FetchError,
 			    "http %sread error: overflow",
 			    first ? "first " : "");
 			VDI_CloseFd(&bo->vbc);
@@ -448,8 +443,7 @@ FetchHdr(struct req *req, int need_host_hdr, int sendbody)
 			return (-1);
 		}
 		if (hs == HTTP1_ERROR_EOF) {
-			VSLb(req->vsl, SLT_FetchError,
-			    "http %sread error: EOF",
+			VSLb(bo->vsl, SLT_FetchError, "http %sread error: EOF",
 			    first ? "first " : "");
 			VDI_CloseFd(&bo->vbc);
 			/* XXX: other cleanup ? */
@@ -466,7 +460,7 @@ FetchHdr(struct req *req, int need_host_hdr, int sendbody)
 	hp = bo->beresp;
 
 	if (HTTP1_DissectResponse(hp, htc)) {
-		VSLb(req->vsl, SLT_FetchError, "http format error");
+		VSLb(bo->vsl, SLT_FetchError, "http format error");
 		VDI_CloseFd(&bo->vbc);
 		/* XXX: other cleanup ? */
 		return (-1);
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 0066c5c..24c4cf1 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -371,7 +371,8 @@ cnt_fetch(struct worker *wrk, struct req *req)
 
 	req->acct_req.fetch++;
 
-	i = FetchHdr(req, need_host_hdr, req->objcore->objhead == NULL);
+	i = FetchHdr(wrk, bo, req, need_host_hdr,
+	    req->objcore->objhead == NULL);
 	/*
 	 * If we recycle a backend connection, there is a finite chance
 	 * that the backend closed it before we get a request to it.
@@ -379,7 +380,8 @@ cnt_fetch(struct worker *wrk, struct req *req)
 	 */
 	if (i == 1) {
 		VSC_C_main->backend_retry++;
-		i = FetchHdr(req, need_host_hdr, req->objcore->objhead == NULL);
+		i = FetchHdr(wrk, bo, req, need_host_hdr,
+		    req->objcore->objhead == NULL);
 	}
 
 	if (i) {



More information about the varnish-commit mailing list