[master] 03f71c6e6 h2: Reset the stream upon delivery error

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Wed Feb 24 12:18:07 UTC 2021


commit 03f71c6e6dae1340ea7ed080306a6d6c2b8bb56d
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Tue Feb 23 19:16:17 2021 +0100

    h2: Reset the stream upon delivery error
    
    Until now we'd send a zero-length DATA frame with the END_STREAM flag
    set, masquerading fetch streaming failures as completed responses. In
    the absence of a content-length header a user agent couldn't notice
    there was a problem.
    
    This does not apply to ESI sub-requests, they aren't streamed during
    delivery.

diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c
index ffcee5827..a73c9943d 100644
--- a/bin/varnishd/http2/cache_http2_deliver.c
+++ b/bin/varnishd/http2/cache_http2_deliver.c
@@ -95,6 +95,14 @@ h2_fini(struct vdp_ctx *vdc, void **priv)
 	if (r2->error)
 		return (0);
 
+	if (vdc->retval) {
+		r2->error = H2SE_INTERNAL_ERROR; /* XXX: proper error? */
+		H2_Send_Get(vdc->wrk, r2->h2sess, r2);
+		H2_Send_RST(vdc->wrk, r2->h2sess, r2, r2->stream, r2->error);
+		H2_Send_Rel(r2->h2sess, r2);
+		return (0);
+	}
+
 	H2_Send_Get(vdc->wrk, r2->h2sess, r2);
 	H2_Send(vdc->wrk, r2, H2_F_DATA, H2FF_DATA_END_STREAM, 0, "", NULL);
 	H2_Send_Rel(r2->h2sess, r2);
diff --git a/bin/varnishtest/tests/r02258.vtc b/bin/varnishtest/tests/r02258.vtc
index 097682c88..552b1b47e 100644
--- a/bin/varnishtest/tests/r02258.vtc
+++ b/bin/varnishtest/tests/r02258.vtc
@@ -23,29 +23,23 @@ client c1 {
 	expect_close
 } -run
 
-delay .3
+varnish v1 -expect MAIN.sc_range_short == 1
 
-server s1 {
-	rxreq
-	txresp -nolen -hdr "Content-length: 9"
-	delay 1
-	send "BLA"
-	delay .4
-	send "BLA"
-	delay .3
-	send "BL"
-} -start
+delay .3
 
 varnish v1 -cliok "param.set feature +http2"
 
-client c1 {
+server s1 -start
+
+client c2 {
 	stream 1 {
 		txreq -hdr "range" "bytes=0-16"
 		rxhdrs
 		expect resp.status == 206
 		expect resp.http.content-length == 9
-		rxdata -all
+		rxdata -some 3
+		expect resp.body == BLABLABL
+		rxrst
+		expect rst.err == INTERNAL_ERROR
 	} -run
 } -run
-
-varnish v1 -expect MAIN.sc_range_short == 1


More information about the varnish-commit mailing list