Eliminate client close deadlocks. (#1833)

This commit is contained in:
funkyhippo
2022-04-15 21:30:05 -05:00
committed by GitHub
parent a825a831fe
commit 79ca6e04f3
2 changed files with 15 additions and 6 deletions

View File

@@ -231,8 +231,8 @@ func (s *Server) Broadcast(payload events.EventPayload) error {
return err
}
s.mu.Lock()
defer s.mu.Unlock()
s.mu.RLock()
defer s.mu.RUnlock()
for _, client := range s.clients {
if client == nil {
@@ -242,8 +242,7 @@ func (s *Server) Broadcast(payload events.EventPayload) error {
select {
case client.send <- data:
default:
client.close()
delete(s.clients, client.id)
go client.close()
}
}