[master] d98dee2 Give busyobj its own VSL staging buffer too.

Poul-Henning Kamp phk at varnish-cache.org
Tue Feb 14 09:17:55 CET 2012


commit d98dee20689a3f9671e7177e5412d0837d46aeb1
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Feb 14 08:17:32 2012 +0000

    Give busyobj its own VSL staging buffer too.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index d9d9f48..39b30da 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -451,8 +451,6 @@ oc_getlru(const struct objcore *oc)
  *
  * One of these aspects will be how much has been fetched, which
  * streaming delivery will make use of.
- *
- * XXX: many fields from worker needs to move here.
  */
 
 struct busyobj {
@@ -493,6 +491,8 @@ struct busyobj {
 	double			connect_timeout;
 	double			first_byte_timeout;
 	double			between_bytes_timeout;
+
+	struct vsl_log		vsl[1];
 };
 
 /* Object structure --------------------------------------------------*/
diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c
index 0252d57..8f0f31e 100644
--- a/bin/varnishd/cache/cache_busyobj.c
+++ b/bin/varnishd/cache/cache_busyobj.c
@@ -98,14 +98,11 @@ VBO_GetBusyObj(struct worker *wrk)
 {
 	struct vbo *vbo = NULL;
 	uint16_t nhttp;
-	unsigned httpsz;
+	unsigned sz;
 	char *p;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 
-	nhttp = (uint16_t)cache_param->http_max_hdr;
-	httpsz = HTTP_estimate(nhttp);
-
 	if (wrk->nvbo != NULL) {
 		vbo = wrk->nvbo;
 		wrk->nvbo = NULL;
@@ -123,15 +120,28 @@ VBO_GetBusyObj(struct worker *wrk)
 	vbo->bo.vbo = vbo;
 
 	p = (void*)(vbo + 1);
+	p = (void*)PRNDUP(p);
+	assert(p < vbo->end);
+
+	nhttp = (uint16_t)cache_param->http_max_hdr;
+	sz = HTTP_estimate(nhttp);
+
 	vbo->bo.bereq = HTTP_create(p, nhttp);
-	p += httpsz;
+	p += sz;
+	p = (void*)PRNDUP(p);
+	assert(p < vbo->end);
+
 	vbo->bo.beresp = HTTP_create(p, nhttp);
-	p += httpsz;
-	if (p >= vbo->end) {
-		fprintf(stderr, "workspace_backend is at least %jd to small\n",
-		    (p - vbo->end));
-		assert (p < vbo->end);
-	}
+	p += sz;
+	p = (void*)PRNDUP(p);
+	assert(p < vbo->end);
+
+	sz = cache_param->vsl_buffer;
+	VSL_Setup(vbo->bo.vsl, p, sz);
+	p += sz;
+	p = (void*)PRNDUP(p);
+	assert(p < vbo->end);
+
 	WS_Init(vbo->bo.ws, "bo", p, vbo->end - p);
 
 	return (&vbo->bo);
@@ -170,13 +180,15 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo)
 	r = --vbo->refcount;
 	Lck_Unlock(&vbo->mtx);
 
-	if (r == 0) {
-		/* XXX: Sanity checks & cleanup */
-		memset(&vbo->bo, 0, sizeof vbo->bo);
+	if (r)
+		return;
 
-		if (cache_param->bo_cache && wrk->nvbo == NULL)
-			wrk->nvbo = vbo;
-		else
-			VBO_Free(&vbo);
-	}
+	WSL_Flush(vbo->bo.vsl, 0);
+	/* XXX: Sanity checks & cleanup */
+	memset(&vbo->bo, 0, sizeof vbo->bo);
+
+	if (cache_param->bo_cache && wrk->nvbo == NULL)
+		wrk->nvbo = vbo;
+	else
+		VBO_Free(&vbo);
 }
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 0cb3a38..45e069e 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -480,6 +480,7 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req)
 	AZ(wrk->busyobj);
 
 	wrk->busyobj = VBO_GetBusyObj(wrk);
+	wrk->busyobj->vsl->wid = sp->vsl_id;
 	req->obj = STV_NewObject(wrk, TRANSIENT_STORAGE,
 	    cache_param->http_resp_size,
 	    (uint16_t)cache_param->http_max_hdr);
@@ -1222,7 +1223,6 @@ cnt_miss(struct sess *sp, struct worker *wrk, struct req *req)
 	CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
 	AZ(req->obj);
 
-	wrk->busyobj = VBO_GetBusyObj(wrk);
 	http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws);
 	http_FilterReq(sp, HTTPH_R_FETCH);
 	http_ForceGet(wrk->busyobj->bereq);
@@ -1297,6 +1297,7 @@ cnt_pass(struct sess *sp, struct worker *wrk, const struct req *req)
 	AZ(wrk->busyobj);
 
 	wrk->busyobj = VBO_GetBusyObj(wrk);
+	wrk->busyobj->vsl->wid = sp->vsl_id;
 	http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws);
 	http_FilterReq(sp, HTTPH_R_PASS);
 
@@ -1351,6 +1352,7 @@ cnt_pipe(struct sess *sp, struct worker *wrk, const struct req *req)
 
 	wrk->acct_tmp.pipe++;
 	wrk->busyobj = VBO_GetBusyObj(wrk);
+	wrk->busyobj->vsl->wid = sp->vsl_id;
 	http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws);
 	http_FilterReq(sp, 0);
 
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 018c4f9..73e4f08 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -416,6 +416,8 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
 	if (vc->recycled)
 		retry = 1;
 
+	sp->wrk->busyobj->vsl->wid = vc->vsl_id;
+
 	/*
 	 * Now that we know our backend, we can set a default Host:
 	 * header if one is necessary.  This cannot be done in the VCL
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index b330c67..49f6d30 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -453,6 +453,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
 
 	AZ(wrk->busyobj);
 	wrk->busyobj = VBO_GetBusyObj(wrk);
+	wrk->busyobj->vsl->wid = sp->vsl_id;
 
 	VRY_Validate(sp->req->vary_b);
 	if (sp->req->vary_l != NULL)
diff --git a/bin/varnishtest/tests/r01038.vtc b/bin/varnishtest/tests/r01038.vtc
index cecb009..983b704 100644
--- a/bin/varnishtest/tests/r01038.vtc
+++ b/bin/varnishtest/tests/r01038.vtc
@@ -45,7 +45,7 @@ server s1 {
 	txresp -body "foo8"
 } -start
 
-varnish v1 -arg "-p workspace_backend=3072" -vcl+backend {
+varnish v1 -arg "-p workspace_backend=7k" -vcl+backend {
 	sub vcl_fetch {
 		set beresp.do_esi = true;
 	}



More information about the varnish-commit mailing list