[3.0] 3993225 Initialize nthr_max on startup to avoid a race between wrk_herder_thread and wrk_herdtimer_thread causing bogus n_wrk_max stat increments.

Martin Blix Grydeland martin at varnish-cache.org
Wed Aug 15 14:00:45 CEST 2012


commit 3993225fd998ebdf8e03d18105a7da65c3a83d8a
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Wed Aug 15 13:51:40 2012 +0200

    Initialize nthr_max on startup to avoid a race between
    wrk_herder_thread and wrk_herdtimer_thread causing bogus n_wrk_max
    stat increments.
    
    Fixes: #1183

diff --git a/bin/varnishd/cache_pool.c b/bin/varnishd/cache_pool.c
index 14679a5..3c13d69 100644
--- a/bin/varnishd/cache_pool.c
+++ b/bin/varnishd/cache_pool.c
@@ -593,6 +593,10 @@ WRK_Init(void)
 	Lck_New(&herder_mtx, lck_herder);
 	Lck_New(&wstat_mtx, lck_wstat);
 
+	nthr_max = params->wthread_max;
+	if (nthr_max < params->wthread_min)
+		nthr_max = params->wthread_min;
+
 	wrk_addpools(params->wthread_pools);
 	AZ(pthread_create(&tp, NULL, wrk_herdtimer_thread, NULL));
 	AZ(pthread_detach(tp));



More information about the varnish-commit mailing list