[master] ef74b85 Move the busyobj reference from worker to req

Poul-Henning Kamp phk at varnish-cache.org
Sun Feb 19 13:51:54 CET 2012


commit ef74b856eaac7944960a0af957de842519f9d22e
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sun Feb 19 12:51:42 2012 +0000

    Move the busyobj reference from worker to req

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index c4efc49..4b5fcd8 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -316,7 +316,6 @@ struct worker {
 
 	struct ws		aws[1];
 
-	struct busyobj		*busyobj;
 
 	/* Temporary accounting */
 	struct acct		acct_tmp;
@@ -551,6 +550,7 @@ struct req {
 
 	/* The busy objhead we sleep on */
 	struct objhead		*hash_objhead;
+	struct busyobj		*busyobj;
 
 	/* Built Vary string */
 	uint8_t			*vary_b;
@@ -750,7 +750,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 sess *sp, int need_host_hdr, int sendbody);
-int FetchBody(struct worker *w, struct object *obj);
+int FetchBody(struct worker *w, struct busyobj *bo, struct object *obj);
 int FetchReqBody(const struct sess *sp, int sendbody);
 void Fetch_Init(void);
 
@@ -894,7 +894,6 @@ unsigned WRW_Write(struct worker *w, const void *ptr, int len);
 unsigned WRW_WriteH(struct worker *w, const txt *hh, const char *suf);
 
 /* cache_session.c [SES] */
-struct sess *SES_Alloc(void);
 void SES_Close(struct sess *sp, const char *reason);
 void SES_Delete(struct sess *sp, const char *reason, double now);
 void SES_Charge(struct sess *sp);
diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 085c7a7..cfe86ec 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -89,8 +89,8 @@ VBE_ReleaseConn(struct vbc *vc)
 
 #define FIND_TMO(tmx, dst, sp, be)					\
 	do {								\
-		CHECK_OBJ_NOTNULL(sp->wrk->busyobj, BUSYOBJ_MAGIC);	\
-		dst = sp->wrk->busyobj->tmx;				\
+		CHECK_OBJ_NOTNULL(sp->req->busyobj, BUSYOBJ_MAGIC);	\
+		dst = sp->req->busyobj->tmx;				\
 		if (dst == 0.0)						\
 			dst = be->tmx;					\
 		if (dst == 0.0)						\
diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index 2c95f61..0058c3c 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -796,7 +796,7 @@ ban_CheckLast(void)
  * Ban lurker thread
  */
 
-static int 
+static int
 ban_lurker_work(struct worker *wrk, unsigned pass)
 {
 	struct ban *b, *b0, *b2;
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index b921fee..a56e016 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -201,29 +201,32 @@ DOT }
 static int
 cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req)
 {
+	struct busyobj *bo;
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	bo = req->busyobj;
+	CHECK_OBJ_ORNULL(bo, BUSYOBJ_MAGIC);
 
 	CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC);
 	CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC);
 
