Added eventsMutex and wrap all events calls with it.
Due to some "golangish" code this library have possibility to run into data race when application is working with callbacks. This commit adds eventsMutex (which is a sync.Mutex), removed all "golangish" ifs-map reads, and wrap events map read with sync.Mutex to avoid data races.
This commit is contained in:
@@ -39,6 +39,7 @@ type Connection struct {
|
||||
user string
|
||||
registered bool
|
||||
events map[string]map[int]func(*Event)
|
||||
eventsMutex sync.Mutex
|
||||
|
||||
QuitMessage string
|
||||
lastMessage time.Time
|
||||
|
||||
Reference in New Issue
Block a user