From 123183a61bec89ffcac75075879e87ed5e8b5298 Mon Sep 17 00:00:00 2001 From: Alexandru Matei Date: Thu, 11 Apr 2024 14:08:16 +0300 Subject: [PATCH] send all pending responses before shutting down The async implementation doesn't wait for responses to be sent to clients when shutting down. These responses are lost if the application exists fast enough before the write task gets to send them. That means that the response for a request that triggers shutdown of the server might be lost without the client knowing that the server was actually stopped. Signed-off-by: Alexandru Matei --- src/asynchronous/server.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/asynchronous/server.rs b/src/asynchronous/server.rs index ea1eb891..26c49f2c 100644 --- a/src/asynchronous/server.rs +++ b/src/asynchronous/server.rs @@ -327,13 +327,14 @@ impl Builder for ServerBuilder { server_shutdown: self.shutdown_waiter.clone(), handler_shutdown: disconnect_notifier, }, - ServerWriter { rx }, + ServerWriter { rx, _server_shutdown: self.shutdown_waiter.clone() }, ) } } struct ServerWriter { rx: MessageReceiver, + _server_shutdown: shutdown::Waiter } #[async_trait]