Skip to content

Commit

Permalink
ext_proc: switch the order of onFinishProcessorCalls and `closeStre…
Browse files Browse the repository at this point in the history
…am` (#29789)



Signed-off-by: tyxia <[email protected]>
  • Loading branch information
tyxia authored Sep 25, 2023
1 parent 6092cdc commit bb132d2
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions source/extensions/filters/http/ext_proc/ext_proc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -663,14 +663,9 @@ void Filter::onReceiveMessage(std::unique_ptr<ProcessingResponse>&& r) {
// We won't be sending anything more to the stream after we
// receive this message.
ENVOY_LOG(debug, "Sending immediate response");
// TODO(tyxia) For immediate response case here and below, logging is needed because
// `onFinishProcessorCalls` is called after `closeStream` below.
// Investigate to see if we can switch the order of those two so that the logging here can be
// avoided.
logGrpcStreamInfo();
processing_complete_ = true;
closeStream();
onFinishProcessorCalls(Grpc::Status::Ok);
closeStream();
sendImmediateResponse(response->immediate_response());
processing_status = absl::OkStatus();
}
Expand Down Expand Up @@ -703,9 +698,8 @@ void Filter::onReceiveMessage(std::unique_ptr<ProcessingResponse>&& r) {
ENVOY_LOG(debug, "Sending immediate response: {}", processing_status.message());
stats_.stream_msgs_received_.inc();
processing_complete_ = true;
logGrpcStreamInfo();
closeStream();
onFinishProcessorCalls(processing_status.raw_code());
closeStream();
ImmediateResponse invalid_mutation_response;
invalid_mutation_response.mutable_status()->set_code(StatusCode::InternalServerError);
invalid_mutation_response.set_details(std::string(processing_status.message()));
Expand All @@ -728,10 +722,10 @@ void Filter::onGrpcError(Grpc::Status::GrpcStatus status) {

} else {
processing_complete_ = true;
closeStream();
// Since the stream failed, there is no need to handle timeouts, so
// make sure that they do not fire now.
onFinishProcessorCalls(status);
closeStream();
ImmediateResponse errorResponse;
errorResponse.mutable_status()->set_code(StatusCode::InternalServerError);
errorResponse.set_details(absl::StrFormat("%s_gRPC_error_%i", ErrorPrefix, status));
Expand Down

0 comments on commit bb132d2

Please sign in to comment.