[master] f0b50447e Release wrk->vcl before (potentially) long-running worker jobs which do not need it (acceptor, h2_sess)

Poul-Henning Kamp phk at FreeBSD.org
Mon Dec 10 09:45:16 UTC 2018


commit f0b50447e14cc496acf9cbcf719c56baf087d4f6
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Dec 10 09:22:04 2018 +0000

    Release wrk->vcl before (potentially) long-running worker jobs which do
    not need it (acceptor, h2_sess)

diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c
index 3874ac70d..ba4e84be9 100644
--- a/bin/varnishd/cache/cache_acceptor.c
+++ b/bin/varnishd/cache/cache_acceptor.c
@@ -460,6 +460,10 @@ vca_accept_task(struct worker *wrk, void *arg)
 	while (!pool_accepting)
 		VTIM_sleep(.1);
 
+	/* Dont hold on to (possibly) discarded VCLs */
+	if (wrk->vcl != NULL)
+		VCL_Rel(&wrk->vcl);
+
 	while (!ps->pool->die) {
 		INIT_OBJ(&wa, WRK_ACCEPT_MAGIC);
 		wa.acceptlsock = ls;
@@ -547,12 +551,6 @@ vca_accept_task(struct worker *wrk, void *arg)
 		if (!ps->pool->die && DO_DEBUG(DBG_SLOW_ACCEPTOR))
 			VTIM_sleep(2.0);
 
-		/*
-		 * We were able to hand off, so release this threads VCL
-		 * reference (if any) so we don't hold on to discarded VCLs.
-		 */
-		if (wrk->vcl != NULL)
-			VCL_Rel(&wrk->vcl);
 	}
 }
 
diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c
index 932a5b93f..8828c146e 100644
--- a/bin/varnishd/http2/cache_http2_session.c
+++ b/bin/varnishd/http2/cache_http2_session.c
@@ -344,6 +344,9 @@ h2_new_session(struct worker *wrk, void *arg)
 	sp = req->sp;
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 
+	if (wrk->vcl)
+		VCL_Rel(&wrk->vcl);
+
 	assert(req->transport == &H2_transport);
 
 	assert (req->err_code == H2_PU_MARKER || req->err_code == H2_OU_MARKER);


More information about the varnish-commit mailing list