Commit 44fbaa4
committed
Fix concurrent map access panic in webSocketServer.Close()
Close() iterated s.connections without holding the mutex, while
connection goroutines (listen/sender) concurrently called
connectionClosed() which deletes from the same map under the lock.
This caused a "concurrent map iteration and map write" fatal error
observed as a flaky failure in TestBroadcastStartWithoutConnections.
Snapshot the connections slice under the lock before closing them.
Signed-off-by: Enrique Lacal <enrique.lacal@kaleido.io>
Made-with: Cursor1 parent 075e365 commit 44fbaa4
1 file changed
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
| 131 | + | |
130 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
131 | 137 | | |
132 | 138 | | |
133 | 139 | | |
| |||
0 commit comments