Merge branch 'lighthouse-query-chan-lock' into mutex-debug

This commit is contained in:
Wade Simmons 2024-04-11 13:25:09 -04:00
commit dffaaf38d4

View File

@ -374,13 +374,13 @@ func (hm *HandshakeManager) GetOrHandshake(vpnIp iputil.VpnIp, cacheCb func(*Han
// StartHandshake will ensure a handshake is currently being attempted for the provided vpn ip // StartHandshake will ensure a handshake is currently being attempted for the provided vpn ip
func (hm *HandshakeManager) StartHandshake(vpnIp iputil.VpnIp, cacheCb func(*HandshakeHostInfo)) *HostInfo { func (hm *HandshakeManager) StartHandshake(vpnIp iputil.VpnIp, cacheCb func(*HandshakeHostInfo)) *HostInfo {
hm.Lock() hm.Lock()
defer hm.Unlock()
if hh, ok := hm.vpnIps[vpnIp]; ok { if hh, ok := hm.vpnIps[vpnIp]; ok {
// 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
} }
@ -424,6 +424,7 @@ func (hm *HandshakeManager) StartHandshake(vpnIp iputil.VpnIp, cacheCb func(*Han
} }
} }
hm.Unlock()
hm.lightHouse.QueryServer(vpnIp) hm.lightHouse.QueryServer(vpnIp)
return hostinfo return hostinfo
} }