[master] 8df302401 Allow using the whole per thread log buffer

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Thu Dec 2 06:15:06 UTC 2021


commit 8df30240174b190db2601f4d64c28ee313eae486
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Wed Oct 4 15:24:10 2017 +0200

    Allow using the whole per thread log buffer
    
    The logics were off by one in the available buffer space checks,
    causing us to loose one word of per thread log buffer space, and
    making reasoning about available space tricky. Fix this.
    
    Refs 10749ffe2dacd7744ea94265cf751e5a341d3110
    Refs #3745

diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c
index 60187bc33..2e67bbd05 100644
--- a/bin/varnishd/cache/cache_shmlog.c
+++ b/bin/varnishd/cache/cache_shmlog.c
@@ -347,17 +347,17 @@ VSLbt(struct vsl_log *vsl, enum VSL_tag_e tag, txt t)
 	if (l > mlen - 1)
 		l = mlen - 1;
 
-	assert(vsl->wlp < vsl->wle);
+	assert(vsl->wlp <= vsl->wle);
 
 	/* Flush if necessary */
-	if (VSL_END(vsl->wlp, l + 1) >= vsl->wle)
+	if (VSL_END(vsl->wlp, l + 1) > vsl->wle)
 		VSL_Flush(vsl, 1);
-	assert(VSL_END(vsl->wlp, l + 1) < vsl->wle);
+	assert(VSL_END(vsl->wlp, l + 1) <= vsl->wle);
 	p = VSL_DATA(vsl->wlp);
 	memcpy(p, t.b, l);
 	p[l++] = '\0';		/* NUL-terminated */
 	vsl->wlp = vsl_hdr(tag, vsl->wlp, l, vsl->wid);
-	assert(vsl->wlp < vsl->wle);
+	assert(vsl->wlp <= vsl->wle);
 	vsl->wlr++;
 
 	if (DO_DEBUG(DBG_SYNCVSL))
@@ -531,16 +531,16 @@ VSLb_bin(struct vsl_log *vsl, enum VSL_tag_e tag, ssize_t len, const void *ptr)
 	/* Truncate */
 	len = vmin_t(ssize_t, len, mlen);
 
-	assert(vsl->wlp < vsl->wle);
+	assert(vsl->wlp <= vsl->wle);
 
 	/* Flush if necessary */
-	if (VSL_END(vsl->wlp, len) >= vsl->wle)
+	if (VSL_END(vsl->wlp, len) > vsl->wle)
 		VSL_Flush(vsl, 1);
-	assert(VSL_END(vsl->wlp, len) < vsl->wle);
+	assert(VSL_END(vsl->wlp, len) <= vsl->wle);
 	p = VSL_DATA(vsl->wlp);
 	memcpy(p, ptr, len);
 	vsl->wlp = vsl_hdr(tag, vsl->wlp, len, vsl->wid);
-	assert(vsl->wlp < vsl->wle);
+	assert(vsl->wlp <= vsl->wle);
 	vsl->wlr++;
 
 	if (DO_DEBUG(DBG_SYNCVSL))


More information about the varnish-commit mailing list