tweak to avoid a potential data race

This commit is contained in:
Shivaram Lingamneni 2019-12-17 19:57:23 -05:00
parent b468baa959
commit 4b37b5dd3e
1 changed files with 3 additions and 3 deletions

View File

@ -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()