Skip to content

Commit 56722af

Browse files
Merge pull request #214 from kaleido-io/fix-concurrent-map-close
Fix concurrent map panic in webSocketServer.Close()
2 parents 075e365 + 40efc8c commit 56722af

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

pkg/wsserver/wsserver.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,13 @@ func (s *webSocketServer) connectionClosed(c *webSocketConnection) {
127127
}
128128

129129
func (s *webSocketServer) Close() {
130+
s.mux.Lock()
131+
conns := make([]*webSocketConnection, 0, len(s.connections))
130132
for _, c := range s.connections {
133+
conns = append(conns, c)
134+
}
135+
s.mux.Unlock()
136+
for _, c := range conns {
131137
c.close()
132138
}
133139
}

0 commit comments

Comments
 (0)