[master] 5647c26 Move the "need_host_hdr" test to cache_fetch.c

Poul-Henning Kamp phk at varnish-cache.org
Mon May 13 13:44:00 CEST 2013


commit 5647c265ad01b23cf408089a9f9b94cb2bc47af1
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon May 13 11:43:44 2013 +0000

    Move the "need_host_hdr" test to cache_fetch.c

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 4a5cc3a..9b96e4e 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -815,8 +815,7 @@ 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 worker *wrk, struct busyobj *bo, struct req *req,
-    int need_host_hdr);
+int FetchHdr(struct worker *wrk, struct busyobj *bo, struct req *req);
 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 62d0815..4bacbf1 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -357,8 +357,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)
+FetchHdr(struct worker *wrk, struct busyobj *bo, struct req *req)
 {
 	struct vbc *vc;
 	struct http *hp;
@@ -366,6 +365,7 @@ FetchHdr(struct worker *wrk, struct busyobj *bo, struct req *req,
 	int retry = -1;
 	int i, first;
 	struct http_conn *htc;
+        int need_host_hdr;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_ORNULL(req, REQ_MAGIC);
@@ -374,6 +374,8 @@ FetchHdr(struct worker *wrk, struct busyobj *bo, struct req *req,
 
 	AN(bo->director);
 
+	need_host_hdr = !http_GetHdr(bo->bereq, H_Host, NULL);
+
 	hp = bo->bereq;
 
 	bo->vbc = VDI_GetFd(NULL, bo);
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 3c87406..c9e0e05 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -350,7 +350,7 @@ DOT fetch -> fetchbody [style=bold,color=blue]
 static enum req_fsm_nxt
 cnt_fetch(struct worker *wrk, struct req *req)
 {
-	int i, need_host_hdr;
+	int i;
 	struct busyobj *bo;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
@@ -367,12 +367,9 @@ cnt_fetch(struct worker *wrk, struct req *req)
 
 	HTTP_Setup(bo->beresp, bo->ws, bo->vsl, HTTP_Beresp);
 
-	need_host_hdr = !http_GetHdr(bo->bereq, H_Host, NULL);
-
 	req->acct_req.fetch++;
 
-	i = FetchHdr(wrk, bo, req->objcore->objhead == NULL ? req : NULL,
-	    need_host_hdr);
+	i = FetchHdr(wrk, bo, req->objcore->objhead == NULL ? req : NULL);
 	/*
 	 * If we recycle a backend connection, there is a finite chance
 	 * that the backend closed it before we get a request to it.
@@ -381,7 +378,7 @@ cnt_fetch(struct worker *wrk, struct req *req)
 	if (i == 1) {
 		VSC_C_main->backend_retry++;
 		i = FetchHdr(wrk, bo,
-		    req->objcore->objhead == NULL ? req : NULL, need_host_hdr);
+		    req->objcore->objhead == NULL ? req : NULL);
 	}
 
 	if (req->objcore->objhead != NULL)



More information about the varnish-commit mailing list