-	if (wrk->busyobj != NULL) {
-		CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
-		AN(wrk->busyobj->do_stream);
+	if (bo != NULL) {
+		CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+		AN(bo->do_stream);
 		AssertObjCorePassOrBusy(req->obj->objcore);
 	}
 
 	req->res_mode = 0;
 
-	if (wrk->busyobj == NULL)
+	if (bo == NULL)
 		req->res_mode |= RES_LEN;
 
-	if (wrk->busyobj != NULL &&
-	    (wrk->busyobj->h_content_length != NULL ||
-	    !wrk->busyobj->do_stream) &&
-	    !wrk->busyobj->do_gzip && !wrk->busyobj->do_gunzip)
+	if (bo != NULL &&
+	    (bo->h_content_length != NULL ||
+	    !bo->do_stream) &&
+	    !bo->do_gzip && !bo->do_gunzip)
 		req->res_mode |= RES_LEN;
 
 	if (!req->disable_esi && req->obj->esidata != NULL) {
@@ -249,7 +252,7 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req)
 
 	if (!(req->res_mode & (RES_LEN|RES_CHUNKED|RES_EOF))) {
 		if (req->obj->len == 0 &&
-		    (wrk->busyobj == NULL || !wrk->busyobj->do_stream))
+		    (bo == NULL || !bo->do_stream))
 			/*
 			 * If the object is empty, neither ESI nor GUNZIP
 			 * can make it any different size
@@ -282,11 +285,11 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req)
 	case VCL_RET_RESTART:
 		if (req->restarts >= cache_param->max_restarts)
 			break;
-		if (wrk->busyobj != NULL) {
-			AN(wrk->busyobj->do_stream);
-			VDI_CloseFd(wrk, &wrk->busyobj->vbc);
+		if (bo != NULL) {
+			AN(bo->do_stream);
+			VDI_CloseFd(wrk, &bo->vbc);
 			HSH_Drop(wrk, &sp->req->obj);
-			VBO_DerefBusyObj(wrk, &wrk->busyobj);
+			VBO_DerefBusyObj(wrk, &bo);
 		} else {
 			(void)HSH_Deref(&wrk->stats, NULL, &req->obj);
 		}
@@ -325,7 +328,7 @@ cnt_deliver(struct sess *sp, struct worker *wrk, struct req *req)
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 
-	AZ(sp->wrk->busyobj);
+	AZ(req->busyobj);
 	req->director = NULL;
 	req->restarts = 0;
 
@@ -364,12 +367,10 @@ cnt_done(struct sess *sp, struct worker *wrk, struct req *req)
 	CHECK_OBJ_ORNULL(req->vcl, VCL_CONF_MAGIC);
 
 	AZ(req->obj);
-	AZ(wrk->busyobj);
+	AZ(req->busyobj);
 	req->director = NULL;
 	req->restarts = 0;
 
-	wrk->busyobj = NULL;
-
 	SES_Charge(sp);
 
 	/* If we did an ESI include, don't mess up our state */
@@ -464,6 +465,7 @@ static int
 cnt_error(struct sess *sp, struct worker *wrk, struct req *req)
 {
 	struct http *h;
+	struct busyobj *bo;
 	char date[40];
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
@@ -471,21 +473,22 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req)
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	AZ(req->objcore);
 	AZ(req->obj);
-	AZ(wrk->busyobj);
+	AZ(req->busyobj);
 
-	wrk->busyobj = VBO_GetBusyObj(wrk);
-	wrk->busyobj->vsl->wid = sp->vsl_id;
-	AZ(wrk->busyobj->stats);
-	wrk->busyobj->stats = &wrk->stats;
-	req->obj = STV_NewObject(wrk->busyobj, &req->objcore,
+	bo = VBO_GetBusyObj(wrk);
+	req->busyobj = bo;
+	bo->vsl->wid = sp->vsl_id;
+	AZ(bo->stats);
+	bo->stats = &wrk->stats;
+	req->obj = STV_NewObject(bo, &req->objcore,
 	    TRANSIENT_STORAGE, cache_param->http_resp_size,
 	    (uint16_t)cache_param->http_max_hdr);
-	wrk->busyobj->stats = NULL;
+	bo->stats = NULL;
 	if (req->obj == NULL) {
 		req->doclose = "Out of objects";
 		req->director = NULL;
-		http_Teardown(wrk->busyobj->beresp);
-		http_Teardown(wrk->busyobj->bereq);
+		http_Teardown(bo->beresp);
+		http_Teardown(bo->bereq);
 		sp->step = STP_DONE;
 		return(0);
 	}
@@ -513,7 +516,7 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req)
 	if (req->handling == VCL_RET_RESTART &&
 	    req->restarts <  cache_param->max_restarts) {
 		HSH_Drop(wrk, &sp->req->obj);
-		VBO_DerefBusyObj(wrk, &wrk->busyobj);
+		VBO_DerefBusyObj(wrk, &req->busyobj);
 		req->director = NULL;
 		req->restarts++;
 		sp->step = STP_RECV;
@@ -529,8 +532,8 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req)
 	assert(req->handling == VCL_RET_DELIVER);
 	req->err_code = 0;
 	req->err_reason = NULL;
-	http_Teardown(wrk->busyobj->bereq);
-	VBO_DerefBusyObj(wrk, &wrk->busyobj);
+	http_Teardown(bo->bereq);
+	VBO_DerefBusyObj(wrk, &req->busyobj);
 	sp->step = STP_PREPRESP;
 	return (0);
 }
@@ -559,7 +562,7 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req)
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 
 	CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC);
-	bo = wrk->busyobj;
+	bo = req->busyobj;
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 
 	AN(req->director);
@@ -643,7 +646,7 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req)
 		AZ(HSH_Deref(&wrk->stats, req->objcore, NULL));
 		req->objcore = NULL;
 	}
-	VBO_DerefBusyObj(wrk, &wrk->busyobj);
+	VBO_DerefBusyObj(wrk, &req->busyobj);
 	req->director = NULL;
 	req->storage_hint = NULL;
 
@@ -688,7 +691,7 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req)
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
-	bo = wrk->busyobj;
+	bo = req->busyobj;
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 
 	assert(req->handling == VCL_RET_DELIVER);
@@ -791,7 +794,6 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req)
 	    req->objcore == NULL)
 		req->storage_hint = TRANSIENT_STORAGE;
 
-	assert(bo == wrk->busyobj);
 	AZ(bo->stats);
 	bo->stats = &wrk->stats;
 	req->obj = STV_NewObject(bo, &req->objcore, req->storage_hint, l,
@@ -813,7 +815,7 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req)
 		req->err_code = 503;
 		sp->step = STP_ERROR;
 		VDI_CloseFd(wrk, &bo->vbc);
-		VBO_DerefBusyObj(wrk, &wrk->busyobj);
+		VBO_DerefBusyObj(wrk, &req->busyobj);
 		return (0);
 	}
 	CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC);
@@ -889,11 +891,11 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req)
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
-	bo = wrk->busyobj;
+	bo = req->busyobj;
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 
 	/* Use unmodified headers*/
