[master] 45202f7 This is an interim snapshot committed mostly for debugging purposes, do not run in production!

Poul-Henning Kamp phk at varnish-cache.org
Sun Dec 25 11:09:37 CET 2011


commit 45202f7f39093f95a21e7efbb90c95c1eda96d33
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sun Dec 25 10:07:31 2011 +0000

    This is an interim snapshot committed mostly for debugging purposes,
    do not run in production!
    
    Allocate the workspace as part of struct req, and move sp->ws,
    sp->http and sp->http0 to struct req.
    
    Allocate the req->http[0] on the workspace, so that changes to
    nhttp does not force us to dump the mempool.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 7517d1c..d1dc4fb 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -619,6 +619,11 @@ struct req {
 	struct http_conn	htc[1];
 	char			*client_identity;
 
+	/* HTTP request */
+	struct http		*http;
+	struct http		*http0;
+
+	struct ws		ws[1];
 };
 
 /*--------------------------------------------------------------------*/
@@ -664,11 +669,6 @@ struct sess {
 
 	/* Request related fields ------------------------------------*/
 
-	/* HTTP request */
-	struct http		*http;
-	struct http		*http0;
-
-	struct ws		ws[1];
 
 	/* Timestamps, all on TIM_real() timescale */
 	double			t_req;
diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index 2badb76..9162f50 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -675,6 +675,7 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req)
 	struct objcore *oc;
 	struct ban * volatile b0;
 	unsigned tests, skipped;
+	struct http *http;
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
@@ -688,6 +689,11 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req)
 	if (b0 == oc->ban)
 		return (0);
 
+	if (has_req)
+		http = sp->req->http;
+	else
+		http = NULL;
+
 	/*
 	 * This loop is safe without locks, because we know we hold
 	 * a refcount on a ban somewhere in the list and we do not
@@ -711,7 +717,7 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req)
 			 * be other bans that match, so we soldier on
 			 */
 			skipped++;
-		} else if (ban_evaluate(b->spec, o->http, sp->http, &tests))
+		} else if (ban_evaluate(b->spec, o->http, http, &tests))
 			break;
 	}
 
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 5816119..6bf3f6a 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -109,7 +109,7 @@ cnt_wait(struct sess *sp)
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	if (sp->req == NULL) {
 		SES_GetReq(sp);
-		HTC_Init(sp->req->htc, sp->ws, sp->fd, sp->vsl_id,
+		HTC_Init(sp->req->htc, sp->req->ws, sp->fd, sp->vsl_id,
 		    cache_param->http_req_size,
 		    cache_param->http_req_hdr_len);
 	}
@@ -160,8 +160,6 @@ cnt_wait(struct sess *sp)
 				wrk->stats.sess_herd++;
 				SES_Charge(sp);
 				SES_ReleaseReq(sp);
-				WS_Release(sp->ws, 0);
-				WS_Reset(sp->ws, NULL);
 				WAIT_Enter(sp);
 				return (1);
 			}
@@ -267,7 +265,7 @@ cnt_prepresp(struct sess *sp)
 			wrk->res_mode |= RES_LEN;
 		else if (!sp->req->wantbody) {
 			/* Nothing */
-		} else if (sp->http->protover >= 11) {
+		} else if (sp->req->http->protover >= 11) {
 			wrk->res_mode |= RES_CHUNKED;
 		} else {
 			wrk->res_mode |= RES_EOF;
@@ -448,7 +446,7 @@ cnt_done(struct sess *sp)
 	if (wrk->stats.client_req >= cache_param->wthread_stats_rate)
 		WRK_SumStat(wrk);
 	/* Reset the workspace to the session-watermark */
-	WS_Reset(sp->ws, NULL);
+	WS_Reset(sp->req->ws, NULL);
 	WS_Reset(wrk->ws, NULL);
 
 	i = HTC_Reinit(sp->req->htc);
@@ -903,7 +901,7 @@ cnt_fetchbody(struct sess *sp)
 	 * that allow the 304, in which case we return 200 non-stream.
 	 */
 	if (wrk->obj->response == 200 &&
-	    sp->http->conds &&
+	    sp->req->http->conds &&
 	    RFC2616_Do_Cond(sp))
 		wrk->busyobj->do_stream = 0;
 
@@ -1177,12 +1175,12 @@ cnt_lookup(struct sess *sp)
 		AZ(sp->req->vary_b);
 		AZ(sp->req->vary_l);
 		AZ(sp->req->vary_e);
-		(void)WS_Reserve(sp->ws, 0);
+		(void)WS_Reserve(sp->req->ws, 0);
 	} else {
-		AN(sp->ws->r);
+		AN(sp->req->ws->r);
 	}
