need to hold lock during cacheCb

This commit is contained in:
Wade Simmons 2024-04-11 13:02:13 -04:00
parent c7f1bed882
commit 2ff26b261d

View File

@ -376,11 +376,11 @@ func (hm *HandshakeManager) StartHandshake(vpnIp iputil.VpnIp, cacheCb func(*Han
hm.Lock() hm.Lock()
if hh, ok := hm.vpnIps[vpnIp]; ok { if hh, ok := hm.vpnIps[vpnIp]; ok {
hm.Unlock()
// We are already trying to handshake with this vpn ip // We are already trying to handshake with this vpn ip
if cacheCb != nil { if cacheCb != nil {
cacheCb(hh) cacheCb(hh)
} }
hm.Unlock()
return hh.hostinfo return hh.hostinfo
} }
@ -422,9 +422,7 @@ func (hm *HandshakeManager) StartHandshake(vpnIp iputil.VpnIp, cacheCb func(*Han
} }
hm.Unlock() hm.Unlock()
if !hm.lightHouse.IsLighthouseIP(vpnIp) { hm.lightHouse.QueryServer(vpnIp)
hm.lightHouse.QueryServer(vpnIp)
}
return hostinfo return hostinfo
} }