From 6786ce9e3357c8a7d7cdad9f87804c294b0515c9 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Mon, 4 Nov 2019 21:19:53 +0000 Subject: [PATCH] ws-over-h2: wrong sid on rst_stream rst_stream is almost always called from the h2 parser... in the case a ws-over-h2 is closing though, it can't reference the h2n parser sid context to get the sid to send... it's unrelated at that time. https://bugzilla.mozilla.org/show_bug.cgi?id=1590299 https://github.com/warmcat/libwebsockets/issues/1752 --- lib/roles/h2/http2.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/roles/h2/http2.c b/lib/roles/h2/http2.c index 46c254539..62ea29945 100644 --- a/lib/roles/h2/http2.c +++ b/lib/roles/h2/http2.c @@ -400,17 +400,19 @@ lws_h2_rst_stream(struct lws *wsi, uint32_t err, const char *reason) if (!h2n) return 0; - if (h2n->type == LWS_H2_FRAME_TYPE_COUNT) + if (!wsi->h2_stream_carries_ws && h2n->type == LWS_H2_FRAME_TYPE_COUNT) return 0; pps = lws_h2_new_pps(LWS_H2_PPS_RST_STREAM); if (!pps) return 1; - lwsl_info("%s: RST_STREAM 0x%x, REASON '%s'\n", __func__, err, reason); + lwsl_info("%s: RST_STREAM 0x%x, sid %d, REASON '%s'\n", __func__, err, + wsi->h2.my_sid, reason); - pps->u.rs.sid = h2n->sid; + pps->u.rs.sid = wsi->h2.my_sid; pps->u.rs.err = err; + lws_pps_schedule(wsi, pps); h2n->type = LWS_H2_FRAME_TYPE_COUNT; /* ie, IGNORE */