[experimental-ims] f093a08 Tag vbc's with the vsl buffer they should log into. Update the buffers wid with the vbc's vsl_id. Flush the buffer when we recycle/close the vbc.

Geoff Simmons geoff at varnish-cache.org
Tue Feb 14 17:49:35 CET 2012


commit f093a082a7beb579a9e09c2c7e5cae577c235652
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Feb 14 08:52:06 2012 +0000

    Tag vbc's with the vsl buffer they should log into.  Update the
    buffers wid with the vbc's vsl_id.  Flush the buffer when we
    recycle/close the vbc.

diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h
index ad71169..a836fac 100644
--- a/bin/varnishd/cache/cache_backend.h
+++ b/bin/varnishd/cache/cache_backend.h
@@ -152,6 +152,7 @@ struct vbc {
 	VTAILQ_ENTRY(vbc)	list;
 	struct backend		*backend;
 	struct vdi_simple	*vdis;
+	struct vsl_log		*vsl;
 	unsigned		vsl_id;
 	int			fd;
 
diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c
index 53a3e50..bbb13bb 100644
--- a/bin/varnishd/cache/cache_dir.c
+++ b/bin/varnishd/cache/cache_dir.c
@@ -55,11 +55,13 @@ VDI_CloseFd(struct worker *wrk, struct vbc **vbp)
 
 	bp = vc->backend;
 
-	WSL(wrk->vsl, SLT_BackendClose, vc->vsl_id, "%s", bp->display_name);
+	WSL(vc->vsl, SLT_BackendClose, vc->vsl_id, "%s", bp->display_name);
 
 	/* Checkpoint log to flush all info related to this connection
 	   before the OS reuses the FD */
 	WSL_Flush(wrk->vsl, 0);
+	WSL_Flush(vc->vsl, 0);
+	vc->vsl = NULL;
 
 	VTCP_close(&vc->fd);
 	VBE_DropRefConn(bp);
@@ -85,12 +87,16 @@ VDI_RecycleFd(struct worker *wrk, struct vbc **vbp)
 
 	bp = vc->backend;
 
-	WSL(wrk->vsl, SLT_BackendReuse, vc->vsl_id, "%s", bp->display_name);
+	WSL(vc->vsl, SLT_BackendReuse, vc->vsl_id, "%s", bp->display_name);
+
 	/*
 	 * Flush the shmlog, so that another session reusing this backend
 	 * will log chronologically later than our use of it.
 	 */
 	WSL_Flush(wrk->vsl, 0);
+	WSL_Flush(vc->vsl, 0);
+	vc->vsl = NULL;
+
 	Lck_Lock(&bp->mtx);
 	VSC_C_main->backend_recycle++;
 	VTAILQ_INSERT_HEAD(&bp->connlist, vc, list);
@@ -102,12 +108,18 @@ VDI_RecycleFd(struct worker *wrk, struct vbc **vbp)
 struct vbc *
 VDI_GetFd(const struct director *d, struct sess *sp)
 {
+	struct vbc *vc;
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	if (d == NULL)
 		d = sp->req->director;
 	CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
-	return (d->getfd(d, sp));
+	vc = d->getfd(d, sp);
+	if (vc != NULL) {
+		vc->vsl = sp->wrk->busyobj->vsl;
+		vc->vsl->wid = vc->vsl_id;
+	}
+	return (vc);
 }
 
 /* Check health ------------------------------------------------------
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 73e4f08..018c4f9 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -416,8 +416,6 @@ 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



More information about the varnish-commit mailing list