Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ func BuildEngine(conf *Configuration) (*Engine, error) {

func (engine *Engine) Loop() {
for {
engine.rooms.RLock()
engine.rooms.Lock()

engine.State.UpdatedAt = time.Now()
engine.State.ActiveRooms = 0
engine.State.ClosedRooms = 0
engine.State.ActivePeers = 0
engine.State.ClosedPeers = 0

for _, pm := range engine.rooms.m {
for rid, pm := range engine.rooms.m {
pm.RLock()
ap, cp := 0, 0
for _, p := range pm.m {
Expand All @@ -73,11 +73,12 @@ func (engine *Engine) Loop() {
engine.State.ActiveRooms += 1
} else {
engine.State.ClosedRooms += 1
delete(engine.rooms.m, rid)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In line 52, engine.rooms.RLock() should be changed to engine.rooms.Lock(). Line 80 also needs change.

}
pm.RUnlock()
}

engine.rooms.RUnlock()
engine.rooms.Unlock()
time.Sleep(engineStateLoopPeriod)
}
}
Expand Down