-	sp->req->vary_b = (void*)sp->ws->f;
-	sp->req->vary_e = (void*)sp->ws->r;
+	sp->req->vary_b = (void*)sp->req->ws->f;
+	sp->req->vary_e = (void*)sp->req->ws->r;
 	sp->req->vary_b[2] = '\0';
 
 	oc = HSH_Lookup(sp, &oh);
@@ -1208,10 +1206,10 @@ cnt_lookup(struct sess *sp)
 		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->req->vary_l);
+			WS_ReleaseP(sp->req->ws, (void*)sp->req->vary_l);
 		} else {
 			AZ(oc->busyobj->vary);
-			WS_Release(sp->ws, 0);
+			WS_Release(sp->req->ws, 0);
 		}
 		sp->req->vary_b = NULL;
 		sp->req->vary_l = NULL;
@@ -1227,7 +1225,7 @@ cnt_lookup(struct sess *sp)
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 	wrk->obj = o;
 
-	WS_Release(sp->ws, 0);
+	WS_Release(sp->req->ws, 0);
 	sp->req->vary_b = NULL;
 	sp->req->vary_l = NULL;
 	sp->req->vary_e = NULL;
@@ -1500,7 +1498,7 @@ cnt_recv(struct sess *sp)
 	sp->req->hash_ignore_busy = 0;
 	sp->req->client_identity = NULL;
 
-	http_CollectHdr(sp->http, H_Cache_Control);
+	http_CollectHdr(sp->req->http, H_Cache_Control);
 
 	VCL_recv_method(sp);
 	recv_handling = sp->req->handling;
@@ -1516,11 +1514,11 @@ cnt_recv(struct sess *sp)
 	     (recv_handling != VCL_RET_PIPE) &&
 	     (recv_handling != VCL_RET_PASS)) {
 		if (RFC2616_Req_Gzip(sp)) {
-			http_Unset(sp->http, H_Accept_Encoding);
-			http_SetHeader(wrk, sp->vsl_id, sp->http,
+			http_Unset(sp->req->http, H_Accept_Encoding);
+			http_SetHeader(wrk, sp->vsl_id, sp->req->http,
 			    "Accept-Encoding: gzip");
 		} else {
-			http_Unset(sp->http, H_Accept_Encoding);
+			http_Unset(sp->req->http, H_Accept_Encoding);
 		}
 	}
 
@@ -1529,7 +1527,7 @@ cnt_recv(struct sess *sp)
 	assert(sp->req->handling == VCL_RET_HASH);
 	SHA256_Final(sp->req->digest, wrk->sha256ctx);
 
-	if (!strcmp(sp->http->hd[HTTP_HDR_REQ].b, "HEAD"))
+	if (!strcmp(sp->req->http->hd[HTTP_HDR_REQ].b, "HEAD"))
 		sp->req->wantbody = 0;
 	else
 		sp->req->wantbody = 1;
@@ -1605,7 +1603,7 @@ cnt_start(struct sess *sp)
 	sp->req->vcl = wrk->vcl;
 	wrk->vcl = NULL;
 
-	http_Setup(sp->http, sp->ws);
+	http_Setup(sp->req->http, sp->req->ws);
 	done = http_DissectRequest(sp);
 
 	/* If we could not even parse the request, just close */
@@ -1616,10 +1614,10 @@ cnt_start(struct sess *sp)
 	}
 
 	/* Catch request snapshot */
-	sp->req->ws_req = WS_Snapshot(sp->ws);
+	sp->req->ws_req = WS_Snapshot(sp->req->ws);
 
 	/* Catch original request, before modification */
-	HTTP_Copy(sp->http0, sp->http);
+	HTTP_Copy(sp->req->http0, sp->req->http);
 
 	if (done != 0) {
 		sp->req->err_code = done;
@@ -1627,14 +1625,14 @@ cnt_start(struct sess *sp)
 		return (0);
 	}
 
