[experimental-ims] 097e646 Move another 144 bytes from sess to req

Geoff Simmons geoff at varnish-cache.org
Tue Jan 10 00:03:31 CET 2012


commit 097e646a65fc157751f93bbd24005eaa1e34d160
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Dec 23 12:15:35 2011 +0000

    Move another 144 bytes from sess to req

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index f45235b..1b2f1a7 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -582,6 +582,29 @@ struct req {
 #define REQ_MAGIC		0x2751aaa1
 
 	unsigned		xid;
+	int			restarts;
+	int			esi_level;
+	int			disable_esi;
+	uint8_t			hash_ignore_busy;
+	uint8_t			hash_always_miss;
+
+	/* The busy objhead we sleep on */
+	struct objhead		*hash_objhead;
+
+	/* Built Vary string */
+	uint8_t			*vary_b;
+	uint8_t			*vary_l;
+	uint8_t			*vary_e;
+
+	unsigned char		digest[DIGEST_LEN];
+
+	const char		*doclose;
+	struct exp		exp;
+	unsigned		cur_method;
+	unsigned		handling;
+	unsigned char		sendbody;
+	unsigned char		wantbody;
+
 };
 
 /*--------------------------------------------------------------------*/
@@ -624,46 +647,20 @@ struct sess {
 #if defined(HAVE_EPOLL_CTL)
 	struct epoll_event ev;
 #endif
+	enum step		step;
 
 	/* Request related fields ------------------------------------*/
 
-
-	int			restarts;
-	int			esi_level;
-	int			disable_esi;
-
-	uint8_t			hash_ignore_busy;
-	uint8_t			hash_always_miss;
-
 	/* HTTP request */
-	const char		*doclose;
 	struct http		*http;
 	struct http		*http0;
 
 	struct ws		ws[1];
 	char			*ws_req;	/* WS above request data */
 
-	unsigned char		digest[DIGEST_LEN];
-
-	/* Built Vary string */
-	uint8_t			*vary_b;
-	uint8_t			*vary_l;
-	uint8_t			*vary_e;
-
-	/* Acceptable grace period */
-	struct exp		exp;
-
-	enum step		step;
-	unsigned		cur_method;
-	unsigned		handling;
-	unsigned char		sendbody;
-	unsigned char		wantbody;
 	uint16_t		err_code;
 	const char		*err_reason;
 
-	/* The busy objhead we sleep on */
-	struct objhead		*hash_objhead;
-
 	struct director		*director;
 	struct VCL_conf		*vcl;
 
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 1de6ed7..cb5d161 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -112,7 +112,7 @@ cnt_wait(struct sess *sp)
 
 	AZ(sp->vcl);
 	AZ(wrk->obj);
-	AZ(sp->esi_level);
+	AZ(sp->req->esi_level);
 	assert(sp->req->xid == 0);
 
 	assert(!isnan(sp->t_req));
@@ -229,13 +229,13 @@ cnt_prepresp(struct sess *sp)
 	    !wrk->busyobj->do_gzip && !wrk->busyobj->do_gunzip)
 		wrk->res_mode |= RES_LEN;
 
