1
0
mirror of https://github.com/bingohuang/docker-labs.git synced 2025-10-04 17:33:21 +08:00

Better session lock management

This commit is contained in:
Jonathan Leibiusky (@xetorthio)
2016-11-11 20:10:19 -03:00
parent e49245dfe9
commit d05fe56fea
3 changed files with 6 additions and 3 deletions

View File

@@ -59,8 +59,10 @@ func NewSession() (*Session, error) {
sessions[s.Id] = s
// Schedule cleanup of the session
time.AfterFunc(4*time.Hour, func() {
time.AfterFunc(15*time.Second, func() {
s = GetSession(s.Id)
s.Lock()
defer s.Unlock()
wsServer.BroadcastTo(s.Id, "session end")
log.Printf("Starting clean up of session [%s]\n", s.Id)
for _, i := range s.Instances {