Skip to content

Commit 40efc8c

Browse files
committed
fix: concurrent map access panic in webSocketServer.Close()
Signed-off-by: Enrique Lacal <enrique.lacal@kaleido.io>
1 parent 075e365 commit 40efc8c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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)