Skip to content

Commit

Permalink
BugFix: Send WindowUpdate when ClearAbandonedStreams is called (#1786)
Browse files Browse the repository at this point in the history
  • Loading branch information
zyearn authored Jun 9, 2022
1 parent 9556320 commit 4b80e95
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
13 changes: 3 additions & 10 deletions src/brpc/policy/http2_rpc_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,25 +372,18 @@ int H2Context::Init() {
return 0;
}

H2StreamContext* H2Context::RemoveStream(int stream_id) {
H2StreamContext* H2Context::RemoveStreamAndDeferWU(int stream_id) {
H2StreamContext* sctx = NULL;
{
std::unique_lock<butil::Mutex> mu(_stream_mutex);
if (!_pending_streams.erase(stream_id, &sctx)) {
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;
}

Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion src/brpc/policy/http2_rpc_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<H2StreamContext*>* out_streams);

H2StreamContext* FindStream(int stream_id);
Expand Down

0 comments on commit 4b80e95

Please sign in to comment.