-	i = FetchBody(wrk, req->obj);
+	i = FetchBody(wrk, bo, req->obj);
 
 	http_Teardown(bo->bereq);
 	http_Teardown(bo->beresp);
@@ -904,7 +906,7 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req)
 
 	if (i) {
 		HSH_Drop(wrk, &sp->req->obj);
-		VBO_DerefBusyObj(wrk, &wrk->busyobj);
+		VBO_DerefBusyObj(wrk, &req->busyobj);
 		AZ(req->obj);
 		req->err_code = 503;
 		sp->step = STP_ERROR;
@@ -918,7 +920,7 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req)
 		AZ(req->obj->ws_o->overflow);
 		HSH_Unbusy(req->obj->objcore);
 	}
-	VBO_DerefBusyObj(wrk, &wrk->busyobj);
+	VBO_DerefBusyObj(wrk, &req->busyobj);
 	wrk->acct_tmp.fetch++;
 	sp->step = STP_PREPRESP;
 	return (0);
@@ -997,15 +999,15 @@ cnt_hit(struct sess *sp, struct worker *wrk, struct req *req)
 	CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC);
 	CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC);
 	AZ(req->objcore);
-	AZ(wrk->busyobj);
+	AZ(req->busyobj);
 
 	assert(!(req->obj->objcore->flags & OC_F_PASS));
 
 	VCL_hit_method(sp);
 
 	if (req->handling == VCL_RET_DELIVER) {
-		//AZ(wrk->busyobj->bereq->ws);
-		//AZ(wrk->busyobj->beresp->ws);
+		//AZ(req->busyobj->bereq->ws);
+		//AZ(req->busyobj->beresp->ws);
 		(void)FetchReqBody(sp, 0);
 		sp->step = STP_PREPRESP;
 		return (0);
@@ -1064,7 +1066,7 @@ cnt_lookup(struct sess *sp, struct worker *wrk, struct req *req)
 	AZ(req->objcore);
 
 	CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC);
-	AZ(wrk->busyobj);
+	AZ(req->busyobj);
 
 	if (req->hash_objhead == NULL) {
 		/* Not a waiting list return */
@@ -1113,7 +1115,7 @@ cnt_lookup(struct sess *sp, struct worker *wrk, struct req *req)
 		req->vary_e = NULL;
 
 		req->objcore = oc;
-		CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
+		CHECK_OBJ_NOTNULL(req->busyobj, BUSYOBJ_MAGIC);
 		sp->step = STP_MISS;
 		return (0);
 	}
@@ -1159,40 +1161,42 @@ DOT
 static int
 cnt_miss(struct sess *sp, struct worker *wrk, struct req *req)
 {
+	struct busyobj *bo;
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC);
 	CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
-	CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
+	bo = req->busyobj;
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	AZ(req->obj);
 
-	http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws, wrk->busyobj->vsl);
+	http_Setup(bo->bereq, bo->ws, bo->vsl);
 	http_FilterReq(sp, HTTPH_R_FETCH);
-	http_ForceGet(wrk->busyobj->bereq);
+	http_ForceGet(bo->bereq);
 	if (cache_param->http_gzip_support) {
 		/*
 		 * We always ask the backend for gzip, even if the
 		 * client doesn't grok it.  We will uncompress for
 		 * the minority of clients which don't.
 		 */
-		http_Unset(wrk->busyobj->bereq, H_Accept_Encoding);
-		http_SetHeader(wrk->busyobj->bereq, "Accept-Encoding: gzip");
+		http_Unset(bo->bereq, H_Accept_Encoding);
+		http_SetHeader(bo->bereq, "Accept-Encoding: gzip");
 	}
 
 	VCL_miss_method(sp);
 
 	if (req->handling == VCL_RET_FETCH) {
-		CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
+		CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 		sp->step = STP_FETCH;
 		return (0);
 	}
 
 	AZ(HSH_Deref(&wrk->stats, req->objcore, NULL));
 	req->objcore = NULL;
-	http_Teardown(wrk->busyobj->bereq);
-	VBO_DerefBusyObj(wrk, &wrk->busyobj);
+	http_Teardown(bo->bereq);
+	VBO_DerefBusyObj(wrk, &req->busyobj);
 
 	switch(req->handling) {
 	case VCL_RET_ERROR:
@@ -1230,7 +1234,7 @@ XDOT err_pass [label="ERROR",shape=plaintext]
  */
 
 static int
-cnt_pass(struct sess *sp, struct worker *wrk, const struct req *req)
+cnt_pass(struct sess *sp, struct worker *wrk, struct req *req)
 {
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
@@ -1238,18 +1242,18 @@ cnt_pass(struct sess *sp, struct worker *wrk, const struct req *req)
 	CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC);
 	AZ(req->objcore);
 	AZ(req->obj);
-	AZ(wrk->busyobj);
+	AZ(req->busyobj);
 
-	wrk->busyobj = VBO_GetBusyObj(wrk);
-	wrk->busyobj->vsl->wid = sp->vsl_id;
-	http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws, wrk->busyobj->vsl);
+	req->busyobj = VBO_GetBusyObj(wrk);
+	req->busyobj->vsl->wid = sp->vsl_id;
+	http_Setup(req->busyobj->bereq, req->busyobj->ws, req->busyobj->vsl);
 	http_FilterReq(sp, HTTPH_R_PASS);
 
 	VCL_pass_method(sp);
 
 	if (req->handling == VCL_RET_ERROR) {
-		http_Teardown(wrk->busyobj->bereq);
-		VBO_DerefBusyObj(wrk, &wrk->busyobj);
+		http_Teardown(req->busyobj->bereq);
+		VBO_DerefBusyObj(wrk, &req->busyobj);
 		sp->step = STP_ERROR;
 		return (0);
 	}
