mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-02-19 07:50:43 +01:00
Add atomic `closed` flag to Client struct and `safeSend()` helper method to prevent race condition when sending to client channels. The race occurred when a client disconnected while a goroutine was trying to send initial state - the channel could be closed between the registration check and the actual send. All sends to client.send now go through safeSend() which checks the closed flag first. The flag is set atomically before closing the channel in all code paths (unregister, dispatchToClients, broadcast, shutdown). Related to #1048