recover from client-caused panics

This commit is contained in:
Shivaram Lingamneni 2017-10-23 18:38:32 -04:00
parent fbaf2d8e3a
commit 054f57e215
1 changed files with 9 additions and 3 deletions

View File

@ -184,6 +184,15 @@ func (client *Client) run() {
var line string
var msg ircmsg.IrcMessage
defer func() {
if r := recover(); r != nil {
client.server.logger.Error("internal", fmt.Sprintf("Client caused panic, disconnecting: %v", r))
debug.PrintStack()
}
// ensure client connection gets closed
client.destroy()
}()
client.idletimer = NewIdleTimer(client)
client.idletimer.Start()
@ -225,9 +234,6 @@ func (client *Client) run() {
break
}
}
// ensure client connection gets closed
client.destroy()
}
//