3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-13 07:29:30 +01:00

ensure the nick timeout mechanism is cleaned up on client quit

This commit is contained in:
Shivaram Lingamneni 2018-02-28 00:14:44 -05:00
parent a5897baa2b
commit 945dec9964
2 changed files with 20 additions and 3 deletions

View File

@ -686,9 +686,8 @@ func (client *Client) destroy(beingResumed bool) {
}
// clean up self
if client.idletimer != nil {
client.idletimer.Stop()
}
client.idletimer.Stop()
client.nickTimer.Stop()
client.server.accounts.Logout(client)

View File

@ -127,6 +127,10 @@ func (it *IdleTimer) processTimeout() {
// Stop stops counting idle time.
func (it *IdleTimer) Stop() {
if it == nil {
return
}
it.Lock()
defer it.Unlock()
it.state = TimerDead
@ -232,6 +236,20 @@ func (nt *NickTimer) Touch() {
}
}
// Stop stops counting time and cleans up the timer
func (nt *NickTimer) Stop() {
if nt == nil {
return
}
nt.Lock()
defer nt.Unlock()
if nt.timer != nil {
nt.timer.Stop()
nt.timer = nil
}
}
func (nt *NickTimer) sendWarning() {
baseNotice := "Nickname is reserved; you must change it or authenticate to NickServ within %v"
nt.client.Notice(fmt.Sprintf(nt.client.t(baseNotice), nt.timeout))