[master] 99d6751 Make HTC_Init() part of getting a request

Poul-Henning Kamp phk at varnish-cache.org
Tue Jun 19 13:23:28 CEST 2012


commit 99d6751242eb14a2f93e1c38a502fc208a2b02bb
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Jun 19 11:23:12 2012 +0000

    Make HTC_Init() part of getting a request

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 7090654..8d45641 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -921,7 +921,7 @@ struct sesspool *SES_NewPool(struct pool *pp, unsigned pool_no);
 void SES_DeletePool(struct sesspool *sp);
 int SES_Schedule(struct sess *sp);
 void SES_Handle(struct sess *sp, double now);
-void SES_GetReq(struct sess *sp);
+struct req *SES_GetReq(struct sess *sp);
 void SES_ReleaseReq(struct sess *sp);
 pool_func_t SES_pool_accept_task;
 
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index a925f1a..372d0c4 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -110,16 +110,10 @@ cnt_wait(struct sess *sp, struct worker *wrk, struct req *req)
 	assert(!isnan(sp->t_rx));
 
 	if (req == NULL) {
-		SES_GetReq(sp);
-		req = sp->req;
+		req = SES_GetReq(sp);
 		CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
-		assert(req->sp == sp);
-		HTC_Init(req->htc, req->ws, sp->fd, sp->req->vsl,
-		    cache_param->http_req_size,
-		    cache_param->http_req_hdr_len);
-	} else {
-		assert(req->sp == sp);
 	}
+	assert(req->sp == sp);
 
 	AZ(req->vcl);
 	AZ(req->obj);
@@ -945,13 +939,9 @@ cnt_first(struct sess *sp, struct worker *wrk)
 
 	/* Allocate a request already now, so we can VSL to it */
 	AZ(sp->req);
-	SES_GetReq(sp);
-	req = sp->req;
+	req = SES_GetReq(sp);
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	assert(req->sp == sp);
-	HTC_Init(req->htc, req->ws, sp->fd, req->vsl,
-	    cache_param->http_req_size,
-	    cache_param->http_req_hdr_len);
 
 	VTCP_name(&sp->sockaddr, sp->sockaddrlen,
 	    sp->addr, sizeof sp->addr, sp->port, sizeof sp->port);
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index df268f1..08f77f2 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -287,7 +287,7 @@ SES_Delete(struct sess *sp, const char *reason, double now)
  * Alloc/Free sp->req
  */
 
-void
+struct req *
 SES_GetReq(struct sess *sp)
 {
 	struct sesspool *pp;
@@ -341,6 +341,12 @@ SES_GetReq(struct sess *sp)
 	assert(p < e);
 
 	WS_Init(req->ws, "req", p, e - p);
+
+	HTC_Init(req->htc, req->ws, sp->fd, req->vsl,
+	    cache_param->http_req_size,
+	    cache_param->http_req_hdr_len);
+
+	return (req);
 }
 
 void



More information about the varnish-commit mailing list