Skip to content

Commit

Permalink
send all pending responses before shutting down
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
alex-matei committed May 7, 2024
1 parent 44b31f7 commit 123183a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/asynchronous/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 123183a

Please sign in to comment.