[master] d6b6428 Move the beresp and bereq from worker ot busyobj for good.

Poul-Henning Kamp phk at varnish-cache.org
Thu Dec 8 08:45:35 CET 2011


commit d6b64285f179f8d6a66f29c60357f9c33cabb95c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Dec 8 07:45:21 2011 +0000

    Move the beresp and bereq from worker ot busyobj for good.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 4435c32..ed6a3fd 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -328,10 +328,6 @@ struct worker {
 	/* This is only here so VRT can find it */
 	const char		*storage_hint;
 
-	/* Fetch stuff.  Here because pipe has no busyobj */
-	struct http		*x_bereq;
-	struct http		*x_beresp;
-
 	/* Stream state */
 	struct stream_ctx	*sctx;
 
diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c
index 4272725..ab4db76 100644
--- a/bin/varnishd/cache/cache_busyobj.c
+++ b/bin/varnishd/cache/cache_busyobj.c
@@ -43,6 +43,7 @@ struct vbo {
 #define VBO_MAGIC		0xde3d8223
 	struct lock		mtx;
 	unsigned		refcount;
+	uint16_t		nhttp;
 	struct busyobj		bo;
 };
 
@@ -64,9 +65,20 @@ static struct vbo *
 vbo_New(void)
 {
 	struct vbo *vbo;
+	uint16_t nhttp;
+	ssize_t http_space;
 
-	ALLOC_OBJ(vbo, VBO_MAGIC);
+	assert(cache_param->http_max_hdr < 65536);
+	nhttp = (uint16_t)cache_param->http_max_hdr;
+
+	http_space = HTTP_estimate(nhttp);
+
+	vbo = malloc(sizeof *vbo + 2 * http_space);
 	AN(vbo);
+
+	memset(vbo, 0, sizeof *vbo);
+	vbo->magic = VBO_MAGIC;
+	vbo->nhttp = nhttp;
 	Lck_New(&vbo->mtx, lck_busyobj);
 	return (vbo);
 }
@@ -89,6 +101,7 @@ struct busyobj *
 VBO_GetBusyObj(struct worker *wrk)
 {
 	struct vbo *vbo = NULL;
+	char *p;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 
@@ -109,17 +122,25 @@ VBO_GetBusyObj(struct worker *wrk)
 		Lck_Unlock(&vbo_mtx);
 	}
 
+	if (vbo != NULL && vbo->nhttp != cache_param->http_max_hdr)
+		VBO_Free(&vbo);
+
 	if (vbo == NULL)
 		vbo = vbo_New();
 
 	CHECK_OBJ_NOTNULL(vbo, VBO_MAGIC);
 	AZ(vbo->refcount);
+
 	AZ(vbo->bo.magic);
 	vbo->refcount = 1;
 	vbo->bo.magic = BUSYOBJ_MAGIC;
 	vbo->bo.vbo = vbo;
-	vbo->bo.beresp = wrk->x_beresp;
-	vbo->bo.bereq = wrk->x_bereq;
+
+	p = (void*)(vbo + 1);
+	vbo->bo.bereq = HTTP_create(p, vbo->nhttp);
+	p += HTTP_estimate(vbo->nhttp);
+	vbo->bo.beresp = HTTP_create(p, vbo->nhttp);
+
 	return (&vbo->bo);
 }
 
diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c
index cf40e85..a3cb805 100644
--- a/bin/varnishd/cache/cache_pool.c
+++ b/bin/varnishd/cache/cache_pool.c
@@ -196,8 +196,6 @@ Pool_Work_Thread(void *priv, struct worker *w)
 		Lck_AssertHeld(&pp->mtx);
 
 		CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
-		CHECK_OBJ_NOTNULL(w->x_bereq, HTTP_MAGIC);
-		CHECK_OBJ_NOTNULL(w->x_beresp, HTTP_MAGIC);
 		CHECK_OBJ_NOTNULL(w->resp, HTTP_MAGIC);
 
 		WS_Reset(w->ws, NULL);
diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index 73eedb2..6b1d9dd 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -139,8 +139,6 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned sess_workspace,
 	uint32_t wlog[shm_workspace / 4];
 	/* XXX: can we trust these to be properly aligned ? */
 	unsigned char ws[sess_workspace];
-	unsigned char http0[http_space];
-	unsigned char http1[http_space];
 	unsigned char http2[http_space];
 	struct iovec iov[siov];
 	struct SHA256Context sha256;
@@ -153,8 +151,6 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned sess_workspace,
 	w->wlb = w->wlp = wlog;
 	w->wle = wlog + (sizeof wlog) / 4;
 	w->sha256ctx = &sha256;
-	w->x_bereq = HTTP_create(http0, nhttp);
-	w->x_beresp = HTTP_create(http1, nhttp);
 	w->resp = HTTP_create(http2, nhttp);
 	w->wrw.iov = iov;
 	w->wrw.siov = siov;



More information about the varnish-commit mailing list