mirror of
https://github.com/gesellix/Bose-SoundTouch.git
synced 2026-09-07 15:07:17 +00:00
webSocketWriteMu serialized writes across ALL browser WebSocket connections, not just the single connection gorilla actually requires. HandleDeleteDevice's synchronous BroadcastDeviceList call, and every other client's own periodic update, all contended on one lock -- directly contradicting the PR's own goal that a stalled client cannot block healthy ones. Replace it with a per-connection *sync.Mutex stored in WSClients (withConnWrite). Registration is fully decoupled from discovery-status publication: a new connection reads whatever discoveryStatus.Load() currently returns and is never blocked by an in-flight publication, which stays safe because Store() always commits before a publication takes its client snapshot. BroadcastDeviceList/BroadcastDiscoveryStatus now write each client under only that client's own lock. Found in code review of PR #665 (finding #1).