From 0f0ed1f80c37eb2ff0c2611e3d0654f9b7e418a9 Mon Sep 17 00:00:00 2001 From: Emmanuel Bosquet Date: Tue, 12 Dec 2023 09:53:44 +0100 Subject: [PATCH] workers return only one response when dispatching a request --- command/src/response.rs | 4 ++++ lib/src/server.rs | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/command/src/response.rs b/command/src/response.rs index eb6ed6992..c60d3e0f7 100644 --- a/command/src/response.rs +++ b/command/src/response.rs @@ -294,6 +294,10 @@ impl WorkerResponse { content: None, } } + + pub fn is_failure(&self) -> bool { + self.status == ResponseStatus::Failure + } } impl fmt::Display for WorkerResponse { diff --git a/lib/src/server.rs b/lib/src/server.rs index c6f534735..5431d3c78 100644 --- a/lib/src/server.rs +++ b/lib/src/server.rs @@ -982,14 +982,24 @@ impl Server { }; let proxy_destinations = request.content.get_destinations(); + let mut notify_response = None; if proxy_destinations.to_http_proxy { - push_queue(self.http.borrow_mut().notify(request.clone())); + notify_response = Some(self.http.borrow_mut().notify(request.clone())); } if proxy_destinations.to_https_proxy { - push_queue(self.https.borrow_mut().notify(request.clone())); + let http_proxy_response = self.https.borrow_mut().notify(request.clone()); + if http_proxy_response.is_failure() || notify_response.is_none() { + notify_response = Some(http_proxy_response); + } } if proxy_destinations.to_tcp_proxy { - push_queue(self.tcp.borrow_mut().notify(request.clone())); + let tcp_proxy_response = self.tcp.borrow_mut().notify(request.clone()); + if tcp_proxy_response.is_failure() || notify_response.is_none() { + notify_response = Some(tcp_proxy_response); + } + } + if let Some(response) = notify_response { + push_queue(response); } match request.content.request_type {