kataras / neffos

A modern, fast and scalable websocket framework with elegant API written in Go

Home Page:http://bit.ly/neffos-wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fatal error: concurrent map iteration and map write

rubik-crypto opened this issue · comments

commented

fatal error: concurrent map iteration and map write

goroutine 46 [running]:
runtime.throw(0x1842c28, 0x26)
/usr/local/Cellar/go/1.14.4/libexec/src/runtime/panic.go:1116 +0x72 fp=0xc002fd9bf8 sp=0xc002fd9bc8 pc=0x433a62
runtime.mapiternext(0xc002fd9cd0)
/usr/local/Cellar/go/1.14.4/libexec/src/runtime/map.go:853 +0x552 fp=0xc002fd9c78 sp=0xc002fd9bf8 pc=0x40f5e2
runtime.mapiterinit(0x1603200, 0xc000e9bf80, 0xc002fd9cd0)
/usr/local/Cellar/go/1.14.4/libexec/src/runtime/map.go:843 +0x1c4 fp=0xc002fd9c98 sp=0xc002fd9c78 pc=0x40ef94
github.com/kataras/neffos.(*Server).GetConnections(0xc0008c6700, 0x0)
/Users/near/go/pkg/mod/github.com/kataras/neffos@v0.0.18/server.go:606 +0x9b fp=0xc002fd9d40 sp=0xc002fd9c98 pc=0x10b8b6b

@nearcode Please read the godocs before using a method. That method is NOT safe for concurrent use:

neffos/server.go

Lines 601 to 602 in 2221a9a

// Not thread safe.
func (s *Server) GetConnections() map[string]*Conn {

Use Mutex to lock your callers instead.