[master] a6696fc Fix an off-by one causing extremely rare asserts: We must have two free slots, one for the data we want to write and one for the end of chunk bits.

Poul-Henning Kamp phk at FreeBSD.org
Wed Feb 15 15:03:05 CET 2017


commit a6696fc0813c8a8c1519a4ebceea25720f8f7836
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Feb 15 13:58:34 2017 +0000

    Fix an off-by one causing extremely rare asserts:  We must have two
    free slots, one for the data we want to write and one for the
    end of chunk bits.
    
    Fixes: #2207

diff --git a/bin/varnishd/http1/cache_http1_line.c b/bin/varnishd/http1/cache_http1_line.c
index a1b7537..2565b05 100644
--- a/bin/varnishd/http1/cache_http1_line.c
+++ b/bin/varnishd/http1/cache_http1_line.c
@@ -239,7 +239,7 @@ V1L_Write(const struct worker *wrk, const void *ptr, ssize_t len)
 		return (0);
 	if (len == -1)
 		len = strlen(ptr);
-	if (v1l->niov >= v1l->siov - (v1l->ciov < v1l->siov ? 1 : 0))
+	if (v1l->niov >= v1l->siov - (v1l->ciov < v1l->siov ? 2 : 0))
 		(void)V1L_Flush(wrk);
 	v1l->iov[v1l->niov].iov_base = TRUST_ME(ptr);
 	v1l->iov[v1l->niov].iov_len = len;



More information about the varnish-commit mailing list