From 06f654fc4a47264e4b0f860d4bdf351943af4795 Mon Sep 17 00:00:00 2001 From: dd di cesare Date: Thu, 31 Oct 2024 08:33:45 +0100 Subject: [PATCH] [refactor] Fixing flow of http request on grpc response Signed-off-by: dd di cesare --- src/filter/http_context.rs | 8 ++++++-- src/service.rs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/filter/http_context.rs b/src/filter/http_context.rs index 27d3c85..ec3d4af 100644 --- a/src/filter/http_context.rs +++ b/src/filter/http_context.rs @@ -133,13 +133,17 @@ impl Context for Filter { if GrpcService::process_grpc_response(operation, resp_size).is_ok() { // call the next op match self.operation_dispatcher.borrow_mut().next() { - Ok(_) => {} // no action needed + Ok(some_op) => { + if some_op.is_none() { + // No more operations left in queue, resuming + self.resume_http_request(); + } + } Err(op_err) => { // If desired, we could check the error status. GrpcService::handle_error_on_grpc_response(op_err.failure_mode); } } - self.resume_http_request(); } } Err(e) => { diff --git a/src/service.rs b/src/service.rs index e84d9a7..575281a 100644 --- a/src/service.rs +++ b/src/service.rs @@ -85,7 +85,7 @@ impl GrpcService { match failure_mode { FailureMode::Deny => { hostcalls::send_http_response(500, vec![], Some(b"Internal Server Error.\n")) - .unwrap() + .unwrap(); } FailureMode::Allow => hostcalls::resume_http_request().unwrap(), }