[master] 1764f13 Split resp.* construction so that version independent stuff goes into req_fsm.c::cnt_deliver{}

Poul-Henning Kamp phk at varnish-cache.org
Wed Sep 4 10:53:22 CEST 2013


commit 1764f13a7b74d492107d031f34a6935c712ae3da
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Sep 4 08:52:34 2013 +0000

    Split resp.* construction so that version independent stuff goes
    into req_fsm.c::cnt_deliver{}

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index ca47bf0..bfde6f7 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -157,6 +157,7 @@ DOT deliver:stream:s -> stream [style=bold,color=blue]
 static enum req_fsm_nxt
 cnt_deliver(struct worker *wrk, struct req *req)
 {
+	char time_str[30];
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
@@ -216,11 +217,34 @@ cnt_deliver(struct worker *wrk, struct req *req)
 		if (!cache_param->obj_readonly)
 			req->obj->last_use = req->t_resp; /* XXX: locking ? */
 	}
+
 	HTTP_Setup(req->resp, req->ws, req->vsl, HTTP_Resp);
-	RES_BuildHttp(req);
+
+	http_ClrHeader(req->resp);
+	http_FilterResp(req->obj->http, req->resp, 0);
+
+	http_Unset(req->resp, H_Date);
+	VTIM_format(VTIM_real(), time_str);
+	http_PrintfHeader(req->resp, "Date: %s", time_str);
+
+	if (req->wrk->stats.cache_hit)
+		http_PrintfHeader(req->resp,
+		    "X-Varnish: %u %u", req->vsl->wid & VSL_IDENTMASK,
+		    req->obj->vxid & VSL_IDENTMASK);
+	else
+		http_PrintfHeader(req->resp,
+		    "X-Varnish: %u", req->vsl->wid & VSL_IDENTMASK);
+
+	http_PrintfHeader(req->resp, "Age: %.0f",
+	    req->obj->exp.age + req->t_resp - req->obj->exp.entered);
+
+	http_SetHeader(req->resp, "Via: 1.1 varnish");
+	
 
 	VCL_deliver_method(req->vcl, wrk, req, NULL, req->http->ws);
 
+	RES_BuildHttp(req);
+
 	while (req->obj->objcore->busyobj) {
 		VSLb(req->vsl, SLT_Debug, "HERE %s %d", __func__, __LINE__);
 		(void)usleep(10000);
diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c
index 5e9f997..0dee670 100644
--- a/bin/varnishd/cache/cache_response.c
+++ b/bin/varnishd/cache/cache_response.c
@@ -32,7 +32,6 @@
 #include "cache.h"
 
 #include "vct.h"
-#include "vtim.h"
 
 /*--------------------------------------------------------------------*/
 
@@ -105,14 +104,10 @@ res_dorange(const struct req *req, const char *r, ssize_t *plow, ssize_t *phigh)
 void
 RES_BuildHttp(struct req *req)
 {
-	char time_str[30];
 
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC);
 
-	http_ClrHeader(req->resp);
-	http_FilterResp(req->obj->http, req->resp, 0);
-
 	if (!(req->res_mode & RES_LEN)) {
 		http_Unset(req->resp, H_Content_Length);
 	} else if (cache_param->http_range_support) {
@@ -133,21 +128,6 @@ RES_BuildHttp(struct req *req)
 	} else if (req->res_mode & RES_CHUNKED)
 		http_SetHeader(req->resp, "Transfer-Encoding: chunked");
 
-	http_Unset(req->resp, H_Date);
-	VTIM_format(VTIM_real(), time_str);
-	http_PrintfHeader(req->resp, "Date: %s", time_str);
-
-	if (req->wrk->stats.cache_hit)
-		http_PrintfHeader(req->resp,
-		    "X-Varnish: %u %u", req->vsl->wid & VSL_IDENTMASK,
-		    req->obj->vxid & VSL_IDENTMASK);
-	else
-		http_PrintfHeader(req->resp,
-		    "X-Varnish: %u", req->vsl->wid & VSL_IDENTMASK);
-	http_PrintfHeader(req->resp, "Age: %.0f",
-	    req->obj->exp.age + req->t_resp -
-	    req->obj->exp.entered);
-	http_SetHeader(req->resp, "Via: 1.1 varnish");
 	http_PrintfHeader(req->resp, "Connection: %s",
 	    req->doclose ? "close" : "keep-alive");
 }



More information about the varnish-commit mailing list