-	if (!sp->disable_esi && wrk->obj->esidata != NULL) {
+	if (!sp->req->disable_esi && wrk->obj->esidata != NULL) {
 		/* In ESI mode, we don't know the aggregate length */
 		wrk->res_mode &= ~RES_LEN;
 		wrk->res_mode |= RES_ESI;
 	}
 
-	if (sp->esi_level > 0) {
+	if (sp->req->esi_level > 0) {
 		wrk->res_mode &= ~RES_LEN;
 		wrk->res_mode |= RES_ESI_CHILD;
 	}
@@ -258,13 +258,13 @@ cnt_prepresp(struct sess *sp)
 			 * can make it any different size
 			 */
 			wrk->res_mode |= RES_LEN;
-		else if (!sp->wantbody) {
+		else if (!sp->req->wantbody) {
 			/* Nothing */
 		} else if (sp->http->protover >= 11) {
 			wrk->res_mode |= RES_CHUNKED;
 		} else {
 			wrk->res_mode |= RES_EOF;
-			sp->doclose = "EOF mode";
+			sp->req->doclose = "EOF mode";
 		}
 	}
 
@@ -279,11 +279,11 @@ cnt_prepresp(struct sess *sp)
 	http_Setup(wrk->resp, wrk->ws);
 	RES_BuildHttp(sp);
 	VCL_deliver_method(sp);
-	switch (sp->handling) {
+	switch (sp->req->handling) {
 	case VCL_RET_DELIVER:
 		break;
 	case VCL_RET_RESTART:
-		if (sp->restarts >= cache_param->max_restarts)
+		if (sp->req->restarts >= cache_param->max_restarts)
 			break;
 		if (wrk->busyobj != NULL) {
 			AN(wrk->busyobj->do_stream);
@@ -294,7 +294,7 @@ cnt_prepresp(struct sess *sp)
 			(void)HSH_Deref(wrk, NULL, &wrk->obj);
 		}
 		AZ(wrk->obj);
-		sp->restarts++;
+		sp->req->restarts++;
 		sp->director = NULL;
 		http_Setup(wrk->resp, NULL);
 		sp->step = STP_RECV;
@@ -337,7 +337,7 @@ cnt_deliver(struct sess *sp)
 
 	AZ(sp->wrk->busyobj);
 	sp->director = NULL;
-	sp->restarts = 0;
+	sp->req->restarts = 0;
 
 	RES_WriteObj(sp);
 
@@ -378,14 +378,14 @@ cnt_done(struct sess *sp)
 	AZ(wrk->obj);
 	AZ(wrk->busyobj);
 	sp->director = NULL;
-	sp->restarts = 0;
+	sp->req->restarts = 0;
 
 	wrk->busyobj = NULL;
 
 	SES_Charge(sp);
 
 	/* If we did an ESI include, don't mess up our state */
-	if (sp->esi_level > 0)
+	if (sp->req->esi_level > 0)
 		return (1);
 
 	if (sp->vcl != NULL) {
@@ -420,16 +420,16 @@ cnt_done(struct sess *sp)
 
 	sp->req_bodybytes = 0;
 
-	sp->hash_always_miss = 0;
-	sp->hash_ignore_busy = 0;
+	sp->req->hash_always_miss = 0;
+	sp->req->hash_ignore_busy = 0;
 
-	if (sp->fd >= 0 && sp->doclose != NULL) {
+	if (sp->fd >= 0 && sp->req->doclose != NULL) {
 		/*
 		 * This is an orderly close of the connection; ditch nolinger
 		 * before we close, to get queued data transmitted.
 		 */
 		// XXX: not yet (void)VTCP_linger(sp->fd, 0);
-		SES_Close(sp, sp->doclose);
+		SES_Close(sp, sp->req->doclose);
 	}
 
 	if (sp->fd < 0) {
@@ -495,7 +495,7 @@ cnt_error(struct sess *sp)
 			    cache_param->http_resp_size,
 			    (uint16_t)cache_param->http_max_hdr);
 		if (wrk->obj == NULL) {
-			sp->doclose = "Out of objects";
+			sp->req->doclose = "Out of objects";
 			sp->director = NULL;
 			http_Setup(wrk->busyobj->beresp, NULL);
 			http_Setup(wrk->busyobj->bereq, NULL);
@@ -528,23 +528,23 @@ cnt_error(struct sess *sp)
 		    http_StatusMessage(sp->err_code));
 	VCL_error_method(sp);
 
-	if (sp->handling == VCL_RET_RESTART &&
-	    sp->restarts <  cache_param->max_restarts) {
+	if (sp->req->handling == VCL_RET_RESTART &&
+	    sp->req->restarts <  cache_param->max_restarts) {
 		HSH_Drop(wrk);
 		VBO_DerefBusyObj(wrk, &wrk->busyobj);
 		sp->director = NULL;
-		sp->restarts++;
+		sp->req->restarts++;
 		sp->step = STP_RECV;
 		return (0);
-	} else if (sp->handling == VCL_RET_RESTART)
-		sp->handling = VCL_RET_DELIVER;
+	} else if (sp->req->handling == VCL_RET_RESTART)
+		sp->req->handling = VCL_RET_DELIVER;
 
 
 	/* We always close when we take this path */
-	sp->doclose = "error";
-	sp->wantbody = 1;
+	sp->req->doclose = "error";
+	sp->req->wantbody = 1;
 
-	assert(sp->handling == VCL_RET_DELIVER);
+	assert(sp->req->handling == VCL_RET_DELIVER);
 	sp->err_code = 0;
 	sp->err_reason = NULL;
 	http_Setup(wrk->busyobj->bereq, NULL);
@@ -616,7 +616,7 @@ cnt_fetch(struct sess *sp)
 	}
 
 	if (i) {
-		sp->handling = VCL_RET_ERROR;
+		sp->req->handling = VCL_RET_ERROR;
 		sp->err_code = 503;
 	} else {
 		/*
@@ -651,7 +651,7 @@ cnt_fetch(struct sess *sp)
 
 		VCL_fetch_method(sp);
 
-		switch (sp->handling) {
+		switch (sp->req->handling) {
 		case VCL_RET_HIT_FOR_PASS:
 			if (wrk->objcore != NULL)
 				wrk->objcore->flags |= OC_F_PASS;
@@ -681,9 +681,9 @@ cnt_fetch(struct sess *sp)
 	sp->director = NULL;
 	wrk->storage_hint = NULL;
 
-	switch (sp->handling) {
+	switch (sp->req->handling) {
 	case VCL_RET_RESTART:
-		sp->restarts++;
+		sp->req->restarts++;
 		sp->step = STP_RECV;
 		return (0);
 	case VCL_RET_ERROR:
@@ -732,15 +732,15 @@ cnt_fetchbody(struct sess *sp)
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
 
-	assert(sp->handling == VCL_RET_HIT_FOR_PASS ||
-	    sp->handling == VCL_RET_DELIVER);
+	assert(sp->req->handling == VCL_RET_HIT_FOR_PASS ||
+	    sp->req->handling == VCL_RET_DELIVER);
 
 	if (wrk->objcore == NULL) {
 		/* This is a pass from vcl_recv */
 		pass = 1;
 		/* VCL may have fiddled this, but that doesn't help */
 		wrk->busyobj->exp.ttl = -1.;
-	} else if (sp->handling == VCL_RET_HIT_FOR_PASS) {
+	} else if (sp->req->handling == VCL_RET_HIT_FOR_PASS) {
 		/* pass from vcl_fetch{} -> hit-for-pass */
 		/* XXX: the bereq was not filtered pass... */
 		pass = 1;
@@ -805,9 +805,9 @@ cnt_fetchbody(struct sess *sp)
 	else if (wrk->busyobj->is_gzip)
 		wrk->busyobj->vfp = &vfp_testgzip;
 
-	if (wrk->busyobj->do_esi || sp->esi_level > 0)
+	if (wrk->busyobj->do_esi || sp->req->esi_level > 0)
 		wrk->busyobj->do_stream = 0;
-	if (!sp->wantbody)
+	if (!sp->req->wantbody)
 		wrk->busyobj->do_stream = 0;
 
 	l = http_EstimateWS(wrk->busyobj->beresp,
@@ -992,11 +992,11 @@ cnt_streambody(struct sess *sp)
 		AN(wrk->obj->objcore->ban);
 		HSH_Unbusy(wrk);
 	} else {
-		sp->doclose = "Stream error";
+		sp->req->doclose = "Stream error";
 	}
 	wrk->acct_tmp.fetch++;
 	sp->director = NULL;
-	sp->restarts = 0;
+	sp->req->restarts = 0;
 
 	RES_StreamEnd(sp);
 	if (wrk->res_mode & RES_GUNZIP)
@@ -1036,8 +1036,6 @@ cnt_first(struct sess *sp)
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 
 	AZ(sp->req);
-	assert(sp->restarts == 0);
-	AZ(sp->esi_level);
 
 	VTCP_name(&sp->sockaddr, sp->sockaddrlen,
 	    sp->addr, sizeof sp->addr, sp->port, sizeof sp->port);
@@ -1098,7 +1096,7 @@ cnt_hit(struct sess *sp)
 
 	VCL_hit_method(sp);
 
-	if (sp->handling == VCL_RET_DELIVER) {
+	if (sp->req->handling == VCL_RET_DELIVER) {
 		/* Dispose of any body part of the request */
 		(void)FetchReqBody(sp);
 		//AZ(wrk->busyobj->bereq->ws);
@@ -1111,7 +1109,7 @@ cnt_hit(struct sess *sp)
 	(void)HSH_Deref(wrk, NULL, &wrk->obj);
 	wrk->objcore = NULL;
 
-	switch(sp->handling) {
+	switch(sp->req->handling) {
 	case VCL_RET_PASS:
 		sp->step = STP_PASS;
 		return (0);
@@ -1120,7 +1118,7 @@ cnt_hit(struct sess *sp)
 		return (0);
 	case VCL_RET_RESTART:
 		sp->director = NULL;
-		sp->restarts++;
+		sp->req->restarts++;
 		sp->step = STP_RECV;
 		return (0);
 	default:
@@ -1171,18 +1169,18 @@ cnt_lookup(struct sess *sp)
 	CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
 	AZ(wrk->busyobj);
 
-	if (sp->hash_objhead == NULL) {
+	if (sp->req->hash_objhead == NULL) {
 		/* Not a waiting list return */
-		AZ(sp->vary_b);
-		AZ(sp->vary_l);
-		AZ(sp->vary_e);
+		AZ(sp->req->vary_b);
+		AZ(sp->req->vary_l);
+		AZ(sp->req->vary_e);
 		(void)WS_Reserve(sp->ws, 0);
 	} else {
 		AN(sp->ws->r);
 	}
-	sp->vary_b = (void*)sp->ws->f;
-	sp->vary_e = (void*)sp->ws->r;
-	sp->vary_b[2] = '\0';
+	sp->req->vary_b = (void*)sp->ws->f;
+	sp->req->vary_e = (void*)sp->ws->r;
+	sp->req->vary_b[2] = '\0';
 
 	oc = HSH_Lookup(sp, &oh);
 
@@ -1204,17 +1202,17 @@ cnt_lookup(struct sess *sp)
 	if (oc->flags & OC_F_BUSY) {
 		wrk->stats.cache_miss++;
 
-		if (sp->vary_l != NULL) {
-			assert(oc->busyobj->vary == sp->vary_b);
+		if (sp->req->vary_l != NULL) {
+			assert(oc->busyobj->vary == sp->req->vary_b);
 			VRY_Validate(oc->busyobj->vary);
-			WS_ReleaseP(sp->ws, (void*)sp->vary_l);
+			WS_ReleaseP(sp->ws, (void*)sp->req->vary_l);
 		} else {
 			AZ(oc->busyobj->vary);
 			WS_Release(sp->ws, 0);
 		}
-		sp->vary_b = NULL;
-		sp->vary_l = NULL;
-		sp->vary_e = NULL;
+		sp->req->vary_b = NULL;
+		sp->req->vary_l = NULL;
+		sp->req->vary_e = NULL;
 
 		wrk->objcore = oc;
 		CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
@@ -1227,9 +1225,9 @@ cnt_lookup(struct sess *sp)
 	wrk->obj = o;
 
 	WS_Release(sp->ws, 0);
-	sp->vary_b = NULL;
-	sp->vary_l = NULL;
-	sp->vary_e = NULL;
+	sp->req->vary_b = NULL;
+	sp->req->vary_l = NULL;
+	sp->req->vary_e = NULL;
 
 	if (oc->flags & OC_F_PASS) {
 		wrk->stats.cache_hitpass++;
@@ -1303,7 +1301,7 @@ cnt_miss(struct sess *sp)
 
 	VCL_miss_method(sp);
 
-	switch(sp->handling) {
+	switch(sp->req->handling) {
 	case VCL_RET_ERROR:
 		AZ(HSH_Deref(wrk, wrk->objcore, NULL));
 		wrk->objcore = NULL;
@@ -1385,15 +1383,15 @@ cnt_pass(struct sess *sp)
 	wrk->first_byte_timeout = 0;
 	wrk->between_bytes_timeout = 0;
 	VCL_pass_method(sp);
-	if (sp->handling == VCL_RET_ERROR) {
+	if (sp->req->handling == VCL_RET_ERROR) {
 		http_Setup(wrk->busyobj->bereq, NULL);
 		VBO_DerefBusyObj(wrk, &wrk->busyobj);
 		sp->step = STP_ERROR;
 		return (0);
 	}
-	assert(sp->handling == VCL_RET_PASS);
+	assert(sp->req->handling == VCL_RET_PASS);
 	wrk->acct_tmp.pass++;
-	sp->sendbody = 1;
+	sp->req->sendbody = 1;
 	sp->step = STP_FETCH;
 	return (0);
 }
@@ -1443,9 +1441,9 @@ cnt_pipe(struct sess *sp)
 
 	VCL_pipe_method(sp);
 
-	if (sp->handling == VCL_RET_ERROR)
+	if (sp->req->handling == VCL_RET_ERROR)
 		INCOMPL();
-	assert(sp->handling == VCL_RET_PIPE);
+	assert(sp->req->handling == VCL_RET_PIPE);
 
 	PipeSession(sp);
 	assert(WRW_IsReleased(wrk));
@@ -1494,17 +1492,17 @@ cnt_recv(struct sess *sp)
 	sp->director = sp->vcl->director[0];
 	AN(sp->director);
 
-	sp->disable_esi = 0;
-	sp->hash_always_miss = 0;
-	sp->hash_ignore_busy = 0;
+	sp->req->disable_esi = 0;
+	sp->req->hash_always_miss = 0;
+	sp->req->hash_ignore_busy = 0;
 	sp->client_identity = NULL;
 
 	http_CollectHdr(sp->http, H_Cache_Control);
 
 	VCL_recv_method(sp);
-	recv_handling = sp->handling;
+	recv_handling = sp->req->handling;
 
-	if (sp->restarts >= cache_param->max_restarts) {
+	if (sp->req->restarts >= cache_param->max_restarts) {
 		if (sp->err_code == 0)
 			sp->err_code = 503;
 		sp->step = STP_ERROR;
@@ -1525,22 +1523,22 @@ cnt_recv(struct sess *sp)
 
 	SHA256_Init(wrk->sha256ctx);
 	VCL_hash_method(sp);
-	assert(sp->handling == VCL_RET_HASH);
-	SHA256_Final(sp->digest, wrk->sha256ctx);
+	assert(sp->req->handling == VCL_RET_HASH);
+	SHA256_Final(sp->req->digest, wrk->sha256ctx);
 
 	if (!strcmp(sp->http->hd[HTTP_HDR_REQ].b, "HEAD"))
-		sp->wantbody = 0;
+		sp->req->wantbody = 0;
 	else
-		sp->wantbody = 1;
+		sp->req->wantbody = 1;
 
-	sp->sendbody = 0;
+	sp->req->sendbody = 0;
 	switch(recv_handling) {
 	case VCL_RET_LOOKUP:
 		/* XXX: discard req body, if any */
 		sp->step = STP_LOOKUP;
 		return (0);
 	case VCL_RET_PIPE:
-		if (sp->esi_level > 0) {
+		if (sp->req->esi_level > 0) {
 			/* XXX: VSL something */
 			INCOMPL();
 			/* sp->step = STP_DONE; */
@@ -1584,10 +1582,11 @@ cnt_start(struct sess *sp)
 	wrk = sp->wrk;
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(sp->req, REQ_MAGIC);
-	AZ(sp->restarts);
+	AZ(sp->req->restarts);
 	AZ(wrk->obj);
 	AZ(sp->vcl);
-	AZ(sp->esi_level);
+	EXP_Clr(&sp->req->exp);
+	AZ(sp->req->esi_level);
 
 	/* Update stats of various sorts */
 	wrk->stats.client_req++;
@@ -1625,7 +1624,7 @@ cnt_start(struct sess *sp)
 		return (0);
 	}
 
-	sp->doclose = http_DoConnection(sp->http);
+	sp->req->doclose = http_DoConnection(sp->http);
 
 	/* XXX: Handle TRACE & OPTIONS of Max-Forwards = 0 */
 
diff --git a/bin/varnishd/cache/cache_dir_random.c b/bin/varnishd/cache/cache_dir_random.c
index d6570ed..28a079c 100644
--- a/bin/varnishd/cache/cache_dir_random.c
+++ b/bin/varnishd/cache/cache_dir_random.c
@@ -112,8 +112,8 @@ vdi_random_init_seed(const struct vdi_random *vs, const struct sess *sp)
 		retval = vdi_random_sha(p, strlen(p));
 		break;
 	case c_hash:
-		AN(sp->digest);
-		retval = scalbn(vle32dec(sp->digest), -32);
+		AN(sp->req->digest);
+		retval = scalbn(vle32dec(sp->req->digest), -32);
 		break;
 	case c_random:
 	default:
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index fb0771d..36ff704 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -52,9 +52,9 @@ ved_include(struct sess *sp, const char *src, const char *host)
 
 	w = sp->wrk;
 
-	if (sp->esi_level >= cache_param->max_esi_depth)
+	if (sp->req->esi_level >= cache_param->max_esi_depth)
 		return;
-	sp->esi_level++;
+	sp->req->esi_level++;
 
 	(void)WRW_FlushRelease(w);
 
@@ -105,7 +105,7 @@ ved_include(struct sess *sp, const char *src, const char *host)
 	sp->req->xid = sxid;
 	AN(sp->wrk);
 	assert(sp->step == STP_DONE);
-	sp->esi_level--;
+	sp->req->esi_level--;
 	sp->wrk->obj = obj;
 	sp->wrk->res_mode = res_mode;
 
@@ -247,7 +247,7 @@ ESI_Deliver(struct sess *sp)
 		isgzip = 0;
 	}
 
-	if (sp->esi_level == 0) {
+	if (sp->req->esi_level == 0) {
 		/*
 		 * Only the top level document gets to decide this.
 		 */
@@ -403,7 +403,7 @@ ESI_Deliver(struct sess *sp)
 			(void)WRW_Write(sp->wrk, obuf, obufl);
 		(void)VGZ_Destroy(&vgz, sp->vsl_id);
 	}
-	if (sp->wrk->gzip_resp && sp->esi_level == 0) {
+	if (sp->wrk->gzip_resp && sp->req->esi_level == 0) {
 		/* Emit a gzip literal block with finish bit set */
 		tailbuf[0] = 0x01;
 		tailbuf[1] = 0x00;
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index 761a62e..e93a1aa 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -116,8 +116,8 @@ EXP_Keep(const struct sess *sp, const struct object *o)
 	r = (double)cache_param->default_keep;
 	if (o->exp.keep > 0.)
 		r = o->exp.keep;
-	if (sp != NULL && sp->exp.keep > 0. && sp->exp.keep < r)
-		r = sp->exp.keep;
+	if (sp != NULL && sp->req->exp.keep > 0. && sp->req->exp.keep < r)
+		r = sp->req->exp.keep;
 	return (EXP_Ttl(sp, o) + r);
 }
 
@@ -129,8 +129,8 @@ EXP_Grace(const struct sess *sp, const struct object *o)
 	r = (double)cache_param->default_grace;
 	if (o->exp.grace >= 0.)
 		r = o->exp.grace;
-	if (sp != NULL && sp->exp.grace > 0. && sp->exp.grace < r)
-		r = sp->exp.grace;
+	if (sp != NULL && sp->req->exp.grace > 0. && sp->req->exp.grace < r)
+		r = sp->req->exp.grace;
 	return (EXP_Ttl(sp, o) + r);
 }
 
@@ -140,8 +140,8 @@ EXP_Ttl(const struct sess *sp, const struct object *o)
 	double r;
 
 	r = o->exp.ttl;
-	if (sp != NULL && sp->exp.ttl > 0. && sp->exp.ttl < r)
-		r = sp->exp.ttl;
+	if (sp != NULL && sp->req->exp.ttl > 0. && sp->req->exp.ttl < r)
+		r = sp->req->exp.ttl;
 	return (o->exp.entered + r);
 }
 
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 936dc30..79d0665 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -349,7 +349,7 @@ FetchReqBody(struct sess *sp)
 			if (rdcnt <= 0)
 				return (1);
 			content_length -= rdcnt;
-			if (!sp->sendbody)
+			if (!sp->req->sendbody)
 				continue;
 			(void)WRW_Write(sp->wrk, buf, rdcnt); /* XXX: stats ? */
 			if (WRW_Flush(sp->wrk))
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index 6f6a85f..627db48 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -262,7 +262,7 @@ HSH_Insert(const struct sess *sp)
 	if (cache_param->diag_bitmap & 0x80000000)
 		hsh_testmagic(sp->wrk->nobjhead->digest);
 
-	AZ(sp->hash_objhead);
+	AZ(sp->req);
 	AN(wrk->nobjhead);
 	oh = hash->lookup(sp, wrk->nobjhead);
 	CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
@@ -307,18 +307,18 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
 	wrk = sp->wrk;
 
 	HSH_Prealloc(sp);
-	memcpy(sp->wrk->nobjhead->digest, sp->digest, sizeof sp->digest);
+	memcpy(sp->wrk->nobjhead->digest, sp->req->digest, sizeof sp->req->digest);
 	if (cache_param->diag_bitmap & 0x80000000)
 		hsh_testmagic(sp->wrk->nobjhead->digest);
 
-	if (sp->hash_objhead != NULL) {
+	if (sp->req->hash_objhead != NULL) {
 		/*
 		 * This sess came off the waiting list, and brings a
 		 * oh refcnt with it.
 		 */
-		CHECK_OBJ_NOTNULL(sp->hash_objhead, OBJHEAD_MAGIC);
-		oh = sp->hash_objhead;
-		sp->hash_objhead = NULL;
+		CHECK_OBJ_NOTNULL(sp->req->hash_objhead, OBJHEAD_MAGIC);
+		oh = sp->req->hash_objhead;
+		sp->req->hash_objhead = NULL;
 	} else {
 		AN(wrk->nobjhead);
 		oh = hash->lookup(sp, wrk->nobjhead);
@@ -340,7 +340,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
 
 		if (oc->flags & OC_F_BUSY) {
 			CHECK_OBJ_NOTNULL(oc->busyobj, BUSYOBJ_MAGIC);
-			if (sp->hash_ignore_busy)
+			if (sp->req->hash_ignore_busy)
 				continue;
 
 			if (oc->busyobj->vary != NULL &&
@@ -401,7 +401,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
 	}
 	sp->wrk->objcore = NULL;
 
-	if (oc != NULL && !sp->hash_always_miss) {
+	if (oc != NULL && !sp->req->hash_always_miss) {
 		o = oc_getobj(sp->wrk, oc);
 		CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 		assert(oc->objhead == oh);
@@ -419,7 +419,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
 
 	if (busy_oc != NULL) {
 		/* There are one or more busy objects, wait for them */
-		if (sp->esi_level == 0) {
+		if (sp->req->esi_level == 0) {
 			CHECK_OBJ_NOTNULL(sp->wrk->nwaitinglist,
 			    WAITINGLIST_MAGIC);
 			if (oh->waitinglist == NULL) {
@@ -437,7 +437,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
 		 * back when the sess comes off the waiting list and
 		 * calls us again
 		 */
-		sp->hash_objhead = oh;
+		sp->req->hash_objhead = oh;
 		sp->wrk = NULL;
 		Lck_Unlock(&oh->mtx);
 		return (NULL);
@@ -452,9 +452,9 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
 	AZ(wrk->busyobj);
 	wrk->busyobj = VBO_GetBusyObj(wrk);
 
-	VRY_Validate(sp->vary_b);
-	if (sp->vary_l != NULL)
-		wrk->busyobj->vary = sp->vary_b;
+	VRY_Validate(sp->req->vary_b);
+	if (sp->req->vary_l != NULL)
+		wrk->busyobj->vary = sp->req->vary_b;
 	else
 		wrk->busyobj->vary = NULL;
 	oc->busyobj = wrk->busyobj;
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 238c597..44c8fc3 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -245,7 +245,7 @@ pan_sess(const struct sess *sp)
 #undef STEP
 		default: stp = NULL;
 	}
-	hand = VCL_Return_Name(sp->handling);
+	hand = VCL_Return_Name(sp->req->handling);
 	if (stp != NULL)
 		VSB_printf(pan_vsp, "  step = %s,\n", stp);
 	else
@@ -253,14 +253,14 @@ pan_sess(const struct sess *sp)
 	if (hand != NULL)
 		VSB_printf(pan_vsp, "  handling = %s,\n", hand);
 	else
-		VSB_printf(pan_vsp, "  handling = 0x%x,\n", sp->handling);
+		VSB_printf(pan_vsp, "  handling = 0x%x,\n", sp->req->handling);
 	if (sp->err_code)
 		VSB_printf(pan_vsp,
 		    "  err_code = %d, err_reason = %s,\n", sp->err_code,
 		    sp->err_reason ? sp->err_reason : "(null)");
 
 	VSB_printf(pan_vsp, "  restarts = %d, esi_level = %d\n",
-	    sp->restarts, sp->esi_level);
+	    sp->req->restarts, sp->req->esi_level);
 
 	if (sp->wrk->busyobj != NULL)
 		pan_busyobj(sp->wrk->busyobj);
diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c
index cbddb7d..e5dbf86 100644
--- a/bin/varnishd/cache/cache_response.c
+++ b/bin/varnishd/cache/cache_response.c
@@ -142,7 +142,7 @@ RES_BuildHttp(const struct sess *sp)
 	    sp->wrk->obj->exp.age + sp->t_resp - sp->wrk->obj->exp.entered);
 	http_SetHeader(sp->wrk, sp->vsl_id, sp->wrk->resp, "Via: 1.1 varnish");
 	http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->resp, "Connection: %s",
-	    sp->doclose ? "close" : "keep-alive");
+	    sp->req->doclose ? "close" : "keep-alive");
 }
 
 /*--------------------------------------------------------------------
@@ -261,7 +261,7 @@ RES_WriteObj(struct sess *sp)
 	if (sp->wrk->obj->response == 200 &&
 	    sp->http->conds &&
 	    RFC2616_Do_Cond(sp)) {
-		sp->wantbody = 0;
+		sp->req->wantbody = 0;
 		http_SetResp(sp->wrk->resp, "HTTP/1.1", 304, "Not Modified");
 		http_Unset(sp->wrk->resp, H_Content_Length);
 		http_Unset(sp->wrk->resp, H_Transfer_Encoding);
@@ -273,7 +273,7 @@ RES_WriteObj(struct sess *sp)
 	low = 0;
 	high = sp->wrk->obj->len - 1;
 	if (
-	    sp->wantbody &&
+	    sp->req->wantbody &&
 	    (sp->wrk->res_mode & RES_LEN) &&
 	    !(sp->wrk->res_mode & (RES_ESI|RES_ESI_CHILD|RES_GUNZIP)) &&
 	    cache_param->http_range_support &&
@@ -294,13 +294,13 @@ RES_WriteObj(struct sess *sp)
 		sp->wrk->acct_tmp.hdrbytes +=
 		    http_Write(sp->wrk, sp->vsl_id, sp->wrk->resp, 1);
 
-	if (!sp->wantbody)
+	if (!sp->req->wantbody)
 		sp->wrk->res_mode &= ~RES_CHUNKED;
 
 	if (sp->wrk->res_mode & RES_CHUNKED)
 		WRW_Chunked(sp->wrk);
 
-	if (!sp->wantbody) {
+	if (!sp->req->wantbody) {
 		/* This was a HEAD or conditional request */
 	} else if (sp->wrk->obj->len == 0) {
 		/* Nothing to do here */
@@ -336,7 +336,7 @@ RES_StreamStart(struct sess *sp)
 	CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC);
 
 	AZ(sp->wrk->res_mode & RES_ESI_CHILD);
-	AN(sp->wantbody);
+	AN(sp->req->wantbody);
 
 	WRW_Reserve(sp->wrk, &sp->fd);
 	/*
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 530c96e..f1f502a 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -171,7 +171,6 @@ ses_setup(struct sessmem *sm)
 	sp->t_idle = NAN;
 	sp->t_req = NAN;
 	sp->t_resp = NAN;
-	EXP_Clr(&sp->exp);
 
 	WS_Init(sp->ws, "sess", sm->wsp, sm->workspace);
 	sp->http = sm->http[0];
diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c
index f55607b..562f6df 100644
--- a/bin/varnishd/cache/cache_vary.c
+++ b/bin/varnishd/cache/cache_vary.c
@@ -176,7 +176,7 @@ vry_cmp(const uint8_t * const *v1, uint8_t * const *v2)
 int
 VRY_Match(struct sess *sp, const uint8_t *vary)
 {
-	uint8_t *vsp = sp->vary_b;
+	uint8_t *vsp = sp->req->vary_b;
 	char *h, *e;
 	unsigned lh, ln;
 	int i, retval = 1, oflo = 0;
@@ -202,8 +202,8 @@ VRY_Match(struct sess *sp, const uint8_t *vary)
 
 			/* Length of the entire new vary entry */
 			ln = 2 + vary[2] + 2 + (lh == 0xffff ? 0 : lh);
-			if (vsp + ln >= sp->vary_e) {
-				vsp = sp->vary_b;
+			if (vsp + ln >= sp->req->vary_e) {
+				vsp = sp->req->vary_b;
 				oflo = 1;
 			}
 
@@ -211,7 +211,7 @@ VRY_Match(struct sess *sp, const uint8_t *vary)
 			 * We MUST have space for one entry and the end marker
 			 * after it, which prevents old junk from confusing us
 			 */
-			assert(vsp + ln + 2 < sp->vary_e);
+			assert(vsp + ln + 2 < sp->req->vary_e);
 
 			vbe16enc(vsp, (uint16_t)lh);
 			memcpy(vsp + 2, vary + 2, vary[2] + 2);
@@ -229,20 +229,20 @@ VRY_Match(struct sess *sp, const uint8_t *vary)
 		vsp += vry_len(vsp);
 		vary += vry_len(vary);
 	}
-	if (vsp + 3 > sp->vary_e)
+	if (vsp + 3 > sp->req->vary_e)
 		oflo = 1;
 
 	if (oflo) {
 		/* XXX: Should log this */
-		vsp = sp->vary_b;
+		vsp = sp->req->vary_b;
 	}
 	vsp[0] = 0xff;
 	vsp[1] = 0xff;
 	vsp[2] = 0;
 	if (oflo)
-		sp->vary_l = NULL;
+		sp->req->vary_l = NULL;
 	else
-		sp->vary_l = vsp + 3;
+		sp->req->vary_l = vsp + 3;
 	return (retval);
 }
 
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 068b482..06d4bd7 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -333,14 +333,14 @@ void									\
 VCL_##func##_method(struct sess *sp)					\
 {									\
 									\
-	sp->handling = 0;						\
-	sp->cur_method = VCL_MET_ ## upper;				\
+	sp->req->handling = 0;						\
+	sp->req->cur_method = VCL_MET_ ## upper;				\
 	WSP(sp, SLT_VCL_call, "%s", #func);				\
 	(void)sp->vcl->func##_func(sp);					\
-	WSP(sp, SLT_VCL_return, "%s", VCL_Return_Name(sp->handling));	\
-	sp->cur_method = 0;						\
-	assert((1U << sp->handling) & bitmap);				\
-	assert(!((1U << sp->handling) & ~bitmap));			\
+	WSP(sp, SLT_VCL_return, "%s", VCL_Return_Name(sp->req->handling));	\
+	sp->req->cur_method = 0;						\
+	assert((1U << sp->req->handling) & bitmap);				\
+	assert(!((1U << sp->req->handling) & ~bitmap));			\
 }
 
 #include "tbl/vcl_returns.h"
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index a696f64..9ec88cc 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -248,7 +248,7 @@ VRT_handling(struct sess *sp, unsigned hand)
 	}
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	assert(hand < VCL_RET_MAX);
-	sp->handling = hand;
+	sp->req->handling = hand;
 }
 
 /*--------------------------------------------------------------------
@@ -510,9 +510,9 @@ VRT_ban_string(struct sess *sp, const char *str)
 void
 VRT_purge(const struct sess *sp, double ttl, double grace)
 {
-	if (sp->cur_method == VCL_MET_HIT)
+	if (sp->req->cur_method == VCL_MET_HIT)
 		HSH_Purge(sp, sp->wrk->obj->objcore->objhead, ttl, grace);
-	else if (sp->cur_method == VCL_MET_MISS)
+	else if (sp->req->cur_method == VCL_MET_MISS)
 		HSH_Purge(sp, sp->wrk->objcore->objhead, ttl, grace);
 }
 
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 6f5544b..8c95d5b 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -327,15 +327,15 @@ VRT_l_req_esi(struct sess *sp, unsigned process_esi)
 	 * Only allow you to turn of esi in the main request
 	 * else everything gets confused
 	 */
-	if(sp->esi_level == 0)
-		sp->disable_esi = !process_esi;
+	if(sp->req->esi_level == 0)
+		sp->req->disable_esi = !process_esi;
 }
 
 unsigned __match_proto__()
 VRT_r_req_esi(struct sess *sp)
 {
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	return (!sp->disable_esi);
+	return (!sp->req->disable_esi);
 }
 
 int
@@ -343,7 +343,7 @@ VRT_r_req_esi_level(const struct sess *sp)
 {
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	return(sp->esi_level);
+	return(sp->req->esi_level);
 }
 
 /*--------------------------------------------------------------------*/
@@ -364,7 +364,7 @@ VRT_r_req_restarts(const struct sess *sp)
 {
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	return (sp->restarts);
+	return (sp->req->restarts);
 }
 
 /*--------------------------------------------------------------------
@@ -401,9 +401,9 @@ vrt_wsp_exp(const struct sess *sp, unsigned xid, const struct exp *e)
 	    sp->t_req, e->age + (sp->t_req - e->entered));
 }
 
-VRT_DO_EXP(req, sp->exp, ttl, 0, )
-VRT_DO_EXP(req, sp->exp, grace, 0, )
-VRT_DO_EXP(req, sp->exp, keep, 0, )
+VRT_DO_EXP(req, sp->req->exp, ttl, 0, )
+VRT_DO_EXP(req, sp->req->exp, grace, 0, )
+VRT_DO_EXP(req, sp->req->exp, keep, 0, )
 
 VRT_DO_EXP(obj, sp->wrk->obj->exp, grace, 0,
    EXP_Rearm(sp->wrk->obj);
@@ -447,7 +447,7 @@ VRT_l_req_##hash_var(struct sess *sp, unsigned val)		\
 {								\
 								\
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);			\
-	sp->hash_var = val ? 1 : 0;				\
+	sp->req->hash_var = val ? 1 : 0;				\
 }								\
 								\
 unsigned __match_proto__()					\
@@ -455,7 +455,7 @@ VRT_r_req_##hash_var(struct sess *sp)				\
 {								\
 								\
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);			\
-	return(sp->hash_var);					\
+	return(sp->req->hash_var);					\
 }
 
 REQ_BOOL(hash_ignore_busy)



More information about the varnish-commit mailing list