[experimental-ims] 1fd2741 Start abstracting the VSL handling a bit.

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


commit 1fd274110b3247131461ab4632b8e00fa1db7ca4
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Feb 13 21:17:59 2012 +0000

    Start abstracting the VSL handling a bit.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 4b1bfc3..9a31cb4 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -245,6 +245,13 @@ struct exp {
 
 /*--------------------------------------------------------------------*/
 
+struct vsl_log {
+	uint32_t		*wlb, *wlp, *wle;
+	unsigned		wlr;
+};
+
+/*--------------------------------------------------------------------*/
+
 struct wrk_accept {
 	unsigned		magic;
 #define WRK_ACCEPT_MAGIC	0x8c4b4d59
@@ -297,8 +304,7 @@ struct worker {
 
 	struct VCL_conf		*vcl;
 
-	uint32_t		*wlb, *wlp, *wle;
-	unsigned		wlr;
+	struct vsl_log		vsl[1];
 
 	struct ws		aws[1];
 
@@ -909,13 +915,13 @@ void VSM_Free(void *ptr);
 #ifdef VSL_ENDMARKER
 void VSL(enum VSL_tag_e tag, int id, const char *fmt, ...)
     __printflike(3, 4);
-void WSLR(struct worker *w, enum VSL_tag_e tag, int id, txt t);
-void WSL(struct worker *w, 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 *w, enum VSL_tag_e tag, const char *fmt, ...)
+void WSLB(struct worker *, enum VSL_tag_e tag, const char *fmt, ...)
     __printflike(3, 4);
 
-void WSL_Flush(struct worker *w, int overflow);
+void WSL_Flush(struct vsl_log *, int overflow);
 
 #define DSL(flag, tag, id, ...)					\
 	do {							\
@@ -924,10 +930,10 @@ void WSL_Flush(struct worker *w, int overflow);
 	} while (0)
 
 #define WSP(sess, tag, ...)					\
-	WSL((sess)->wrk, tag, (sess)->vsl_id, __VA_ARGS__)
+	WSL((sess)->wrk->vsl, tag, (sess)->vsl_id, __VA_ARGS__)
 
 #define WSPR(sess, tag, txt)					\
-	WSLR((sess)->wrk, tag, (sess)->vsl_id, txt)
+	WSLR((sess)->wrk->vsl, tag, (sess)->vsl_id, txt)
 
 #define INCOMPL() do {							\
 	VSL(SLT_Debug, 0, "INCOMPLETE AT: %s(%d)", __func__, __LINE__); \
diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 039300b..267e7ba 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -185,7 +185,7 @@ bes_conn_try(const struct sess *sp, struct vbc *vc, const struct vdi_simple *vs)
 	} else {
 		vc->vsl_id = s | VSL_BACKENDMARKER;
 		VTCP_myname(s, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1);
-		WSL(sp->wrk, SLT_BackendOpen, vc->vsl_id, "%s %s %s ",
+		WSL(sp->wrk->vsl, SLT_BackendOpen, vc->vsl_id, "%s %s %s ",
 		    vs->backend->display_name, abuf1, pbuf1);
 	}
 
@@ -356,12 +356,12 @@ vbe_GetVbe(const struct sess *sp, struct vdi_simple *vs)
 			return (vc);
 		}
 		VSC_C_main->backend_toolate++;
-		WSL(sp->wrk, SLT_BackendClose, vc->vsl_id, "%s",
+		WSL(sp->wrk->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(sp->wrk, 0);
+		WSL_Flush(sp->wrk->vsl, 0);
 
 		VTCP_close(&vc->fd);
 		VBE_DropRefConn(bp);
diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index 451e504..6dc3618 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -954,7 +954,7 @@ ban_lurker(struct sess *sp, void *priv)
 		}
 
 		i = ban_lurker_work(sp, pass);
-		WSL_Flush(sp->wrk, 0);
+		WSL_Flush(sp->wrk->vsl, 0);
 		WRK_SumStat(sp->wrk);
 		if (i) {
 			pass += (1 << LURK_SHIFT);
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 345d0cf..0cb3a38 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -407,7 +407,7 @@ cnt_done(struct sess *sp, struct worker *wrk, struct req *req)
 		    req->xid, sp->t_req, sp->t_idle, dh, dp, da);
 	}
 	req->xid = 0;
-	WSL_Flush(wrk, 0);
+	WSL_Flush(wrk->vsl, 0);
 
 	sp->t_req = NAN;
 	req->t_resp = NAN;
@@ -1592,7 +1592,7 @@ cnt_diag(struct sess *sp, const char *state)
 	if (sp->wrk != NULL) {
 		WSP(sp, SLT_Debug, "vsl_id %u STP_%s sp %p obj %p vcl %p",
 		    sp->vsl_id, state, sp, obj, vcl);
-		WSL_Flush(sp->wrk, 0);
+		WSL_Flush(sp->wrk->vsl, 0);
 	} else {
 		VSL(SLT_Debug, sp->vsl_id,
 		    "vsl_id %u STP_%s sp %p obj %p vcl %p",
@@ -1673,7 +1673,7 @@ CNT_Session(struct sess *sp)
 		WS_Assert(wrk->aws);
 		CHECK_OBJ_ORNULL(wrk->nobjhead, OBJHEAD_MAGIC);
 	}
-	WSL_Flush(wrk, 0);
+	WSL_Flush(wrk->vsl, 0);
 #define ACCT(foo)	AZ(wrk->acct_tmp.foo);
 #include "tbl/acct_fields.h"
 #undef ACCT
diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c
index 4ec81fb..53a3e50 100644
--- a/bin/varnishd/cache/cache_dir.c
+++ b/bin/varnishd/cache/cache_dir.c
@@ -55,11 +55,11 @@ VDI_CloseFd(struct worker *wrk, struct vbc **vbp)
 
 	bp = vc->backend;
 
-	WSL(wrk, SLT_BackendClose, vc->vsl_id, "%s", bp->display_name);
+	WSL(wrk->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, 0);
+	WSL_Flush(wrk->vsl, 0);
 
 	VTCP_close(&vc->fd);
 	VBE_DropRefConn(bp);
@@ -85,12 +85,12 @@ VDI_RecycleFd(struct worker *wrk, struct vbc **vbp)
 
 	bp = vc->backend;
 
-	WSL(wrk, SLT_BackendReuse, vc->vsl_id, "%s", bp->display_name);
+	WSL(wrk->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, 0);
+	WSL_Flush(wrk->vsl, 0);
 	Lck_Lock(&bp->mtx);
 	VSC_C_main->backend_recycle++;
 	VTAILQ_INSERT_HEAD(&bp->connlist, vc, list);
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index bfd6a8c..8ef35a3 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -98,7 +98,7 @@ ved_include(struct sess *sp, const char *src, const char *host)
 		if (sp->step == STP_DONE)
 			break;
 		AZ(sp->wrk);
-		WSL_Flush(w, 0);
+		WSL_Flush(w->vsl, 0);
 		DSL(0x20, SLT_Debug, sp->vsl_id, "loop waiting for ESI");
 		(void)usleep(10000);
 	}
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index e93a1aa..1060bac 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -342,7 +342,7 @@ exp_timer(struct sess *sp, void *priv)
 	oc = NULL;
 	while (1) {
 		if (oc == NULL) {
-			WSL_Flush(sp->wrk, 0);
+			WSL_Flush(sp->wrk->vsl, 0);
 			WRK_SumStat(sp->wrk);
 			VTIM_sleep(cache_param->expiry_sleep);
 			t = VTIM_real();
@@ -400,7 +400,7 @@ exp_timer(struct sess *sp, void *priv)
 
 		CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC);
 		o = oc_getobj(sp->wrk, oc);
-		WSL(sp->wrk, SLT_ExpKill, 0, "%u %.0f",
+		WSL(sp->wrk->vsl, SLT_ExpKill, 0, "%u %.0f",
 		    oc_getxid(sp->wrk, oc), EXP_Ttl(NULL, o) - t);
 		(void)HSH_Deref(sp->wrk, oc, NULL);
 	}
@@ -445,7 +445,7 @@ EXP_NukeOne(struct worker *wrk, struct lru *lru)
 		return (-1);
 
 	/* XXX: bad idea for -spersistent */
-	WSL(wrk, SLT_ExpKill, 0, "%u LRU", oc_getxid(wrk, oc));
+	WSL(wrk->vsl, SLT_ExpKill, 0, "%u LRU", oc_getxid(wrk, oc));
 	(void)HSH_Deref(wrk, oc, NULL);
 	return (1);
 }
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index c4c0718..018c4f9 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -439,7 +439,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
 	}
 
 	/* Checkpoint the vsl.here */
-	WSL_Flush(wrk, 0);
+	WSL_Flush(wrk->vsl, 0);
 
 	/* XXX is this the right place? */
 	VSC_C_main->backend_req++;
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index 9d81f62..2ee1abf 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -407,7 +407,7 @@ VGZ_Destroy(struct vgz **vgp, int vsl_id)
 		    (intmax_t)vg->vz.last_bit,
 		    (intmax_t)vg->vz.stop_bit);
 	else
