server: cleanup user in defer
If a user goroutine panics, this correctly removes it from the global map instead of leaving a dangling entry behind.
This commit is contained in:
parent
9caa6f9ca0
commit
d21fc06d88
12
server.go
12
server.go
@ -286,15 +286,15 @@ func (s *Server) addUserLocked(user *User) *user {
|
|||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
s.Logger.Printf("panic serving user %q: %v\n%v", user.Username, err, debug.Stack())
|
s.Logger.Printf("panic serving user %q: %v\n%v", user.Username, err, debug.Stack())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.lock.Lock()
|
||||||
|
delete(s.users, u.Username)
|
||||||
|
s.lock.Unlock()
|
||||||
|
|
||||||
|
s.stopWG.Done()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
u.run()
|
u.run()
|
||||||
|
|
||||||
s.lock.Lock()
|
|
||||||
delete(s.users, u.Username)
|
|
||||||
s.lock.Unlock()
|
|
||||||
|
|
||||||
s.stopWG.Done()
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return u
|
return u
|
||||||
|
Loading…
Reference in New Issue
Block a user