Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BugFix: Send WindowUpdate when ClearAbandonedStreams is called #1786

Merged
merged 1 commit into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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