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(stream): fix crash when peer send reset stream frame but has no error code #82

Merged
merged 1 commit into from
Nov 21, 2023
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
6 changes: 5 additions & 1 deletion trpc/stream/trpc/trpc_client_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,12 @@ RetCode TrpcClientStream::HandleClose(StreamRecvMessage&& msg) {
// Close (RESET) due to an exception, so there is no need to check the stream status.
// Notify the business that the stream has failed.
SetState(State::kClosed);
if (status.OK()) {
// Normally, the reset frame will carry error code. But if it doesn't exist, we add an unknown error.
status.SetFrameworkRetCode(TrpcRetCode::TRPC_STREAM_UNKNOWN_ERR);
status.SetErrorMessage("stream reset recive, but unable to get error message");
}
OnError(status);
std::cout << "stream error occurs" << std::endl;
return RetCode::kError;
}

Expand Down
5 changes: 5 additions & 0 deletions trpc/stream/trpc/trpc_server_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ RetCode TrpcServerStream::HandleClose(StreamRecvMessage&& msg) {
if (reset) {
// When closing (RESET) due to an exception, there is no need to check the stream state.
SetState(State::kClosed);
if (status.OK()) {
// Normally, the reset frame will carry error code. But if it doesn't exist, we add an unknown error.
status.SetFrameworkRetCode(TrpcRetCode::TRPC_STREAM_UNKNOWN_ERR);
status.SetErrorMessage("stream reset recive, but unable to get error message");
}
OnError(status);
return RetCode::kError;
}
Expand Down