aboutsummaryrefslogtreecommitdiff
path: root/playlist_test.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-05-31 18:15:34 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2023-05-31 18:15:34 +0200
commit031ad1f22dbb3b393850c9534ac082ab71ab1128 (patch)
tree7968f7eade9d63c88a514886e06268207155fe59 /playlist_test.go
parent0a8e25ea698333c73c50fc84e3334e1079606a10 (diff)
downloadWRMS-031ad1f22dbb3b393850c9534ac082ab71ab1128.tar.gz
WRMS-031ad1f22dbb3b393850c9534ac082ab71ab1128.zip
prevent deadlocks when connections are closed
Currently the unbounded Events channel is never closed and Connection are not removed from WRMS therefore any call to Broadcast deadlocks because the wsEndpoint consumer is no longer reading Events. Prevent this deadlock with a combination of announcing the closing of connections and sender counting for each connection. Before a sender is trying to write to the Events channel it checks if it is already closed. If it observes that the connection is open it registers itself as sender send the Event and unregisters itself. The wsEndpoint announces that the connection is closed and consumes Events until no registered senders are left. Then it closed the Events channel and terminates.
Diffstat (limited to 'playlist_test.go')
0 files changed, 0 insertions, 0 deletions