[4.1] adb8de0 If the client workspace is almost, but not quite exhaused, we may not be able to get enough iovec's to do Chunked transmission.

PÃ¥l Hermunn Johansen hermunn at varnish-software.com
Mon Apr 3 14:18:06 CEST 2017


commit adb8de06f305aa21003a7e65aab0083e2216d89f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Mar 23 08:08:29 2017 +0000

    If the client workspace is almost, but not quite exhaused, we may
    not be able to get enough iovec's to do Chunked transmission.
    
    Fixes #2275
    
    And #2207 was probably misdiagnosed, but the fix is correct anyhow.
    
    Conflicts:
    	bin/varnishd/http1/cache_http1_line.c

diff --git a/bin/varnishd/http1/cache_http1_line.c b/bin/varnishd/http1/cache_http1_line.c
index 9f13543..a8e4f01 100644
--- a/bin/varnishd/http1/cache_http1_line.c
+++ b/bin/varnishd/http1/cache_http1_line.c
@@ -92,7 +92,8 @@ V1L_Reserve(struct worker *wrk, struct ws *ws, int *fd, struct vsl_log *vsl,
 	u = WS_Reserve(ws, 0);
 	u = PRNDDN(u);
 	u /= sizeof(struct iovec);
-	if (u == 0) {
+	if (u < 3) {
+		/* Must have at least 3 in case of chunked encoding */
 		WS_Release(ws, 0);
 		WS_MarkOverflow(ws);
 		return;
@@ -264,6 +265,7 @@ V1L_Chunked(const struct worker *wrk)
 	CHECK_OBJ_NOTNULL(v1l, V1L_MAGIC);
 
 	assert(v1l->ciov == v1l->siov);
+	assert(v1l->siov >= 3);
 	/*
 	 * If there are not space for chunked header, a chunk of data and
 	 * a chunk tail, we might as well flush right away.
diff --git a/bin/varnishtest/tests/c00071.vtc b/bin/varnishtest/tests/c00071.vtc
index e281c90..b6c9947 100644
--- a/bin/varnishtest/tests/c00071.vtc
+++ b/bin/varnishtest/tests/c00071.vtc
@@ -14,7 +14,7 @@ server s1 {
 varnish v1 -vcl+backend {
 	import ${vmod_debug};
 	sub vcl_deliver {
-		debug.workspace_allocate(client, debug.workspace_free(client) - 160);
+		debug.workspace_allocate(client, debug.workspace_free(client) - 208);
 
 		if (req.url ~ "/bar") {
 			set resp.http.x-foo = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";



More information about the varnish-commit mailing list