make the switch react to peer coord changes immediately, and send out updates immediately

This commit is contained in:
Arceliar 2018-06-07 00:16:47 -05:00
parent 85afe187ff
commit ecf37cae8a
2 changed files with 46 additions and 15 deletions

View file

@ -223,12 +223,14 @@ func (t *switchTable) cleanRoot() {
}
t.data.locator = switchLocator{root: t.key, tstamp: now.Unix()}
t.data.sigs = nil
t.core.peers.sendSwitchMsgs()
}
}
func (t *switchTable) removePeer(port switchPort) {
delete(t.data.peers, port)
t.updater.Store(&sync.Once{})
t.core.peers.fixSwitchAfterPeerDisconnect()
}
func (t *switchTable) cleanDropped() {
@ -250,6 +252,7 @@ func (t *switchTable) createMessage(port switchPort) (*switchMessage, []sigInfo)
}
func (t *switchTable) handleMessage(msg *switchMessage, fromPort switchPort, sigs []sigInfo) {
// TODO directly use a switchMsg instead of switchMessage + sigs
t.mutex.Lock()
defer t.mutex.Unlock()
now := time.Now()
@ -344,6 +347,7 @@ func (t *switchTable) handleMessage(msg *switchMessage, fromPort switchPort, sig
t.parent = sender.port
t.data.sigs = sigs
//t.core.log.Println("Switch update:", msg.Locator.Root, msg.Locator.Tstamp, msg.Locator.Coords)
t.core.peers.sendSwitchMsgs()
}
if doUpdate {
t.updater.Store(&sync.Once{})