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

Poul-Henning Kamp phk at FreeBSD.org
Thu Mar 23 09:10:07 CET 2017


commit 8e77985261fa4bef963a0e55b7d7392d75e93c2e
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.

diff --git a/bin/varnishd/http1/cache_http1_line.c b/bin/varnishd/http1/cache_http1_line.c
index 2565b05..5f102b0 100644
--- a/bin/varnishd/http1/cache_http1_line.c
+++ b/bin/varnishd/http1/cache_http1_line.c
@@ -89,7 +89,8 @@ V1L_Reserve(struct worker *wrk, struct ws *ws, int *fd, struct vsl_log *vsl,
 	v1l->res = res;
 
 	u = WS_ReserveLumps(ws, 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;
@@ -262,6 +263,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 50574df..a168eb8 100644
--- a/bin/varnishtest/tests/c00071.vtc
+++ b/bin/varnishtest/tests/c00071.vtc
@@ -14,7 +14,7 @@ server s1 {
 varnish v1 -vcl+backend {
 	import 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