3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-01 16:39:26 +01:00

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

View File

@ -327,11 +327,11 @@ func (client *Client) lookupHostname(session *Session, overwrite bool) {
} }
session.rawHostname = hostname session.rawHostname = hostname
// 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) cloakedHostname := config.Server.Cloaks.ComputeCloak(ip)
client.stateMutex.Lock() client.stateMutex.Lock()
defer client.stateMutex.Unlock() 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 == "" {
client.rawHostname = hostname client.rawHostname = hostname
client.cloakedHostname = cloakedHostname client.cloakedHostname = cloakedHostname
client.updateNickMaskNoMutex() client.updateNickMaskNoMutex()