From b8f37e4e6cf8ec7b8b649265995558c56f799280 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Wed, 14 Mar 2018 08:43:50 -0400 Subject: [PATCH] fix bad interaction between nickTimer.Stop() and accounts.Logout() Sequence of events: 1. client.nickTimer.Stop() 2. client.server.accounts.Logout(client) 3. accounts sees that client is no longer logged in, does client.nickTimer.Touch() 4. 30 seconds later, RandomlyRename resurrects the zombie client --- irc/idletimer.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/irc/idletimer.go b/irc/idletimer.go index 58962d37..f4850a80 100644 --- a/irc/idletimer.go +++ b/irc/idletimer.go @@ -179,6 +179,7 @@ type NickTimer struct { client *Client // mutable + stopped bool nick string accountForNick string account string @@ -213,6 +214,11 @@ func (nt *NickTimer) Touch() { func() { nt.Lock() defer nt.Unlock() + + if nt.stopped { + return + } + // the timer will not reset as long as the squatter is targeting the same account accountChanged := accountForNick != nt.accountForNick // change state @@ -248,6 +254,7 @@ func (nt *NickTimer) Stop() { nt.timer.Stop() nt.timer = nil } + nt.stopped = true } func (nt *NickTimer) sendWarning() {