From 362f28344c4995daf188ab4610b6f7988fe908a4 Mon Sep 17 00:00:00 2001 From: Blake Severson Date: Wed, 8 Nov 2017 10:42:38 -0700 Subject: [PATCH] Prevent locks from becoming mutually exclusive Through some profiling under a fair amount of load, we found that on occasion the sidsLock would not release and cause channelsLock not not release as well since both are deferred. After offloading it to another goroutine, the issue subsided under load. --- server.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server.go b/server.go index 7583633..907d307 100644 --- a/server.go +++ b/server.go @@ -277,7 +277,11 @@ func onDisconnectCleanup(c *Channel) { delete(c.server.rooms, c) } + + go deleteSid(c) +} +func deleteSid(c *Channel) { c.server.sidsLock.Lock() defer c.server.sidsLock.Unlock()