BUG/MEDIUM: proxy: Make sure to destroy the stream on upgrade from TCP to H2
In stream_set_backend(), if we have a TCP stream, and we want to upgrade it
to H2 instead of attempting ot reuse the stream, just destroy the
conn_stream, make sure we don't log anything about the stream, and pretend
we failed setting the backend, so that the stream will get destroyed.
New streams will then be created by the mux, as if the connection just
happened.
This fixes a crash when upgrading from TCP to H2, as the H2 mux totally
ignored the conn_stream provided by the upgrade, as reported in github
issue #196.
This should be backported to 2.0.
(cherry picked from commit 4c18f94c11b11e4a4923892ed0fa72385ec1eb08)
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/src/proxy.c b/src/proxy.c
index a537e0b..871d6e1 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -1484,7 +1484,20 @@
&s->si[0].wait_event);
if (conn_upgrade_mux_fe(conn, cs, &s->req.buf, ist(""), PROTO_MODE_HTX) == -1)
return 0;
- s->flags |= SF_HTX;
+ if (!strcmp(conn->mux->name, "H2")) {
+ /* For HTTP/2, destroy the conn_stream,
+ * disable logging, and pretend that we
+ * failed, to that the stream is
+ * silently destroyed. The new mux
+ * will create new streams.
+ */
+ cs_destroy(cs);
+ si_detach_endpoint(&s->si[0]);
+ s->logs.logwait = 0;
+ s->logs.level = 0;
+ s->flags |= SF_IGNORE;
+ return 0;
+ }
}
}