You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I use beaver to build a socket server.But sometimes it panics with an error.
The error is : fatal error: concurrent map writes.
And the error's stacks info : github.com/clivern/beaver/internal/app/controller.(*Websocket).HandleConnections(0xc0001ca4d0, 0x7f033e218240, 0xc0004869a0, 0xc0000b1200, 0xc000233108, 0x24, 0xc00023312d, 0xbd, 0xc000029440, 0x24) /root/Beaver/internal/app/controller/socket.go:166 +0x505 fp=0xc000585688 sp=0xc0005854e8 pc=0xabd815.
The code in 166 line is:delete(e.Clients, ID)
I google for the reason and find it's unsafe that using map in goruntine. So I think Websocket.Clients should protected by mutex or use sync.Map directly?
Development or production environment
OS: [Ubuntu 16.04]
Go 1.12.17
The text was updated successfully, but these errors were encountered:
Describe the bug
I use beaver to build a socket server.But sometimes it panics with an error.
The error is :
fatal error: concurrent map writes
.And the error's stacks info :
github.com/clivern/beaver/internal/app/controller.(*Websocket).HandleConnections(0xc0001ca4d0, 0x7f033e218240, 0xc0004869a0, 0xc0000b1200, 0xc000233108, 0x24, 0xc00023312d, 0xbd, 0xc000029440, 0x24) /root/Beaver/internal/app/controller/socket.go:166 +0x505 fp=0xc000585688 sp=0xc0005854e8 pc=0xabd815
.The code in 166 line is:
delete(e.Clients, ID)
I google for the reason and find it's unsafe that using map in goruntine. So I think
Websocket.Clients
should protected by mutex or usesync.Map
directly?Development or production environment
The text was updated successfully, but these errors were encountered: