Skip to content

Commit df129ea

Browse files
server: disconnect lightway in case of TCP shutdown or other fatal failures.
Note that it is possible, disconnect has been called in `conn.handle_outside_data_error` already in case of fatal error case. It is still fine to call it again, since `disconnect` call is idempotent and no-op if it is already disconnected But we need this disconnect in case of TCP connection shutdown. Otherwise Server::Connection will be leaking.
1 parent 4fa7bae commit df129ea

File tree

1 file changed

+9
-0
lines changed
  • lightway-server/src/io/outside

1 file changed

+9
-0
lines changed

lightway-server/src/io/outside/tcp.rs

+9
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,15 @@ async fn handle_connection(
171171
}
172172
};
173173

174+
// Disconnect the session in case of TCP shutdown or other fatal failures.
175+
//
176+
// Note that it is possible, disconnect has been called in `conn.handle_outside_data_error` already
177+
// in case of fatal error case. It is still fine to call it again, since `disconnect`
178+
// call is idempotent and no-op if it is already disconnected
179+
//
180+
// But we need this disconnect in case of TCP connection shutdown
181+
let _ = conn.disconnect();
182+
174183
info!("Connection closed: {:?}", err);
175184
}
176185

0 commit comments

Comments
 (0)