I found a lot possible race issues in this project.
For example, the Room struct, the run method goroutine read/write the room.peers, but out of the run method, there're also some other goroutine read the room.peers without lock, it might case race issue.
// Write in one goroutine
...
go rooms[id].run()
...
select {
// A new peer has connected.
case peer, ok := <-room.register:
if ok {
room.peers[peer] = true
// ...
But out of the run method goroutine, there is another goroutine read it without lock.
// Read in another goroutine
func (room *Room) peerList() map[string]string {
list := make(map[string]string)
for peer := range room.peers {
list[peer.id] = peer.handle
}
return list
}
I found some more places like this, it should case race issue.
I found a lot possible race issues in this project.
For example, the Room struct, the run method goroutine read/write the room.peers, but out of the run method, there're also some other goroutine read the room.peers without lock, it might case race issue.
// Write in one goroutine
But out of the run method goroutine, there is another goroutine read it without lock.
I found some more places like this, it should case race issue.