From 4b37b5dd3e19d34197b38baaf1c2d5cd7eaad3d2 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Tue, 17 Dec 2019 19:57:23 -0500 Subject: [PATCH] tweak to avoid a potential data race --- irc/client.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/irc/client.go b/irc/client.go index 30d8c22c..e3ef9034 100644 --- a/irc/client.go +++ b/irc/client.go @@ -327,11 +327,11 @@ func (client *Client) lookupHostname(session *Session, overwrite bool) { } session.rawHostname = hostname + cloakedHostname := config.Server.Cloaks.ComputeCloak(ip) + client.stateMutex.Lock() + defer client.stateMutex.Unlock() // update the hostname if this is a new connection or a resume, but not if it's a reattach if overwrite || client.rawHostname == "" { - cloakedHostname := config.Server.Cloaks.ComputeCloak(ip) - client.stateMutex.Lock() - defer client.stateMutex.Unlock() client.rawHostname = hostname client.cloakedHostname = cloakedHostname client.updateNickMaskNoMutex()