From f5e7ec525d948dd503387118de776a71a83b0555 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Sat, 2 Dec 2017 20:05:06 -0500 Subject: [PATCH] synchronize accesses to client.atime --- irc/client.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/irc/client.go b/irc/client.go index 6deb4410..5cfd9bed 100644 --- a/irc/client.go +++ b/irc/client.go @@ -261,6 +261,8 @@ func (client *Client) run() { // Active updates when the client was last 'active' (i.e. the user should be sitting in front of their client). func (client *Client) Active() { + client.stateMutex.Lock() + defer client.stateMutex.Unlock() client.atime = time.Now() } @@ -298,6 +300,8 @@ func (client *Client) Register() { // IdleTime returns how long this client's been idle. func (client *Client) IdleTime() time.Duration { + client.stateMutex.RLock() + defer client.stateMutex.RUnlock() return time.Since(client.atime) }