[master] fe68764 Attach the vslbuffer to the vbc while in use and lend it the vbc's vsl_id. When the vbc is returned, restore the original vsl_id.

Poul-Henning Kamp phk at varnish-cache.org
Tue Feb 14 10:19:28 CET 2012


commit fe687646b00aed6d0f2b589353551e98e4a0d64d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Feb 14 09:18:21 2012 +0000

    Attach the vslbuffer to the vbc while in use and lend it the
    vbc's vsl_id.  When the vbc is returned, restore the original vsl_id.
    
    Change WSLB() to VSLB() and have it take a busyobj as arg.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 39b30da..eac81df 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -756,8 +756,8 @@ int EXP_NukeOne(struct worker *w, struct lru *lru);
 
 /* cache_fetch.c */
 struct storage *FetchStorage(struct worker *w, ssize_t sz);
-int FetchError(struct worker *w, const char *error);
-int FetchError2(struct worker *w, const char *error, const char *more);
+int FetchError(const struct worker *w, const char *error);
+int FetchError2(const struct worker *w, const char *error, const char *more);
 int FetchHdr(struct sess *sp, int need_host_hdr, int sendbody);
 int FetchBody(struct worker *w, struct object *obj);
 int FetchReqBody(const struct sess *sp, int sendbody);
@@ -934,7 +934,7 @@ void VSL(enum VSL_tag_e tag, int id, const char *fmt, ...)
 void WSLR(struct vsl_log *, enum VSL_tag_e tag, int id, txt t);
 void WSL(struct vsl_log *, enum VSL_tag_e tag, int id, const char *fmt, ...)
     __printflike(4, 5);
-void WSLB(struct worker *, enum VSL_tag_e tag, const char *fmt, ...)
+void VSLB(struct busyobj *, enum VSL_tag_e tag, const char *fmt, ...)
     __printflike(3, 4);
 
 void WSL_Flush(struct vsl_log *, int overflow);
diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h
index a836fac..b1688f9 100644
--- a/bin/varnishd/cache/cache_backend.h
+++ b/bin/varnishd/cache/cache_backend.h
@@ -153,6 +153,7 @@ struct vbc {
 	struct backend		*backend;
 	struct vdi_simple	*vdis;
 	struct vsl_log		*vsl;
+	unsigned		orig_vsl_id;
 	unsigned		vsl_id;
 	int			fd;
 
diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c
index bbb13bb..b1359e3 100644
--- a/bin/varnishd/cache/cache_dir.c
+++ b/bin/varnishd/cache/cache_dir.c
@@ -61,7 +61,9 @@ VDI_CloseFd(struct worker *wrk, struct vbc **vbp)
 	   before the OS reuses the FD */
 	WSL_Flush(wrk->vsl, 0);
 	WSL_Flush(vc->vsl, 0);
+	vc->vsl->wid = vc->orig_vsl_id;
 	vc->vsl = NULL;
+	vc->orig_vsl_id = 0;
 
 	VTCP_close(&vc->fd);
 	VBE_DropRefConn(bp);
@@ -95,7 +97,9 @@ VDI_RecycleFd(struct worker *wrk, struct vbc **vbp)
 	 */
 	WSL_Flush(wrk->vsl, 0);
 	WSL_Flush(vc->vsl, 0);
+	vc->vsl->wid = vc->orig_vsl_id;
 	vc->vsl = NULL;
+	vc->orig_vsl_id = 0;
 
 	Lck_Lock(&bp->mtx);
 	VSC_C_main->backend_recycle++;
@@ -117,6 +121,7 @@ VDI_GetFd(const struct director *d, struct sess *sp)
 	vc = d->getfd(d, sp);
 	if (vc != NULL) {
 		vc->vsl = sp->wrk->busyobj->vsl;
+		vc->orig_vsl_id = vc->vsl->wid;
 		vc->vsl->wid = vc->vsl_id;
 	}
 	return (vc);
diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c
index 1d705b1..3154784 100644
--- a/bin/varnishd/cache/cache_esi_parse.c
+++ b/bin/varnishd/cache/cache_esi_parse.c
@@ -61,6 +61,7 @@ struct vep_state {
 	struct vsb		*vsb;
 
 	struct worker		*wrk;
+	struct busyobj		*bo;
 	int			dogzip;
 	vep_callback_t		*cb;
 
@@ -186,7 +187,7 @@ vep_error(const struct vep_state *vep, const char *p)
 
 	VSC_C_main->esi_errors++;
 	l = (intmax_t)(vep->ver_p - vep->hack_p);
-	WSLB(vep->wrk, SLT_ESI_xmlerror, "ERR at %jd %s", l, p);
+	VSLB(vep->bo, SLT_ESI_xmlerror, "ERR at %jd %s", l, p);
 
 }
 
@@ -202,7 +203,7 @@ vep_warn(const struct vep_state *vep, const char *p)
 	VSC_C_main->esi_warnings++;
 	l = (intmax_t)(vep->ver_p - vep->hack_p);
 	printf("WARNING at %jd %s\n", l, p);
-	WSLB(vep->wrk, SLT_ESI_xmlerror, "WARN at %jd %s", l, p);
+	VSLB(vep->bo, SLT_ESI_xmlerror, "WARN at %jd %s", l, p);
 
 }
 
