[master] acd2198 Fix race in the VSL segment counter initialization
Martin Blix Grydeland
martin at varnish-software.com
Tue Mar 7 17:18:06 CET 2017
commit acd219844d551883507829984964ad880db27fef
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Tue Mar 7 17:13:26 2017 +0100
Fix race in the VSL segment counter initialization
Fix a stupid misstake where the segment counter in the VSL segment was
set just before the entire struct was cleared during
initialization. This didn't cause problems in the common case because
it would be set correctly on the very first log line produced. But it
did open a race where an unfortunate early log client would assume it
was lagging indefinetely behind varnishd on the log reading and report
overflow error. This was most commonly experienced with varnishtest.
Fixes: #2241
diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c
index d8e3c7d..66fac59 100644
--- a/bin/varnishd/cache/cache_shmlog.c
+++ b/bin/varnishd/cache/cache_shmlog.c
@@ -507,13 +507,13 @@ VSM_Init(void)
problems with regard to readers on that event visible */
vsl_segment_n = UINT_MAX - (VSL_SEGMENTS - 1);
AZ(vsl_segment_n % VSL_SEGMENTS);
- vsl_head->segment_n = vsl_segment_n;
vsl_ptr = vsl_head->log;
*vsl_ptr = VSL_ENDMARKER;
memset(vsl_head, 0, sizeof *vsl_head);
vsl_head->segsize = vsl_segsize;
vsl_head->offset[0] = 0;
+ vsl_head->segment_n = vsl_segment_n;
for (i = 1; i < VSL_SEGMENTS; i++)
vsl_head->offset[i] = -1;
VWMB();
More information about the varnish-commit
mailing list