@@ -1285,19 +1289,19 @@ DOT err_pipe [label="ERROR",shape=plaintext]
  */
 
 static int
-cnt_pipe(struct sess *sp, struct worker *wrk, const struct req *req)
+cnt_pipe(struct sess *sp, struct worker *wrk, struct req *req)
 {
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC);
-	AZ(wrk->busyobj);
+	AZ(req->busyobj);
 
 	wrk->acct_tmp.pipe++;
-	wrk->busyobj = VBO_GetBusyObj(wrk);
-	wrk->busyobj->vsl->wid = sp->vsl_id;
-	http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws, wrk->busyobj->vsl);
+	req->busyobj = VBO_GetBusyObj(wrk);
+	req->busyobj->vsl->wid = sp->vsl_id;
+	http_Setup(req->busyobj->bereq, req->busyobj->ws, req->busyobj->vsl);
 	http_FilterReq(sp, 0);
 
 	VCL_pipe_method(sp);
@@ -1308,8 +1312,8 @@ cnt_pipe(struct sess *sp, struct worker *wrk, const struct req *req)
 
 	PipeSession(sp);
 	assert(WRW_IsReleased(wrk));
-	http_Teardown(wrk->busyobj->bereq);
-	VBO_DerefBusyObj(wrk, &wrk->busyobj);
+	http_Teardown(req->busyobj->bereq);
+	VBO_DerefBusyObj(wrk, &req->busyobj);
 	sp->step = STP_DONE;
 	return (0);
 }
@@ -1354,7 +1358,7 @@ cnt_recv(struct sess *sp, const struct worker *wrk, struct req *req)
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC);
 	AZ(req->obj);
-	AZ(wrk->busyobj);
+	AZ(req->busyobj);
 
 	/* By default we use the first backend */
 	AZ(req->director);
diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c
index ab74b59..3f70cb7 100644
--- a/bin/varnishd/cache/cache_dir.c
+++ b/bin/varnishd/cache/cache_dir.c
@@ -120,7 +120,7 @@ VDI_GetFd(const struct director *d, struct sess *sp)
 	CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
 	vc = d->getfd(d, sp);
 	if (vc != NULL) {
-		vc->vsl = sp->wrk->busyobj->vsl;
+		vc->vsl = sp->req->busyobj->vsl;
 		vc->orig_vsl_id = vc->vsl->wid;
 		vc->vsl->wid = vc->vsl_id;
 	}
diff --git a/bin/varnishd/cache/cache_dir_dns.c b/bin/varnishd/cache/cache_dir_dns.c
index 80310b9..9cad3f6 100644
--- a/bin/varnishd/cache/cache_dir_dns.c
+++ b/bin/varnishd/cache/cache_dir_dns.c
@@ -347,8 +347,8 @@ vdi_dns_find_backend(const struct sess *sp, struct vdi_dns *vs)
 	/* bereq is only present after recv et. al, otherwise use req (ie:
 	 * use req for health checks in vcl_recv and such).
 	 */
-	if (sp->wrk->busyobj != NULL && sp->wrk->busyobj->bereq)
-		hp = sp->wrk->busyobj->bereq;
+	if (sp->req->busyobj != NULL && sp->req->busyobj->bereq)
+		hp = sp->req->busyobj->bereq;
 	else
 		hp = sp->req->http;
 
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index adc5af3..24abc7a 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -46,7 +46,7 @@ static unsigned fetchfrag;
  * We want to issue the first error we encounter on fetching and
  * supress the rest.  This function does that.
  *
- * Other code is allowed to look at wrk->busyobj->fetch_failed to bail out
+ * Other code is allowed to look at sp->req->busyobj->fetch_failed to bail out
  *
  * For convenience, always return -1
  */
