Skip to content

Commit 422a181

Browse files
committed
Addresses a race condition as reported and identified in #226 by using the peer address as given by tokio instead of querying it after the socket was maybe already shut down
1 parent ed78d80 commit 422a181

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

russh/src/server/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,11 +869,12 @@ pub trait Server {
869869
},
870870
accept_result = socket.accept() => {
871871
match accept_result {
872-
Ok((socket, _)) => {
872+
Ok((socket, peer_addr)) => {
873873
let mut shutdown_rx = shutdown_tx2.subscribe();
874874

875875
let config = config.clone();
876-
let handler = self.new_client(socket.peer_addr().ok());
876+
// NOTE: For backwards compatibility, we keep the Option signature as changing it would be a breaking change.
877+
let handler = self.new_client(Some(peer_addr));
877878
let error_tx = error_tx.clone();
878879

879880
russh_util::runtime::spawn(async move {

0 commit comments

Comments
 (0)