Skip to content

Commit

Permalink
Do not resume on failure
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Cattermole <[email protected]>
  • Loading branch information
adam-cattermole committed Dec 4, 2024
1 parent b9df081 commit c9cc4dc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
41 changes: 28 additions & 13 deletions src/filter/http_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ impl Filter {
}
}
}

fn process_next_op(&self) {
match self.operation_dispatcher.borrow_mut().next() {
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);
}
}
}
}

impl HttpContext for Filter {
Expand Down Expand Up @@ -134,21 +149,21 @@ impl Context for Filter {

match op_res {
Ok(operation) => {
if let Ok(result) = GrpcService::process_grpc_response(operation, resp_size) {
// add the response headers
self.response_headers_to_add.extend(result.response_headers);
// call the next op
match self.operation_dispatcher.borrow_mut().next() {
Ok(some_op) => {
if some_op.is_none() {
// No more operations left in queue, resuming
self.resume_http_request();
match GrpcService::process_grpc_response(Rc::clone(&operation), resp_size) {
Ok(result) => {
// add the response headers
self.response_headers_to_add.extend(result.response_headers);
// call the next op
self.process_next_op();
}
Err(_) => {
match operation.get_failure_mode() {
FailureMode::Deny => {}
FailureMode::Allow => {
// call the next op
self.process_next_op();
}
}
Err(op_err) => {
// If desired, we could check the error status.
GrpcService::handle_error_on_grpc_response(op_err.failure_mode);
}
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ impl GrpcService {
hostcalls::send_http_response(500, vec![], Some(b"Internal Server Error.\n"))
.expect("failed to send_http_response 500");
}
FailureMode::Allow => {
hostcalls::resume_http_request().expect("failed to resume_http_request")
}
FailureMode::Allow => {}
}
}
}
Expand Down

0 comments on commit c9cc4dc

Please sign in to comment.