[master] 5ead7c5 Dont panic because a housekeeping thread races against orderly shutdown.

Poul-Henning Kamp phk at FreeBSD.org
Mon Feb 8 11:33:30 CET 2016


commit 5ead7c5151f9717f0ab442e544f3fd9bc29a4571
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Feb 8 10:32:56 2016 +0000

    Dont panic because a housekeeping thread races against orderly
    shutdown.

diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c
index de768f2..6a2f1d4 100644
--- a/bin/varnishd/cache/cache_acceptor.c
+++ b/bin/varnishd/cache/cache_acceptor.c
@@ -506,8 +506,12 @@ vca_acct(void *arg)
 	while (1) {
 		(void)sleep(1);
 		if (vca_tcp_opt_init()) {
-			VTAILQ_FOREACH(ls, &heritage.socks, list)
+			VTAILQ_FOREACH(ls, &heritage.socks, list) {
+				if (ls->sock == -2)
+					continue;	// raced VCA_Shutdown
+				assert (ls->sock > 0);
 				vca_tcp_opt_set(ls->sock, 1);
+			}
 		}
 		now = VTIM_real();
 		VSC_C_main->uptime = (uint64_t)(now - t0);
@@ -581,7 +585,7 @@ VCA_Shutdown(void)
 
 	VTAILQ_FOREACH(ls, &heritage.socks, list) {
 		i = ls->sock;
-		ls->sock = -1;
+		ls->sock = -2;
 		(void)close(i);
 	}
 }



More information about the varnish-commit mailing list