@@ -385,33 +385,37 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
 {
 	struct vbc *vc;
 	struct worker *wrk;
+	struct req *req;
+	struct busyobj *bo;
 	struct http *hp;
 	int retry = -1;
 	int i;
 	struct http_conn *htc;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	wrk = sp->wrk;
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
-	CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
-	htc = &wrk->busyobj->htc;
+	req = sp->req;
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	bo = req->busyobj;
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	htc = &bo->htc;
 
-	AN(sp->req->director);
-	AZ(sp->req->obj);
+	AN(req->director);
+	AZ(req->obj);
 
-	if (sp->req->objcore != NULL) {		/* pass has no objcore */
-		CHECK_OBJ_NOTNULL(sp->req->objcore, OBJCORE_MAGIC);
-		AN(sp->req->objcore->flags & OC_F_BUSY);
+	if (req->objcore != NULL) {		/* pass has no objcore */
+		CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
+		AN(req->objcore->flags & OC_F_BUSY);
 	}
 
-	hp = wrk->busyobj->bereq;
+	hp = bo->bereq;
 
-	wrk->busyobj->vbc = VDI_GetFd(NULL, sp);
-	if (wrk->busyobj->vbc == NULL) {
-		VSLb(sp->req->vsl, SLT_FetchError, "no backend connection");
+	bo->vbc = VDI_GetFd(NULL, sp);
+	if (bo->vbc == NULL) {
+		VSLb(req->vsl, SLT_FetchError, "no backend connection");
 		return (-1);
 	}
-	vc = wrk->busyobj->vbc;
+	vc = bo->vbc;
 	if (vc->recycled)
 		retry = 1;
 
@@ -421,7 +425,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
 	 * because the backend may be chosen by a director.
 	 */
 	if (need_host_hdr)
-		VDI_AddHostHeader(wrk->busyobj->bereq, vc);
+		VDI_AddHostHeader(bo->bereq, vc);
 
 	(void)VTCP_blocking(vc->fd);	/* XXX: we should timeout instead */
 	WRW_Reserve(wrk, &vc->fd, sp->t_req);	/* XXX t_resp ? */
@@ -430,10 +434,10 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
 	/* Deal with any message-body the request might have */
 	i = FetchReqBody(sp, sendbody);
 	if (WRW_FlushRelease(wrk) || i > 0) {
-		VSLb(sp->req->vsl, SLT_FetchError,
+		VSLb(req->vsl, SLT_FetchError,
 		    "backend write error: %d (%s)",
 		    errno, strerror(errno));
-		VDI_CloseFd(wrk, &wrk->busyobj->vbc);
+		VDI_CloseFd(wrk, &bo->vbc);
 		/* XXX: other cleanup ? */
 		return (retry);
 	}
@@ -446,7 +450,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
 
 	/* Receive response */
 
-	HTC_Init(htc, wrk->busyobj->ws, vc->fd, vc->vsl,
+	HTC_Init(htc, bo->ws, vc->fd, vc->vsl,
 	    cache_param->http_resp_size,
 	    cache_param->http_resp_hdr_len);
 
@@ -455,10 +459,10 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
 	i = HTC_Rx(htc);
 
 	if (i < 0) {
-		VSLb(sp->req->vsl, SLT_FetchError,
+		VSLb(req->vsl, SLT_FetchError,
 		    "http first read error: %d %d (%s)",
 		    i, errno, strerror(errno));
-		VDI_CloseFd(wrk, &wrk->busyobj->vbc);
+		VDI_CloseFd(wrk, &bo->vbc);
 		/* XXX: other cleanup ? */
 		/* Retryable if we never received anything */
 		return (i == -1 ? retry : -1);
@@ -469,20 +473,20 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
 	while (i == 0) {
 		i = HTC_Rx(htc);
 		if (i < 0) {
-			VSLb(sp->req->vsl, SLT_FetchError,
+			VSLb(req->vsl, SLT_FetchError,
 			    "http first read error: %d %d (%s)",
 			    i, errno, strerror(errno));
-			VDI_CloseFd(wrk, &wrk->busyobj->vbc);
+			VDI_CloseFd(wrk, &bo->vbc);
 			/* XXX: other cleanup ? */
 			return (-1);
 		}
 	}
 
-	hp = wrk->busyobj->beresp;
+	hp = bo->beresp;
 
 	if (http_DissectResponse(hp, htc)) {
-		VSLb(sp->req->vsl, SLT_FetchError, "http format error");
-		VDI_CloseFd(wrk, &wrk->busyobj->vbc);
+		VSLb(req->vsl, SLT_FetchError, "http format error");
+		VDI_CloseFd(wrk, &bo->vbc);
 		/* XXX: other cleanup ? */
 		return (-1);
 	}
@@ -492,17 +496,15 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
 /*--------------------------------------------------------------------*/
 
 int
-FetchBody(struct worker *wrk, struct object *obj)
+FetchBody(struct worker *wrk, struct busyobj *bo, struct object *obj)
 {
 	int cls;
 	struct storage *st;
 	int mklen;
 	ssize_t cl;
 	struct http_conn *htc;
-	struct busyobj *bo;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
-	bo = wrk->busyobj;
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	AZ(bo->fetch_obj);
 	CHECK_OBJ_NOTNULL(bo->vbc, VBC_MAGIC);
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index 15b0a2a..1e21214 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -443,16 +443,16 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
 	AN(oc->flags & OC_F_BUSY);
 	oc->refcnt = 1;
 
-	AZ(wrk->busyobj);
-	wrk->busyobj = VBO_GetBusyObj(wrk);
-	wrk->busyobj->vsl->wid = sp->vsl_id;
+	AZ(sp->req->busyobj);
+	sp->req->busyobj = VBO_GetBusyObj(wrk);
+	sp->req->busyobj->vsl->wid = sp->vsl_id;
 
 	VRY_Validate(sp->req->vary_b);
 	if (sp->req->vary_l != NULL)
-		wrk->busyobj->vary = sp->req->vary_b;
+		sp->req->busyobj->vary = sp->req->vary_b;
 	else
-		wrk->busyobj->vary = NULL;
-	oc->busyobj = wrk->busyobj;
+		sp->req->busyobj->vary = NULL;
+	oc->busyobj = sp->req->busyobj;
 
 	/*
 	 * Busy objects go on the tail, so they will not trip up searches.
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index f721ea2..02ab94f 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -854,7 +854,7 @@ http_FilterReq(const struct sess *sp, unsigned how)
 {
 	struct http *hp;
 
-	hp = sp->wrk->busyobj->bereq;
+	hp = sp->req->busyobj->bereq;
 	CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
 	hp->logtag = HTTP_Tx;
 
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 5a2a805..2689cc8 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -197,10 +197,6 @@ pan_wrk(const struct worker *wrk)
 
 	VSB_printf(pan_vsp, "  worker = %p {\n", wrk);
 	pan_ws(wrk->aws, 4);
-	if (wrk->busyobj != NULL && wrk->busyobj->bereq->ws != NULL)
-		pan_http("bereq", wrk->busyobj->bereq, 4);
-	if (wrk->busyobj != NULL && wrk->busyobj->beresp->ws != NULL)
-		pan_http("beresp", wrk->busyobj->beresp, 4);
 	VSB_printf(pan_vsp, "  },\n");
 }
 
@@ -221,6 +217,10 @@ pan_busyobj(const struct busyobj *bo)
 	VSB_printf(pan_vsp, "    },\n");
 	if (VALID_OBJ(bo->vbc, BACKEND_MAGIC))
 		pan_vbc(bo->vbc);
+	if (bo->bereq->ws != NULL)
+		pan_http("bereq", bo->bereq, 4);
+	if (bo->beresp->ws != NULL)
+		pan_http("beresp", bo->beresp, 4);
 
 }
 
@@ -261,8 +261,8 @@ pan_sess(const struct sess *sp)
 	VSB_printf(pan_vsp, "  restarts = %d, esi_level = %d\n",
 	    sp->req->restarts, sp->req->esi_level);
 
-	if (sp->wrk->busyobj != NULL)
-		pan_busyobj(sp->wrk->busyobj);
+	if (sp->req->busyobj != NULL)
+		pan_busyobj(sp->req->busyobj);
 
 	pan_ws(sp->req->ws, 2);
 	pan_http("req", sp->req->http, 2);
diff --git a/bin/varnishd/cache/cache_pipe.c b/bin/varnishd/cache/cache_pipe.c
index 688d87d..3f7cadf 100644
--- a/bin/varnishd/cache/cache_pipe.c
+++ b/bin/varnishd/cache/cache_pipe.c
@@ -63,31 +63,33 @@ void
 PipeSession(struct sess *sp)
 {
 	struct vbc *vc;
-	struct worker *w;
+	struct worker *wrk;
 	struct pollfd fds[2];
+	struct busyobj *bo;
 	int i;
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->wrk->busyobj, BUSYOBJ_MAGIC);
-	w = sp->wrk;
+	bo = sp->req->busyobj;
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	wrk = sp->wrk;
 
 	vc = VDI_GetFd(NULL, sp);
 	if (vc == NULL)
 		return;
-	sp->wrk->busyobj->vbc = vc;		/* For panic dumping */
+	bo->vbc = vc;		/* For panic dumping */
 	(void)VTCP_blocking(vc->fd);
 
-	WRW_Reserve(w, &vc->fd, sp->t_req);
+	WRW_Reserve(wrk, &vc->fd, sp->t_req);
 	sp->wrk->acct_tmp.hdrbytes +=
-	    http_Write(w, sp->wrk->busyobj->bereq, 0);
+	    http_Write(wrk, bo->bereq, 0);
 
 	if (sp->req->htc->pipeline.b != NULL)
 		sp->wrk->acct_tmp.bodybytes +=
-		    WRW_Write(w, sp->req->htc->pipeline.b,
+		    WRW_Write(wrk, sp->req->htc->pipeline.b,
 		    Tlen(sp->req->htc->pipeline));
 
-	i = WRW_FlushRelease(w);
+	i = WRW_FlushRelease(wrk);
 
 	if (i) {
 		SES_Close(sp, "pipe");
@@ -132,5 +134,5 @@ PipeSession(struct sess *sp)
 	}
 	SES_Close(sp, "pipe");
 	VDI_CloseFd(sp->wrk, &vc);
-	sp->wrk->busyobj->vbc = NULL;
+	bo->vbc = NULL;
 }
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 10a8182..f41b7ec 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -112,22 +112,6 @@ ses_new(struct sesspool *pp)
 }
 
 /*--------------------------------------------------------------------
- * Allocate a session for use by background threads.
- */
-
-struct sess *
-SES_Alloc(void)
-{
-	struct sess *sp;
-
-	ALLOC_OBJ(sp, SESS_MAGIC);
-	AN(sp);
-	ses_setup(sp);
-	/* XXX: sp->req ? */
-	return (sp);
-}
-
-/*--------------------------------------------------------------------
  * The pool-task function for sessions
  */
 
@@ -148,7 +132,6 @@ ses_pool_task(struct worker *wrk, void *arg)
 	sp = NULL;			/* Cannot access sp any longer */
 	THR_SetSession(NULL);
 	WS_Assert(wrk->aws);
-	AZ(wrk->busyobj);
 	AZ(wrk->wrw);
 	assert(wrk->vsl->wlp == wrk->vsl->wlb);
 	if (cache_param->diag_bitmap & 0x00040000) {
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index c9135dc..cbe5637 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -101,10 +101,10 @@ vrt_selecthttp(const struct sess *sp, enum gethdr_e where)
 		hp = sp->req->http;
 		break;
 	case HDR_BEREQ:
-		hp = sp->wrk->busyobj->bereq;
+		hp = sp->req->busyobj->bereq;
 		break;
 	case HDR_BERESP:
-		hp = sp->wrk->busyobj->beresp;
+		hp = sp->req->busyobj->beresp;
 		break;
 	case HDR_RESP:
 		hp = sp->req->resp;
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 82aeb9c..72fa4dc 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -84,15 +84,15 @@ VRT_r_##obj##_##hdr(const struct sess *sp)			\
 VRT_DO_HDR(req,   request,	sp->req->http,		HTTP_HDR_REQ)
 VRT_DO_HDR(req,   url,		sp->req->http,		HTTP_HDR_URL)
 VRT_DO_HDR(req,   proto,	sp->req->http,		HTTP_HDR_PROTO)
-VRT_DO_HDR(bereq, request,	sp->wrk->busyobj->bereq,	HTTP_HDR_REQ)
-VRT_DO_HDR(bereq, url,		sp->wrk->busyobj->bereq,	HTTP_HDR_URL)
-VRT_DO_HDR(bereq, proto,	sp->wrk->busyobj->bereq,	HTTP_HDR_PROTO)
+VRT_DO_HDR(bereq, request,	sp->req->busyobj->bereq,	HTTP_HDR_REQ)
+VRT_DO_HDR(bereq, url,		sp->req->busyobj->bereq,	HTTP_HDR_URL)
+VRT_DO_HDR(bereq, proto,	sp->req->busyobj->bereq,	HTTP_HDR_PROTO)
 VRT_DO_HDR(obj,   proto,	sp->req->obj->http,	HTTP_HDR_PROTO)
 VRT_DO_HDR(obj,   response,	sp->req->obj->http,	HTTP_HDR_RESPONSE)
 VRT_DO_HDR(resp,  proto,	sp->req->resp,		HTTP_HDR_PROTO)
 VRT_DO_HDR(resp,  response,	sp->req->resp,		HTTP_HDR_RESPONSE)
-VRT_DO_HDR(beresp,  proto,	sp->wrk->busyobj->beresp,	HTTP_HDR_PROTO)
-VRT_DO_HDR(beresp,  response,	sp->wrk->busyobj->beresp, HTTP_HDR_RESPONSE)
+VRT_DO_HDR(beresp,  proto,	sp->req->busyobj->beresp,	HTTP_HDR_PROTO)
+VRT_DO_HDR(beresp,  response,	sp->req->busyobj->beresp, HTTP_HDR_RESPONSE)
 
 /*--------------------------------------------------------------------*/
 
@@ -114,7 +114,7 @@ VRT_r_##obj##_status(const struct sess *sp)			\
 }
 
 VRT_DO_STATUS(obj, sp->req->obj->http)
-VRT_DO_STATUS(beresp, sp->wrk->busyobj->beresp)
+VRT_DO_STATUS(beresp, sp->req->busyobj->beresp)
 VRT_DO_STATUS(resp, sp->req->resp)
 
 /*--------------------------------------------------------------------*/
@@ -130,14 +130,11 @@ VRT_l_beresp_saintmode(const struct sess *sp, double a)
 	struct trouble *new;
 	struct trouble *tr;
 	struct trouble *tr2;
-	struct worker *wrk;
 	struct vbc *vbc;
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
-	wrk = sp->wrk;
-	CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
-	vbc = wrk->busyobj->vbc;
+	CHECK_OBJ_NOTNULL(sp->req->busyobj, BUSYOBJ_MAGIC);
+	vbc = sp->req->busyobj->vbc;
 	if (!vbc)
 		return;
 	CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC);
@@ -187,14 +184,14 @@ void									\
 VRT_l_##dir##_##onm(const struct sess *sp, type a)			\
 {									\
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);				\
-	sp->wrk->field = a;						\
+	sp->req->field = a;						\
 }									\
 									\
 type									\
 VRT_r_##dir##_##onm(const struct sess *sp)				\
 {									\
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);				\
-	return (sp->wrk->field);					\
+	return (sp->req->field);					\
 }
 
 VBERESP(beresp, unsigned, do_esi, busyobj->do_esi)
@@ -235,8 +232,8 @@ VRT_l_bereq_##which(struct sess *sp, double num)		\
 {								\
 								\
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);			\
-	CHECK_OBJ_NOTNULL(sp->wrk->busyobj, BUSYOBJ_MAGIC);	\
-	sp->wrk->busyobj->which = (num > 0.0 ? num : 0.0);	\
+	CHECK_OBJ_NOTNULL(sp->req->busyobj, BUSYOBJ_MAGIC);	\
+	sp->req->busyobj->which = (num > 0.0 ? num : 0.0);	\
 }								\
 								\
 double __match_proto__()					\
@@ -244,8 +241,8 @@ VRT_r_bereq_##which(struct sess *sp)				\
 {								\
 								\
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);			\
-	CHECK_OBJ_NOTNULL(sp->wrk->busyobj, BUSYOBJ_MAGIC);	\
-	return(sp->wrk->busyobj->which);			\
+	CHECK_OBJ_NOTNULL(sp->req->busyobj, BUSYOBJ_MAGIC);	\
+	return(sp->req->busyobj->which);			\
 }
 
 BEREQ_TIMEOUT(connect_timeout)
@@ -259,8 +256,8 @@ VRT_r_beresp_backend_name(const struct sess *sp)
 {
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->wrk->busyobj->vbc, VBC_MAGIC);
-	return(sp->wrk->busyobj->vbc->backend->vcl_name);
+	CHECK_OBJ_NOTNULL(sp->req->busyobj->vbc, VBC_MAGIC);
+	return(sp->req->busyobj->vbc->backend->vcl_name);
 }
 
 struct sockaddr_storage *
@@ -268,8 +265,8 @@ VRT_r_beresp_backend_ip(const struct sess *sp)
 {
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->wrk->busyobj->vbc, VBC_MAGIC);
-	return(sp->wrk->busyobj->vbc->addr);
+	CHECK_OBJ_NOTNULL(sp->req->busyobj->vbc, VBC_MAGIC);
+	return(sp->req->busyobj->vbc->addr);
 }
 
 int
@@ -277,8 +274,8 @@ VRT_r_beresp_backend_port(const struct sess *sp)
 {
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->wrk->busyobj->vbc, VBC_MAGIC);
-	return (VTCP_port(sp->wrk->busyobj->vbc->addr));
+	CHECK_OBJ_NOTNULL(sp->req->busyobj->vbc, VBC_MAGIC);
+	return (VTCP_port(sp->req->busyobj->vbc->addr));
 }
 
 const char * __match_proto__()
