mirror of
https://github.com/rustdesk/hbb_common.git
synced 2026-08-27 04:37:35 +00:00
4220302d4003dc568e61eef783fa381d176c113d
Answers the review on this PR. The fallback kept three states that could not self-heal, and two of them came from the same place: it trusted the environment and it had no deadline. B1, no deadline on any part of the new path while the caller holds a process-wide lock: `connect(2)` parks on a full backlog and sctk's roundtrip polls with no deadline, so a socket that accepts and never speaks wayland stalls the display service, the six drm_capturer call sites and the flutter_ffi SyncReturn. The probe now runs on its own thread with a 2 s deadline, under the 3 s the uinput caller already budgets, and only one probe can be in flight. That also keeps sctk's `panic!`/`todo!` on malformed output events off the thread holding the lock, so it can no longer poison that mutex, and a `Builder` is used because `thread::spawn` panics when a thread cannot be created. B2, a newly reachable empty `Ok` latched into the caller's cache for the process lifetime: an empty list is now an error, so the existing no-cache path still applies and the next poll retries. B3, the `WAYLAND_SOCKET` half of the guard could not fire, because `connect_to_env` removes that variable on its success and bad-fd paths and this is re-entered every ~1.5 s. Both variables are read at the call site before connecting, and the answer is latched: a consumed variable cannot turn a process that was pointed at a compositor into one free to look for another. C4 and S1 have the same fix: the directory is `/run/user/<uid>` of the active seat0 session rather than `XDG_RUNTIME_DIR`, so no environment value reaches a connect in a process that can be root, and it works in the default build, which is given no such variable (C3). The candidates are scanned rather than guessed, since `wl_display_add_socket_auto` takes the first FREE name up to `wayland-32` and a greeter accumulates leftovers; that drops the `path.exists()` pre-stat and its TOCTOU window with it (C7), and empty values are no longer read as names (C6). C2, the first socket that accepted used to win unconditionally: the loop now carries on to the next candidate when a socket connects but fails the protocol or reports no outputs. C8, `registry_handlers!()` was empty, so a `wl_output` advertised between the registry snapshot and the roundtrip was dropped and never reached `outputs()`. C5 is real and is not fixable here: `get_primary_monitor` spawning a timeout-less xrandr inside the held lock is in the consumer, and I will send it there.
Description
No description provided
Languages
Rust
100%