-	sp->req->doclose = http_DoConnection(sp->http);
+	sp->req->doclose = http_DoConnection(sp->req->http);
 
 	/* XXX: Handle TRACE & OPTIONS of Max-Forwards = 0 */
 
 	/*
 	 * Handle Expect headers
 	 */
-	if (http_GetHdr(sp->http, H_Expect, &p)) {
+	if (http_GetHdr(sp->req->http, H_Expect, &p)) {
 		if (strcasecmp(p, "100-continue")) {
 			sp->req->err_code = 417;
 			sp->step = STP_ERROR;
@@ -1647,7 +1645,7 @@ cnt_start(struct sess *sp)
 		 * XXX: because we use http0 as our basis.  Believed
 		 * XXX: safe, but potentially confusing.
 		 */
-		http_Unset(sp->http, H_Expect);
+		http_Unset(sp->req->http, H_Expect);
 	}
 
 	sp->step = STP_RECV;
diff --git a/bin/varnishd/cache/cache_dir_dns.c b/bin/varnishd/cache/cache_dir_dns.c
index 517caaa..80310b9 100644
--- a/bin/varnishd/cache/cache_dir_dns.c
+++ b/bin/varnishd/cache/cache_dir_dns.c
@@ -350,7 +350,7 @@ vdi_dns_find_backend(const struct sess *sp, struct vdi_dns *vs)
 	if (sp->wrk->busyobj != NULL && sp->wrk->busyobj->bereq)
 		hp = sp->wrk->busyobj->bereq;
 	else
-		hp = sp->http;
+		hp = sp->req->http;
 
 
 	CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index e1d3945..be8d185 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -63,17 +63,17 @@ ved_include(struct sess *sp, const char *src, const char *host)
 	res_mode = sp->wrk->res_mode;
 
 	/* Reset request to status before we started messing with it */
-	HTTP_Copy(sp->http, sp->http0);
+	HTTP_Copy(sp->req->http, sp->req->http0);
 
 	/* Take a workspace snapshot */
-	sp_ws_wm = WS_Snapshot(sp->ws);
+	sp_ws_wm = WS_Snapshot(sp->req->ws);
 	wrk_ws_wm = WS_Snapshot(w->ws);
 
-	http_SetH(sp->http, HTTP_HDR_URL, src);
+	http_SetH(sp->req->http, HTTP_HDR_URL, src);
 	if (host != NULL && *host != '\0')  {
-		http_Unset(sp->http, H_Host);
-		http_Unset(sp->http, H_If_Modified_Since);
-		http_SetHeader(w, sp->vsl_id, sp->http, host);
+		http_Unset(sp->req->http, H_Host);
+		http_Unset(sp->req->http, H_If_Modified_Since);
+		http_SetHeader(w, sp->vsl_id, sp->req->http, host);
 	}
 	/*
 	 * XXX: We should decide if we should cache the director
@@ -82,14 +82,14 @@ ved_include(struct sess *sp, const char *src, const char *host)
 	 */
 	sp->req->director = NULL;
 	sp->step = STP_RECV;
-	http_ForceGet(sp->http);
+	http_ForceGet(sp->req->http);
 
 	/* Don't do conditionals */
-	sp->http->conds = 0;
-	http_Unset(sp->http, H_If_Modified_Since);
+	sp->req->http->conds = 0;
+	http_Unset(sp->req->http, H_If_Modified_Since);
 
 	/* Client content already taken care of */
-	http_Unset(sp->http, H_Content_Length);
+	http_Unset(sp->req->http, H_Content_Length);
 
 	sxid = sp->req->xid;
 	while (1) {
@@ -110,7 +110,7 @@ ved_include(struct sess *sp, const char *src, const char *host)
 	sp->wrk->res_mode = res_mode;
 
 	/* Reset the workspace */
-	WS_Reset(sp->ws, sp_ws_wm);
+	WS_Reset(sp->req->ws, sp_ws_wm);
 	WS_Reset(w->ws, wrk_ws_wm);
 
 	WRW_Reserve(sp->wrk, &sp->fd);
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index dbf30e6..1e75f64 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -336,7 +336,7 @@ FetchReqBody(struct sess *sp)
 	char *ptr, *endp;
 	int rdcnt;
 
-	if (http_GetHdr(sp->http, H_Content_Length, &ptr)) {
+	if (http_GetHdr(sp->req->http, H_Content_Length, &ptr)) {
 
 		content_length = strtoul(ptr, &endp, 10);
 		/* XXX should check result of conversion */
@@ -356,7 +356,7 @@ FetchReqBody(struct sess *sp)
 				return (2);
 		}
 	}
-	if (http_GetHdr(sp->http, H_Transfer_Encoding, NULL)) {
+	if (http_GetHdr(sp->req->http, H_Transfer_Encoding, NULL)) {
 		/* XXX: Handle chunked encoding. */
 		WSP(sp, SLT_Debug, "Transfer-Encoding in request");
 		return (1);
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index dbcca41..5d8c880 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -301,7 +301,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->http, HTTP_MAGIC);
+	CHECK_OBJ_NOTNULL(sp->req->http, HTTP_MAGIC);
 	AN(sp->req->director);
 	AN(hash);
 	wrk = sp->wrk;
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index 93bd896..f7dad38 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -660,7 +660,7 @@ http_DissectRequest(struct sess *sp)
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	htc = sp->req->htc;
 	CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
-	hp = sp->http;
+	hp = sp->req->http;
 	CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
 
 	hp->logtag = HTTP_Rx;
@@ -873,13 +873,13 @@ http_FilterHeader(const struct sess *sp, unsigned how)
 	CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
 	hp->logtag = HTTP_Tx;
 
-	http_copyh(hp, sp->http, HTTP_HDR_REQ);
-	http_copyh(hp, sp->http, HTTP_HDR_URL);
+	http_copyh(hp, sp->req->http, HTTP_HDR_REQ);
+	http_copyh(hp, sp->req->http, HTTP_HDR_URL);
 	if (how == HTTPH_R_FETCH)
 		http_SetH(hp, HTTP_HDR_PROTO, "HTTP/1.1");
 	else
-		http_copyh(hp, sp->http, HTTP_HDR_PROTO);
-	http_FilterFields(sp->wrk, sp->vsl_id, hp, sp->http, how);
+		http_copyh(hp, sp->req->http, HTTP_HDR_PROTO);
+	http_FilterFields(sp->wrk, sp->vsl_id, hp, sp->req->http, how);
 	http_PrintfHeader(sp->wrk, sp->vsl_id, hp, "X-Varnish: %u", sp->req->xid);
 }
 
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 9710517..a35c258 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -265,8 +265,8 @@ pan_sess(const struct sess *sp)
 	if (sp->wrk->busyobj != NULL)
 		pan_busyobj(sp->wrk->busyobj);
 
-	pan_ws(sp->ws, 2);
-	pan_http("req", sp->http, 2);
+	pan_ws(sp->req->ws, 2);
+	pan_http("req", sp->req->http, 2);
 
 	if (sp->wrk != NULL)
 		pan_wrk(sp->wrk);
diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c
index fe5f29f..6b2ea78 100644
--- a/bin/varnishd/cache/cache_response.c
+++ b/bin/varnishd/cache/cache_response.c
@@ -259,7 +259,7 @@ RES_WriteObj(struct sess *sp)
 	WRW_Reserve(sp->wrk, &sp->fd);
 
 	if (sp->wrk->obj->response == 200 &&
-	    sp->http->conds &&
+	    sp->req->http->conds &&
 	    RFC2616_Do_Cond(sp)) {
 		sp->req->wantbody = 0;
 		http_SetResp(sp->wrk->resp, "HTTP/1.1", 304, "Not Modified");
@@ -278,7 +278,7 @@ RES_WriteObj(struct sess *sp)
 	    !(sp->wrk->res_mode & (RES_ESI|RES_ESI_CHILD|RES_GUNZIP)) &&
 	    cache_param->http_range_support &&
 	    sp->wrk->obj->response == 200 &&
-	    http_GetHdr(sp->http, H_Range, &r))
+	    http_GetHdr(sp->req->http, H_Range, &r))
 		res_dorange(sp, r, &low, &high);
 
 	/*
diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c
index 5c5e5e2..04641ca 100644
--- a/bin/varnishd/cache/cache_rfc2616.c
+++ b/bin/varnishd/cache/cache_rfc2616.c
@@ -291,7 +291,7 @@ RFC2616_Req_Gzip(const struct sess *sp)
 	 * p104 says to not do q values for x-gzip, so we just test
 	 * for its existence.
 	 */
-	if (http_GetHdrData(sp->http, H_Accept_Encoding, "x-gzip", NULL))
+	if (http_GetHdrData(sp->req->http, H_Accept_Encoding, "x-gzip", NULL))
 		return (1);
 
 	/*
@@ -299,7 +299,7 @@ RFC2616_Req_Gzip(const struct sess *sp)
 	 * We do not care a hoot if the client prefers some other
 	 * compression more than gzip: Varnish only does gzip.
 	 */
-	if (http_GetHdrQ(sp->http, H_Accept_Encoding, "gzip") > 0.)
+	if (http_GetHdrQ(sp->req->http, H_Accept_Encoding, "gzip") > 0.)
 		return (1);
 
 	/* Bad client, no gzip. */
@@ -318,7 +318,7 @@ RFC2616_Do_Cond(const struct sess *sp)
 	/* RFC 2616 13.3.4 states we need to match both ETag
 	   and If-Modified-Since if present*/
 
-	if (http_GetHdr(sp->http, H_If_Modified_Since, &p) ) {
+	if (http_GetHdr(sp->req->http, H_If_Modified_Since, &p) ) {
 		if (!sp->wrk->obj->last_modified)
 			return (0);
 		ims = VTIM_parse(p);
@@ -329,7 +329,7 @@ RFC2616_Do_Cond(const struct sess *sp)
 		do_cond = 1;
 	}
 
-	if (http_GetHdr(sp->http, H_If_None_Match, &p) &&
+	if (http_GetHdr(sp->req->http, H_If_None_Match, &p) &&
 	    http_GetHdr(sp->wrk->obj->http, H_ETag, &e)) {
 		if (strcmp(p,e) != 0)
 			return (0);
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 42ce7df..92a7357 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -55,7 +55,6 @@ struct sessmem {
 	unsigned		workspace;
 	uint16_t		nhttp;
 	void			*wsp;
-	struct http		*http[2];
 	VTAILQ_ENTRY(sessmem)	list;
 
 	struct sess		sess;
@@ -69,7 +68,6 @@ struct sesspool {
 	struct lock		mtx;
 	unsigned		nsess;
 	unsigned		dly_free_cnt;
-	unsigned		req_size;
 	struct mempool		*mpl_req;
 };
 
@@ -82,6 +80,7 @@ SES_Charge(struct sess *sp)
 {
 	struct acct *a = &sp->wrk->acct_tmp;
 
+	CHECK_OBJ_NOTNULL(sp->req, REQ_MAGIC);
 	sp->req->req_bodybytes += a->bodybytes;
 
 #define ACCT(foo)				\
@@ -170,10 +169,6 @@ ses_setup(struct sessmem *sm)
 	sp->t_open = NAN;
 	sp->t_idle = NAN;
 	sp->t_req = NAN;
-
-	WS_Init(sp->ws, "sess", sm->wsp, sm->workspace);
-	sp->http = sm->http[0];
-	sp->http0 = sm->http[1];
 }
 
 /*--------------------------------------------------------------------
@@ -273,7 +268,7 @@ SES_Schedule(struct sess *sp)
 	if (Pool_Schedule(pp->pool, sp)) {
 		VSC_C_main->client_drop_late++;
 		sp->t_idle = VTIM_real();
-		if (sp->req->vcl != NULL) {
+		if (sp->req != NULL && sp->req->vcl != NULL) {
 			/*
 			 * A session parked on a busy object can come here
 			 * after it wakes up.  Loose the VCL reference.
@@ -391,19 +386,40 @@ SES_Delete(struct sess *sp, const char *reason, double now)
 }
 
 /*--------------------------------------------------------------------
- * Alloc/Free/Clean sp->req
+ * Alloc/Free sp->req
  */
 
 void
 SES_GetReq(struct sess *sp)
 {
 	struct sesspool *pp;
+	uint16_t nhttp;
+	unsigned sz, hl;
+	char *p;
 
 	pp = ses_getpool(sp);
 	AZ(sp->req);
-	sp->req = MPL_Get(pp->mpl_req, NULL);
+	sp->req = MPL_Get(pp->mpl_req, &sz);
 	AN(sp->req);
 	sp->req->magic = REQ_MAGIC;
+
+	p = (char*)(sp->req + 1);
+	sz -= sizeof *sp->req;
+
+	nhttp = (uint16_t)cache_param->http_max_hdr;
+	hl = HTTP_estimate(nhttp);
+
+	xxxassert(sz > 2 * hl + 128);
+
+	sp->req->http = HTTP_create(p, nhttp);
+	p += hl;
+	sz -= hl;
+
+	sp->req->http0 = HTTP_create(p, nhttp);
+	p += hl;
+	sz -= hl;
+	
+	WS_Init(sp->req->ws, "req", p, sz);
 }
 
 void
@@ -434,8 +450,8 @@ SES_NewPool(struct pool *wp, unsigned pool_no)
 	VTAILQ_INIT(&pp->freelist);
 	Lck_New(&pp->mtx, lck_sessmem);
 	bprintf(nb, "req%u", pool_no);
-	pp->req_size = sizeof (struct req);
-	pp->mpl_req = MPL_New(nb, &cache_param->req_pool, &pp->req_size);
+	pp->mpl_req = MPL_New(nb, &cache_param->req_pool,
+	    &cache_param->sess_workspace);
 	return (pp);
 }
 
diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c
index 562f6df..a5070cd 100644
--- a/bin/varnishd/cache/cache_vary.c
+++ b/bin/varnishd/cache/cache_vary.c
@@ -96,7 +96,7 @@ VRY_Create(const struct sess *sp, const struct http *hp)
 		    (char)(1 + (q - p)), (int)(q - p), p, 0);
 		AZ(VSB_finish(sbh));
 
-		if (http_GetHdr(sp->http, VSB_data(sbh), &h)) {
+		if (http_GetHdr(sp->req->http, VSB_data(sbh), &h)) {
 			AZ(vct_issp(*h));
 			/* Trim trailing space */
 			e = strchr(h, '\0');
@@ -187,7 +187,7 @@ VRY_Match(struct sess *sp, const uint8_t *vary)
 		if (i == 1) {
 			/* Build a new entry */
 
-			i = http_GetHdr(sp->http, (const char*)(vary+2), &h);
+			i = http_GetHdr(sp->req->http, (const char*)(vary+2), &h);
 			if (i) {
 				/* Trim trailing space */
 				e = strchr(h, '\0');
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index e078f8f..7f27e8b 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -97,7 +97,7 @@ vrt_selecthttp(const struct sess *sp, enum gethdr_e where)
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	switch (where) {
 	case HDR_REQ:
-		hp = sp->http;
+		hp = sp->req->http;
 		break;
 	case HDR_BEREQ:
 		hp = sp->wrk->busyobj->bereq;
@@ -307,7 +307,7 @@ VRT_IP_string(const struct sess *sp, const struct sockaddr_storage *sa)
 		INCOMPL();
 	}
 	XXXAN(len);
-	AN(p = WS_Alloc(sp->http->ws, len));
+	AN(p = WS_Alloc(sp->req->http->ws, len));
 	AN(inet_ntop(sa->ss_family, addr, p, len));
 	return (p);
 }
@@ -319,7 +319,7 @@ VRT_int_string(const struct sess *sp, int num)
 	int size;
 
 	size = snprintf(NULL, 0, "%d", num) + 1;
-	AN(p = WS_Alloc(sp->http->ws, size));
+	AN(p = WS_Alloc(sp->req->http->ws, size));
 	assert(snprintf(p, size, "%d", num) < size);
 	return (p);
 }
@@ -331,7 +331,7 @@ VRT_double_string(const struct sess *sp, double num)
 	int size;
 
 	size = snprintf(NULL, 0, "%.3f", num) + 1;
-	AN(p = WS_Alloc(sp->http->ws, size));
+	AN(p = WS_Alloc(sp->req->http->ws, size));
 	assert(snprintf(p, size, "%.3f", num) < size);
 	return (p);
 }
@@ -341,7 +341,7 @@ VRT_time_string(const struct sess *sp, double t)
 {
 	char *p;
 
-	AN(p = WS_Alloc(sp->http->ws, VTIM_FORMAT_SIZE));
+	AN(p = WS_Alloc(sp->req->http->ws, VTIM_FORMAT_SIZE));
 	VTIM_format(t, p);
 	return (p);
 }
@@ -371,8 +371,8 @@ void
 VRT_Rollback(struct sess *sp)
 {
 
-	HTTP_Copy(sp->http, sp->http0);
-	WS_Reset(sp->ws, sp->req->ws_req);
+	HTTP_Copy(sp->req->http, sp->req->http0);
+	WS_Reset(sp->req->ws, sp->req->ws_req);
 }
 
 /*--------------------------------------------------------------------*/
@@ -384,7 +384,7 @@ VRT_panic(const struct sess *sp, const char *str, ...)
 	char *b;
 
 	va_start(ap, str);
-	b = VRT_String(sp->http->ws, "PANIC: ", str, ap);
+	b = VRT_String(sp->req->http->ws, "PANIC: ", str, ap);
 	va_end(ap);
 	VAS_Fail("VCL", "", 0, b, 0, 2);
 }
diff --git a/bin/varnishd/cache/cache_vrt_re.c b/bin/varnishd/cache/cache_vrt_re.c
index e9ac9de..9864611 100644
--- a/bin/varnishd/cache/cache_vrt_re.c
+++ b/bin/varnishd/cache/cache_vrt_re.c
@@ -110,8 +110,8 @@ VRT_regsub(const struct sess *sp, int all, const char *str, void *re,
 		return(str);
 	}
 
-	u = WS_Reserve(sp->http->ws, 0);
-	res.e = res.b = b0 = sp->http->ws->f;
+	u = WS_Reserve(sp->req->http->ws, 0);
+	res.e = res.b = b0 = sp->req->http->ws->f;
 	res.e += u;
 
 	do {
@@ -143,7 +143,7 @@ VRT_regsub(const struct sess *sp, int all, const char *str, void *re,
 		i = VRE_exec(t, str, len, 0, options, ovector, 30,
 		    &cache_param->vre_limits);
 		if (i < VRE_ERROR_NOMATCH ) {
-			WS_Release(sp->http->ws, 0);
+			WS_Release(sp->req->http->ws, 0);
 			WSP(sp, SLT_VCL_Error,
 			    "Regexp matching returned %d", i);
 			return(str);
@@ -153,10 +153,10 @@ VRT_regsub(const struct sess *sp, int all, const char *str, void *re,
 	/* Copy suffix to match */
 	Tadd(&res, str, len+1);
 	if (res.b >= res.e) {
-		WS_Release(sp->http->ws, 0);
+		WS_Release(sp->req->http->ws, 0);
 		return (str);
 	}
 	Tcheck(res);
-	WS_ReleaseP(sp->http->ws, res.b);
+	WS_ReleaseP(sp->req->http->ws, res.b);
 	return (b0);
 }
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 7ac9768..d128818 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -82,9 +82,9 @@ VRT_r_##obj##_##hdr(const struct sess *sp)			\
 	return (http->hd[fld].b);				\
 }
 
-VRT_DO_HDR(req,   request,	sp->http,		HTTP_HDR_REQ)
-VRT_DO_HDR(req,   url,		sp->http,		HTTP_HDR_URL)
-VRT_DO_HDR(req,   proto,	sp->http,		HTTP_HDR_PROTO)
+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)
@@ -222,7 +222,7 @@ VRT_l_client_identity(struct sess *sp, const char *str, ...)
 	char *b;
 
 	va_start(ap, str);
-	b = VRT_String(sp->http->ws, NULL, str, ap);
+	b = VRT_String(sp->req->http->ws, NULL, str, ap);
 	va_end(ap);
 	sp->req->client_identity = b;
 }
@@ -434,7 +434,7 @@ VRT_r_req_xid(struct sess *sp)
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 
 	size = snprintf(NULL, 0, "%u", sp->req->xid) + 1;
-	AN(p = WS_Alloc(sp->http->ws, size));
+	AN(p = WS_Alloc(sp->req->http->ws, size));
 	assert(snprintf(p, size, "%u", sp->req->xid) < size);
 	return (p);
 }
diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c
index 2f7bd53..81aaf0d 100644
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@ -688,7 +688,7 @@ static const struct parspec input_parspec[] = {
 		0,
 		"120", "seconds" },
 	{ "sess_workspace",
-		tweak_bytes_u, &mgt_param.sess_workspace, 1024, UINT_MAX,
+		tweak_bytes_u, &mgt_param.sess_workspace, 3072, UINT_MAX,
 		"Bytes of HTTP protocol workspace allocated for sessions. "
 		"This space must be big enough for the entire HTTP protocol "
 		"header and any edits done to it in the VCL code.\n"



More information about the varnish-commit mailing list