From 4b80e9520130faaa209667a20e08de86da9e92d6 Mon Sep 17 00:00:00 2001 From: Jiashun Zhu Date: Thu, 9 Jun 2022 04:57:30 +0200 Subject: [PATCH] BugFix: Send WindowUpdate when ClearAbandonedStreams is called (#1786) --- src/brpc/policy/http2_rpc_protocol.cpp | 13 +++---------- src/brpc/policy/http2_rpc_protocol.h | 1 - 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/brpc/policy/http2_rpc_protocol.cpp b/src/brpc/policy/http2_rpc_protocol.cpp index ed57bcfe5f..ab14863c1f 100644 --- a/src/brpc/policy/http2_rpc_protocol.cpp +++ b/src/brpc/policy/http2_rpc_protocol.cpp @@ -372,7 +372,7 @@ int H2Context::Init() { return 0; } -H2StreamContext* H2Context::RemoveStream(int stream_id) { +H2StreamContext* H2Context::RemoveStreamAndDeferWU(int stream_id) { H2StreamContext* sctx = NULL; { std::unique_lock mu(_stream_mutex); @@ -380,17 +380,10 @@ H2StreamContext* H2Context::RemoveStream(int stream_id) { return NULL; } } - return sctx; -} - -H2StreamContext* H2Context::RemoveStreamAndDeferWU(int stream_id) { - H2StreamContext* sctx = RemoveStream(stream_id); // The remote stream will not send any more data, sending back the // stream-level WINDOW_UPDATE is pointless, just move the value into // the connection. - if (sctx) { - DeferWindowUpdate(sctx->ReleaseDeferredWindowUpdate()); - } + DeferWindowUpdate(sctx->ReleaseDeferredWindowUpdate()); return sctx; } @@ -1152,7 +1145,7 @@ inline void H2Context::ClearAbandonedStreams() { const uint32_t stream_id = _abandoned_streams.back(); _abandoned_streams.pop_back(); mu.unlock(); - H2StreamContext* sctx = RemoveStream(stream_id); + H2StreamContext* sctx = RemoveStreamAndDeferWU(stream_id); if (sctx != NULL) { delete sctx; } diff --git a/src/brpc/policy/http2_rpc_protocol.h b/src/brpc/policy/http2_rpc_protocol.h index 7e2061b442..b4422ee057 100644 --- a/src/brpc/policy/http2_rpc_protocol.h +++ b/src/brpc/policy/http2_rpc_protocol.h @@ -371,7 +371,6 @@ friend void InitFrameHandlers(); H2ParseResult OnContinuation(butil::IOBufBytesIterator&, const H2FrameHead&); H2StreamContext* RemoveStreamAndDeferWU(int stream_id); - H2StreamContext* RemoveStream(int stream_id); void RemoveGoAwayStreams(int goaway_stream_id, std::vector* out_streams); H2StreamContext* FindStream(int stream_id);