@@ -298,7 +295,7 @@ VRT_l_beresp_storage(struct sess *sp, const char *str, ...)
 	char *b;
 
 	va_start(ap, str);
-	b = VRT_String(sp->wrk->busyobj->ws, NULL, str, ap);
+	b = VRT_String(sp->req->busyobj->ws, NULL, str, ap);
 	va_end(ap);
 	sp->req->storage_hint = b;
 }
@@ -417,12 +414,12 @@ VRT_DO_EXP(obj, sp->req->obj->exp, keep, 0,
    EXP_Rearm(sp->req->obj);
    vrt_wsp_exp(sp, sp->req->obj->xid, &sp->req->obj->exp);)
 
-VRT_DO_EXP(beresp, sp->wrk->busyobj->exp, grace, 0,
-   vrt_wsp_exp(sp, sp->req->xid, &sp->wrk->busyobj->exp);)
-VRT_DO_EXP(beresp, sp->wrk->busyobj->exp, ttl, 0,
-   vrt_wsp_exp(sp, sp->req->xid, &sp->wrk->busyobj->exp);)
-VRT_DO_EXP(beresp, sp->wrk->busyobj->exp, keep, 0,
-   vrt_wsp_exp(sp, sp->req->xid, &sp->wrk->busyobj->exp);)
+VRT_DO_EXP(beresp, sp->req->busyobj->exp, grace, 0,
+   vrt_wsp_exp(sp, sp->req->xid, &sp->req->busyobj->exp);)
+VRT_DO_EXP(beresp, sp->req->busyobj->exp, ttl, 0,
+   vrt_wsp_exp(sp, sp->req->xid, &sp->req->busyobj->exp);)
+VRT_DO_EXP(beresp, sp->req->busyobj->exp, keep, 0,
+   vrt_wsp_exp(sp, sp->req->xid, &sp->req->busyobj->exp);)
 
 /*--------------------------------------------------------------------
  * req.xid



More information about the varnish-commit mailing list