-		WSL(vg->wrk, SLT_Gzip, vsl_id, "%s %jd %jd %jd %jd %jd",
+		WSL(vg->wrk->vsl, SLT_Gzip, vsl_id, "%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_hash.c b/bin/varnishd/cache/cache_hash.c
index c8cb6cc..b330c67 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -612,7 +612,7 @@ HSH_Unbusy(struct worker *wrk)
 	if (o->ws_o->overflow)
 		wrk->stats.n_objoverflow++;
 	if (cache_param->diag_bitmap & 0x40)
-		WSL(wrk, SLT_Debug, 0,
+		WSL(wrk->vsl, SLT_Debug, 0,
 		    "Object %u workspace free %u", o->xid, WS_Free(o->ws_o));
 
 	/* XXX: pretouch neighbors on oh->objcs to prevent page-on under mtx */
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index cdf95f1..314c05f 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -77,7 +77,7 @@ WSLH(struct worker *w, unsigned vsl_id, const struct http *hp, unsigned hdr)
 {
 
 	AN(vsl_id & (VSL_CLIENTMARKER|VSL_BACKENDMARKER));
-	WSLR(w, http2shmlog(hp, hdr), vsl_id, hp->hd[hdr]);
+	WSLR(w->vsl, http2shmlog(hp, hdr), vsl_id, hp->hd[hdr]);
 }
 
 /*--------------------------------------------------------------------*/
@@ -519,7 +519,7 @@ http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p,
 
 		if (q - p > htc->maxhdr) {
 			VSC_C_main->losthdr++;
-			WSL(w, SLT_LostHeader, vsl_id, "%.*s",
+			WSL(w->vsl, SLT_LostHeader, vsl_id, "%.*s",
 			    (int)(q - p > 20 ? 20 : q - p), p);
 			return (413);
 		}
@@ -545,7 +545,7 @@ http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p,
 			hp->nhd++;
 		} else {
 			VSC_C_main->losthdr++;
-			WSL(w, SLT_LostHeader, vsl_id, "%.*s",
+			WSL(w->vsl, SLT_LostHeader, vsl_id, "%.*s",
 			    (int)(q - p > 20 ? 20 : q - p), p);
 			return (413);
 		}
@@ -716,7 +716,7 @@ http_DissectResponse(struct worker *w, const struct http_conn *htc,
 	}
 
 	if (retval != 0) {
-		WSLR(w, SLT_HttpGarbage, htc->vsl_id, htc->rxbuf);
+		WSLR(w->vsl, SLT_HttpGarbage, htc->vsl_id, htc->rxbuf);
 		assert(retval >= 100 && retval <= 999);
 		hp->status = retval;
 	} else {
@@ -835,7 +835,7 @@ http_filterfields(struct worker *w, unsigned vsl_id, struct http *to,
 			to->nhd++;
 		} else  {
 			VSC_C_main->losthdr++;
-			WSLR(w, SLT_LostHeader, vsl_id, fm->hd[u]);
+			WSLR(w->vsl, SLT_LostHeader, vsl_id, fm->hd[u]);
 		}
 	}
 }
@@ -905,7 +905,7 @@ http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp)
 		} else {
 			/* XXX This leaves a slot empty */
 			VSC_C_main->losthdr++;
-			WSLR(w, SLT_LostHeader, vsl_id, hp->hd[u]);
+			WSLR(w->vsl, SLT_LostHeader, vsl_id, hp->hd[u]);
 			hp->hd[u].b = NULL;
 			hp->hd[u].e = NULL;
 		}
@@ -936,7 +936,7 @@ http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to,
 	CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
 	if (to->nhd >= to->shd) {
 		VSC_C_main->losthdr++;
-		WSL(w, SLT_LostHeader, vsl_id, "%s", hdr);
+		WSL(w->vsl, SLT_LostHeader, vsl_id, "%s", hdr);
 		return;
 	}
 	http_SetH(to, to->nhd++, hdr);
@@ -955,7 +955,7 @@ http_PutField(struct worker *w, unsigned vsl_id, const struct http *to,
 	l = strlen(string);
 	p = WS_Alloc(to->ws, l + 1);
 	if (p == NULL) {
-		WSL(w, SLT_LostHeader, vsl_id, "%s", string);
+		WSL(w->vsl, SLT_LostHeader, vsl_id, "%s", string);
 		to->hd[field].b = NULL;
 		to->hd[field].e = NULL;
 		to->hdf[field] = 0;
@@ -1011,7 +1011,7 @@ http_PrintfHeader(struct worker *w, unsigned vsl_id, struct http *to,
 	va_end(ap);
 	if (n + 1 >= l || to->nhd >= to->shd) {
 		VSC_C_main->losthdr++;
-		WSL(w, SLT_LostHeader, vsl_id, "%s", to->ws->f);
+		WSL(w->vsl, SLT_LostHeader, vsl_id, "%s", to->ws->f);
 		WS_Release(to->ws, 0);
 	} else {
 		to->hd[to->nhd].b = to->ws->f;
diff --git a/bin/varnishd/cache/cache_httpconn.c b/bin/varnishd/cache/cache_httpconn.c
index 1abd2a4..1a1eaf0 100644
--- a/bin/varnishd/cache/cache_httpconn.c
+++ b/bin/varnishd/cache/cache_httpconn.c
@@ -225,7 +225,7 @@ HTC_Read(struct worker *w, struct http_conn *htc, void *d, size_t len)
 		return (l);
 	i = read(htc->fd, p, len);
 	if (i < 0) {
-		WSL(w, SLT_FetchError, htc->vsl_id, "%s", strerror(errno));
+		WSL(w->vsl, SLT_FetchError, htc->vsl_id, "%s", strerror(errno));
 		return (i);
 	}
 	return (i + l);
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index ea0668b..196cead 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -156,7 +156,7 @@ ses_pool_task(struct worker *wrk, void *arg)
 	WS_Assert(wrk->aws);
 	AZ(wrk->busyobj);
 	AZ(wrk->wrw);
-	assert(wrk->wlp == wrk->wlb);
+	assert(wrk->vsl->wlp == wrk->vsl->wlb);
 	if (cache_param->diag_bitmap & 0x00040000) {
 		if (wrk->vcl != NULL)
 			VCL_Rel(&wrk->vcl);
diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c
index a839f5a..461aa97 100644
--- a/bin/varnishd/cache/cache_shmlog.c
+++ b/bin/varnishd/cache/cache_shmlog.c
@@ -180,30 +180,30 @@ VSL(enum VSL_tag_e tag, int id, const char *fmt, ...)
 /*--------------------------------------------------------------------*/
 
 void
-WSL_Flush(struct worker *wrk, int overflow)
+WSL_Flush(struct vsl_log *vsl, int overflow)
 {
 	uint32_t *p;
 	unsigned l;
 
-	l = pdiff(wrk->wlb, wrk->wlp);
+	l = pdiff(vsl->wlb, vsl->wlp);
 	if (l == 0)
 		return;
 
 	assert(l >= 8);
 
-	p = vsl_get(l - 8, wrk->wlr, overflow);
+	p = vsl_get(l - 8, vsl->wlr, overflow);
 
-	memcpy(p + 1, wrk->wlb + 1, l - 4);
+	memcpy(p + 1, vsl->wlb + 1, l - 4);
 	VWMB();
-	p[0] = wrk->wlb[0];
-	wrk->wlp = wrk->wlb;
-	wrk->wlr = 0;
+	p[0] = vsl->wlb[0];
+	vsl->wlp = vsl->wlb;
+	vsl->wlr = 0;
 }
 
 /*--------------------------------------------------------------------*/
 
 void
-WSLR(struct worker *wrk, enum VSL_tag_e tag, int id, txt t)
+WSLR(struct vsl_log *vsl, enum VSL_tag_e tag, int id, txt t)
 {
 	unsigned l, mlen;
 
@@ -217,29 +217,29 @@ WSLR(struct worker *wrk, enum VSL_tag_e tag, int id, txt t)
 		t.e = t.b + l;
 	}
 
-	assert(wrk->wlp < wrk->wle);
+	assert(vsl->wlp < vsl->wle);
 
 	/* Wrap if necessary */
-	if (VSL_END(wrk->wlp, l) >= wrk->wle)
-		WSL_Flush(wrk, 1);
-	assert (VSL_END(wrk->wlp, l) < wrk->wle);
-	memcpy(VSL_DATA(wrk->wlp), t.b, l);
-	vsl_hdr(tag, wrk->wlp, l, id);
-	wrk->wlp = VSL_END(wrk->wlp, l);
-	assert(wrk->wlp < wrk->wle);
-	wrk->wlr++;
+	if (VSL_END(vsl->wlp, l) >= vsl->wle)
+		WSL_Flush(vsl, 1);
+	assert (VSL_END(vsl->wlp, l) < vsl->wle);
+	memcpy(VSL_DATA(vsl->wlp), t.b, l);
+	vsl_hdr(tag, vsl->wlp, l, id);
+	vsl->wlp = VSL_END(vsl->wlp, l);
+	assert(vsl->wlp < vsl->wle);
+	vsl->wlr++;
 	if (cache_param->diag_bitmap & 0x10000)
-		WSL_Flush(wrk, 0);
+		WSL_Flush(vsl, 0);
 }
 
 /*--------------------------------------------------------------------*/
 
 static void
-wsl(struct worker *wrk, enum VSL_tag_e tag, int id, const char *fmt, va_list ap)
+wsl(struct vsl_log *, enum VSL_tag_e tag, int id, const char *fmt, va_list ap)
     __printflike(4, 0);
 
 static void
-wsl(struct worker *wrk, enum VSL_tag_e tag, int id, const char *fmt, va_list ap)
+wsl(struct vsl_log *vsl, enum VSL_tag_e tag, int id, const char *fmt, va_list ap)
 {
 	char *p;
 	unsigned n, mlen;
@@ -251,38 +251,37 @@ wsl(struct worker *wrk, enum VSL_tag_e tag, int id, const char *fmt, va_list ap)
 	if (strchr(fmt, '%') == NULL) {
 		t.b = TRUST_ME(fmt);
 		t.e = strchr(t.b, '\0');
-		WSLR(wrk, tag, id, t);
+		WSLR(vsl, tag, id, t);
 	} else {
-		assert(wrk->wlp < wrk->wle);
+		assert(vsl->wlp < vsl->wle);
 
 		/* Wrap if we cannot fit a full size record */
-		if (VSL_END(wrk->wlp, mlen) >= wrk->wle)
-			WSL_Flush(wrk, 1);
+		if (VSL_END(vsl->wlp, mlen) >= vsl->wle)
+			WSL_Flush(vsl, 1);
 
-		p = VSL_DATA(wrk->wlp);
+		p = VSL_DATA(vsl->wlp);
 		n = vsnprintf(p, mlen, fmt, ap);
 		if (n > mlen)
 			n = mlen;	/* we truncate long fields */
-		vsl_hdr(tag, wrk->wlp, n, id);
-		wrk->wlp = VSL_END(wrk->wlp, n);
-		assert(wrk->wlp < wrk->wle);
-		wrk->wlr++;
+		vsl_hdr(tag, vsl->wlp, n, id);
+		vsl->wlp = VSL_END(vsl->wlp, n);
+		assert(vsl->wlp < vsl->wle);
+		vsl->wlr++;
 	}
 	if (cache_param->diag_bitmap & 0x10000)
-		WSL_Flush(wrk, 0);
+		WSL_Flush(vsl, 0);
 }
 
 /*--------------------------------------------------------------------*/
 
 void
-WSL(struct worker *wrk, enum VSL_tag_e tag, int id, const char *fmt, ...)
+WSL(struct vsl_log *vsl, enum VSL_tag_e tag, int id, const char *fmt, ...)
 {
 	va_list ap;
 
-	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	AN(fmt);
 	va_start(ap, fmt);
-	wsl(wrk, tag, id, fmt, ap);
+	wsl(vsl, tag, id, fmt, ap);
 	va_end(ap);
 }
 
@@ -299,7 +298,7 @@ WSLB(struct worker *wrk, enum VSL_tag_e tag, const char *fmt, ...)
 	CHECK_OBJ_NOTNULL(wrk->busyobj->vbc, VBC_MAGIC);
 	AN(fmt);
 	va_start(ap, fmt);
-	wsl(wrk, tag, wrk->busyobj->vbc->vsl_id, fmt, ap);
+	wsl(wrk->vsl, tag, wrk->busyobj->vbc->vsl_id, fmt, ap);
 	va_end(ap);
 }
 
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 643f0a3..d69c7fb 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -56,7 +56,7 @@ VRT_error(const struct sess *sp, unsigned code, const char *reason)
 {
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	WSL(sp->wrk, SLT_Debug, 0, "VCL_error(%u, %s)", code, reason ?
+	WSL(sp->wrk->vsl, SLT_Debug, 0, "VCL_error(%u, %s)", code, reason ?
 	    reason : "(null)");
 	if (code < 100 || code > 999)
 		code = 503;
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index cc7fb5b..417fcee 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -55,7 +55,7 @@ vrt_do_string(struct worker *w, int fd, const struct http *hp, int fld,
 	AN(hp);
 	b = VRT_String(hp->ws, NULL, p, ap);
 	if (b == NULL || *b == '\0') {
-		WSL(w, SLT_LostHeader, fd, "%s", err);
+		WSL(w->vsl, SLT_LostHeader, fd, "%s", err);
 	} else {
 		http_SetH(hp, fld, b);
 	}
diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index 2f0b575..591e633 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -104,8 +104,8 @@ wrk_bgthread(void *arg)
 	memset(&wrk, 0, sizeof wrk);
 	sp->wrk = &wrk;
 	wrk.magic = WORKER_MAGIC;
-	wrk.wlp = wrk.wlb = logbuf;
-	wrk.wle = logbuf + (sizeof logbuf) / 4;
+	wrk.vsl->wlp = wrk.vsl->wlb = logbuf;
+	wrk.vsl->wle = logbuf + (sizeof logbuf) / 4;
 
 	(void)bt->func(sp, bt->priv);
 
@@ -142,8 +142,8 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned thread_workspace)
 	memset(w, 0, sizeof *w);
 	w->magic = WORKER_MAGIC;
 	w->lastused = NAN;
-	w->wlb = w->wlp = wlog;
-	w->wle = wlog + (sizeof wlog) / 4;
+	w->vsl->wlb = w->vsl->wlp = wlog;
+	w->vsl->wle = wlog + (sizeof wlog) / 4;
 	AZ(pthread_cond_init(&w->cond, NULL));
 
 	WS_Init(w->aws, "wrk", ws, thread_workspace);
diff --git a/bin/varnishd/cache/cache_wrw.c b/bin/varnishd/cache/cache_wrw.c
index 2c0d7c3..5c4b280 100644
--- a/bin/varnishd/cache/cache_wrw.c
+++ b/bin/varnishd/cache/cache_wrw.c
@@ -174,7 +174,7 @@ WRW_Flush(struct worker *wrk)
 
 			if (VTIM_real() - wrk->sp->req->t_resp >
 			    cache_param->send_timeout) {
-				WSL(wrk, SLT_Debug, *wrw->wfd,
+				WSL(wrk->vsl, SLT_Debug, *wrw->wfd,
 				    "Hit total send timeout, "
 				    "wrote = %zd/%zd; not retrying",
 				    i, wrw->liov);
@@ -182,7 +182,7 @@ WRW_Flush(struct worker *wrk)
 				break;
 			}
 
-			WSL(wrk, SLT_Debug, *wrw->wfd,
+			WSL(wrk->vsl, SLT_Debug, *wrw->wfd,
 			    "Hit send timeout, wrote = %zd/%zd; retrying",
 			    i, wrw->liov);
 
@@ -191,7 +191,7 @@ WRW_Flush(struct worker *wrk)
 		}
 		if (i <= 0) {
 			wrw->werr++;
-			WSL(wrk, SLT_Debug, *wrw->wfd,
+			WSL(wrk->vsl, SLT_Debug, *wrw->wfd,
 			    "Write error, retval = %zd, len = %zd, errno = %s",
 			    i, wrw->liov, strerror(errno));
 		}
diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index ccd45b1..22971a3 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -141,7 +141,7 @@ stv_pick_stevedore(struct worker *wrk, const char **hint)
 			return (stv_transient);
 
 		/* Hint was not valid, nuke it */
-		WSL(wrk, SLT_Debug, 0,			/* XXX VSL_id ?? */
+		WSL(wrk->vsl, SLT_Debug, 0,		/* XXX VSL_id ?? */
 		    "Storage hint not usable");
 		*hint = NULL;
 	}



More information about the varnish-commit mailing list