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
@ -286,9 +286,6 @@ func (s *Server) addUserLocked(user *User) *user {
|
||||
if err := recover(); err != nil {
|
||||
s.Logger.Printf("panic serving user %q: %v\n%v", user.Username, err, debug.Stack())
|
||||
}
|
||||
}()
|
||||
|
||||
u.run()
|
||||
|
||||
s.lock.Lock()
|
||||
delete(s.users, u.Username)
|
||||
@ -297,6 +294,9 @@ func (s *Server) addUserLocked(user *User) *user {
|
||||
s.stopWG.Done()
|
||||
}()
|
||||
|
||||
u.run()
|
||||
}()
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user