[3.0] 1a45246 Fix the boundary detection code in vsl.c, slightly more paranoid than DocWilcos proposed fix in #956
Tollef Fog Heen
tfheen at varnish-cache.org
Wed Aug 17 11:26:46 CEST 2011
commit 1a45246bc76d1830fa162bf4a2800cba06589e5d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Aug 8 12:34:38 2011 +0000
Fix the boundary detection code in vsl.c, slightly more paranoid than
DocWilcos proposed fix in #956
diff --git a/lib/libvarnishapi/vsl.c b/lib/libvarnishapi/vsl.c
index 95e8cae..cc1fc0b 100644
--- a/lib/libvarnishapi/vsl.c
+++ b/lib/libvarnishapi/vsl.c
@@ -173,20 +173,30 @@ vsl_nextlog(struct vsl *vsl, uint32_t **pp)
for (w = 0; w < TIMEOUT_USEC;) {
t = *vsl->log_ptr;
- if (t == VSL_WRAPMARKER ||
- (t == VSL_ENDMARKER && vsl->last_seq != vsl->log_start[0])) {
+ if (t == VSL_WRAPMARKER) {
+ /* Wrap around not possible at front */
+ assert(vsl->log_ptr != vsl->log_start + 1);
vsl->log_ptr = vsl->log_start + 1;
- vsl->last_seq = vsl->log_start[0];
VRMB();
continue;
- }
+ }
if (t == VSL_ENDMARKER) {
+ if (vsl->log_ptr != vsl->log_start + 1 &&
+ vsl->last_seq != vsl->log_start[0]) {
+ /* ENDMARKER not at front and seq wrapped */
+ vsl->log_ptr = vsl->log_start + 1;
+ VRMB();
+ continue;
+ }
if (vsl->flags & F_NON_BLOCKING)
return (-1);
w += SLEEP_USEC;
assert(usleep(SLEEP_USEC) == 0 || errno == EINTR);
continue;
}
+ if (vsl->log_ptr == vsl->log_start + 1)
+ vsl->last_seq = vsl->log_start[0];
+
*pp = (void*)(uintptr_t)vsl->log_ptr; /* Loose volatile */
vsl->log_ptr = VSL_NEXT(vsl->log_ptr);
return (1);
More information about the varnish-commit
mailing list