@@ -602,7 +603,7 @@ VEP_Parse(const struct worker *wrk, const char *p, size_t l)
 				p++;
 				vep->state = VEP_STARTTAG;
 			} else if (p < e) {
-				WSLB(vep->wrk, SLT_ESI_xmlerror,
+				VSLB(vep->bo, SLT_ESI_xmlerror,
 				    "No ESI processing, first char not '<'");
 				vep->state = VEP_NOTXML;
 			}
@@ -1010,6 +1011,7 @@ VEP_Init(struct worker *wrk, vep_callback_t *cb)
 	memset(vep, 0, sizeof *vep);
 	vep->magic = VEP_MAGIC;
 	vep->wrk = wrk;
+	vep->bo = wrk->busyobj;
 	vep->vsb = VSB_new_auto();
 	AN(vep->vsb);
 	wrk->busyobj->vep = vep;
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 018c4f9..1e2ef44 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -52,22 +52,23 @@ static unsigned fetchfrag;
  */
 
 int
-FetchError2(struct worker *wrk, const char *error, const char *more)
+FetchError2(const struct worker *wrk, const char *error, const char *more)
 {
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	if (!wrk->busyobj->fetch_failed) {
 		if (more == NULL)
-			WSLB(wrk, SLT_FetchError, "%s", error);
+			VSLB(wrk->busyobj, SLT_FetchError, "%s", error);
 		else
-			WSLB(wrk, SLT_FetchError, "%s: %s", error, more);
+			VSLB(wrk->busyobj, SLT_FetchError, "%s: %s", error,
+			    more);
 	}
 	wrk->busyobj->fetch_failed = 1;
 	return (-1);
 }
 
 int
-FetchError(struct worker *wrk, const char *error)
+FetchError(const struct worker *wrk, const char *error)
 {
 	return(FetchError2(wrk, error, NULL));
 }
@@ -574,7 +575,7 @@ FetchBody(struct worker *wrk, struct object *obj)
 
 	bo->fetch_obj = NULL;
 
-	WSLB(wrk, SLT_Fetch_Body, "%u(%s) cls %d mklen %d",
+	VSLB(bo, SLT_Fetch_Body, "%u(%s) cls %d mklen %d",
 	    bo->body_status, body_status(bo->body_status),
 	    cls, mklen);
 
@@ -594,7 +595,7 @@ FetchBody(struct worker *wrk, struct object *obj)
 	if (cls == 0 && bo->should_close)
 		cls = 1;
 
-	WSLB(wrk, SLT_Length, "%zd", obj->len);
+	VSLB(bo, SLT_Length, "%zd", obj->len);
 
 	{
 	/* Sanity check fetch methods accounting */
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index 2ee1abf..cf270c5 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -399,7 +399,7 @@ VGZ_Destroy(struct vgz **vgp, int vsl_id)
 	*vgp = NULL;
 
 	if (vsl_id < 0)
-		WSLB(vg->wrk, SLT_Gzip, "%s %jd %jd %jd %jd %jd",
+		VSLB(vg->wrk->busyobj, SLT_Gzip, "%s %jd %jd %jd %jd %jd",
 		    vg->id,
 		    (intmax_t)vg->vz.total_in,
 		    (intmax_t)vg->vz.total_out,
diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c
index ab715b7..299389f 100644
--- a/bin/varnishd/cache/cache_shmlog.c
+++ b/bin/varnishd/cache/cache_shmlog.c
@@ -289,16 +289,14 @@ WSL(struct vsl_log *vsl, enum VSL_tag_e tag, int id, const char *fmt, ...)
 /*--------------------------------------------------------------------*/
 
 void
-WSLB(struct worker *wrk, enum VSL_tag_e tag, const char *fmt, ...)
+VSLB(struct busyobj *bo, enum VSL_tag_e tag, const char *fmt, ...)
 {
 	va_list ap;
 
-	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
-	CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
-	CHECK_OBJ_NOTNULL(wrk->busyobj->vbc, VBC_MAGIC);
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	AN(fmt);
 	va_start(ap, fmt);
-	wsl(wrk->vsl, tag, wrk->busyobj->vbc->vsl_id, fmt, ap);
+	wsl(bo->vsl, tag, bo->vsl->wid, fmt, ap);
 	va_end(ap);
 }
 



More information about the varnish-commit mailing list