From b4935701a831a4d351f4d1ad035fd30a483c7048 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 31 Oct 2026 15:07:23 -0700 Subject: [PATCH] revert: the 1 s write timeout on subscriber sockets Reverts 4bdda86f. A write timeout can deliver a truncated JSON document: part of the notification is written, the write then fails with TimedOut, and the subscriber, which stays subscribed, reads the prefix followed by the next notification. It also does not bound the stall: nothing evicts the subscriber (each push to it waits another second under the window manager lock), the connect has no timeout (uds_windows offers none), and that Winsock honours SO_SNDTIMEO on AF_UNIX sockets is unverified. The transport change and the Windows connect closure are both reverted, including the skip-on-timeout test (the connect parameter of notify_sockets was already there and is unchanged). Follow-up, not done: an eviction policy for a subscriber that does not take a notification, together with a timeout that was verified on Windows (or a non-blocking write with a per-subscriber queue). Decision D-coord-10. Behaviour is back to cand4's predecessor (no timeout). Verified: tools/fast-check (native, Windows clippy -D warnings) PASS; e2e not needed beyond commands. --- crates/komorebi-transport/src/subscribers.rs | 55 +------------------- komorebi/src/lib.rs | 10 +--- 2 files changed, 3 insertions(+), 62 deletions(-) diff --git a/crates/komorebi-transport/src/subscribers.rs b/crates/komorebi-transport/src/subscribers.rs index 8ee004c1..6d131c5b 100644 --- a/crates/komorebi-transport/src/subscribers.rs +++ b/crates/komorebi-transport/src/subscribers.rs @@ -43,23 +43,7 @@ pub fn notify_sockets( match connect(path) { Ok(mut stream) => { tracing::debug!(target: LOG_TARGET, "pushed notification to subscriber: {socket}"); - match stream.write_all(notification.as_bytes()) { - Ok(()) => {} - // a subscriber that does not read (the stream has a write timeout) - // is skipped, so that it cannot hold up the one that is pushing - Err(error) - if matches!( - error.kind(), - std::io::ErrorKind::TimedOut | std::io::ErrorKind::WouldBlock - ) => - { - tracing::warn!( - target: LOG_TARGET, - "subscriber {socket} did not take the notification in time: {error}" - ); - } - Err(error) => return Err(error), - } + stream.write_all(notification.as_bytes())?; } Err(_) => { stale_sockets.push(socket.clone()); @@ -148,41 +132,4 @@ mod tests { assert!(live.accept().is_ok()); let _ = std::fs::remove_dir_all(&dir); } - - /// A stream whose write times out, as one with a write timeout does when nobody reads it - struct Stuck; - - impl Write for Stuck { - fn write(&mut self, _: &[u8]) -> std::io::Result { - Err(std::io::ErrorKind::TimedOut.into()) - } - - fn flush(&mut self) -> std::io::Result<()> { - Ok(()) - } - } - - #[test] - fn a_subscriber_that_times_out_is_skipped_and_stays_subscribed() { - let dir = dir("timeout"); - let mut sockets = HashMap::from([ - ("a.sock".to_string(), dir.join("a.sock")), - ("b.sock".to_string(), dir.join("b.sock")), - ]); - let pushed = std::cell::Cell::new(0); - - let result = notify_sockets("{}", &mut sockets, &HashMap::new(), false, &dir, |_| { - pushed.set(pushed.get() + 1); - Ok(Stuck) - }); - - assert!(result.is_ok()); - assert_eq!( - pushed.get(), - 2, - "the subscribers after the stuck one are tried" - ); - assert_eq!(sockets.len(), 2, "a slow subscriber is not removed"); - let _ = std::fs::remove_dir_all(&dir); - } } diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 981483a3..28cc2814 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -15,13 +15,13 @@ pub mod focus_manager; pub mod live_resize; pub use komorebi_collections::Lockable; pub use komorebi_collections::lockable_sequence; -pub mod lock_holder; pub mod monitor; pub mod monitor_reconciliator; pub mod pan; pub mod process_command; pub mod process_event; pub mod process_movement; +pub mod lock_holder; pub mod reaper; pub mod scrolling; pub mod set_window_position; @@ -390,13 +390,7 @@ pub fn notify_subscribers( &options, state_has_been_modified || is_override_event, &DATA_DIR, - |path| { - let stream = UnixStream::connect(path)?; - // a subscriber that does not read must not hold up the writer, which has the - // window manager locked - stream.set_write_timeout(Some(std::time::Duration::from_secs(1)))?; - Ok(stream) - }, + |path| UnixStream::connect(path), )?; let mut stale_pipes = vec![];