Skip to content

Commit a84caf7

Browse files
irudoySomethingNew71
authored andcommitted
fix(ipc): drop non-blocking accept busy-poll in listener loop
The IPC server set the listener to non-blocking and slept 100 ms between WouldBlock errors. There is no shutdown signal feeding the loop, so the non-blocking pattern only added up to ~100 ms of latency before each accepted connection plus continuous busy-poll wakeups. Switching to blocking accept removes the latency and the wakeups, and restores deterministic ordering for the in-tree IPC integration tests that previously flaked under cargo test parallelism (the listener could be mid-sleep when a connection arrived, pushing command delivery past the test's 2 s polling window).
1 parent d0cbc1b commit a84caf7

1 file changed

Lines changed: 0 additions & 9 deletions

File tree

src/ipc/server.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ impl IpcServer {
3232
let listener = TcpListener::bind(format!("127.0.0.1:{}", port))
3333
.map_err(|e| format!("Failed to bind to port {}: {}", port, e))?;
3434

35-
// Set non-blocking so we can check for shutdown
36-
listener
37-
.set_nonblocking(true)
38-
.map_err(|e| format!("Failed to set non-blocking: {}", e))?;
39-
4035
let (command_tx, command_rx) = mpsc::channel();
4136

4237
// Spawn the listener thread
@@ -79,10 +74,6 @@ impl IpcServer {
7974
Self::handle_connection(stream, tx);
8075
});
8176
}
82-
Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => {
83-
// No connection available, sleep briefly
84-
thread::sleep(std::time::Duration::from_millis(100));
85-
}
8677
Err(e) => {
8778
tracing::error!("Error accepting connection: {}", e);
8879
thread::sleep(std::time::Duration::from_millis(100));

0 commit comments

Comments
 (0)