@ -158,10 +158,10 @@ func (c *Conn) maybeSetNearestDERP(report *netcheck.Report) (preferredDERP int)
} else {
} else {
connectedToControl = c . health . GetInPollNetMap ( )
connectedToControl = c . health . GetInPollNetMap ( )
}
}
c . mu . Lock ( )
myDerp := c . myDerp
c . mu . Unlock ( )
if ! connectedToControl {
if ! connectedToControl {
c . mu . Lock ( )
myDerp := c . myDerp
c . mu . Unlock ( )
if myDerp != 0 {
if myDerp != 0 {
metricDERPHomeNoChangeNoControl . Add ( 1 )
metricDERPHomeNoChangeNoControl . Add ( 1 )
return myDerp
return myDerp
@ -178,6 +178,11 @@ func (c *Conn) maybeSetNearestDERP(report *netcheck.Report) (preferredDERP int)
// one.
// one.
preferredDERP = c . pickDERPFallback ( )
preferredDERP = c . pickDERPFallback ( )
}
}
if preferredDERP != myDerp {
c . logf (
"magicsock: home DERP changing from derp-%d [%dms] to derp-%d [%dms]" ,
c . myDerp , report . RegionLatency [ myDerp ] . Milliseconds ( ) , preferredDERP , report . RegionLatency [ preferredDERP ] . Milliseconds ( ) )
}
if ! c . setNearestDERP ( preferredDERP ) {
if ! c . setNearestDERP ( preferredDERP ) {
preferredDERP = 0
preferredDERP = 0
}
}