send a switch message immediately when peering, and use OS-level TCP keep-alive (shouldn't matter right now, since we have application-level keep-alive that preempts it, but important later)

This commit is contained in:
Arceliar 2018-12-14 18:15:35 -06:00
parent ce98aac504
commit abd8b69979
2 changed files with 19 additions and 14 deletions

View file

@ -177,6 +177,7 @@ func (p *peer) doSendSwitchMsgs() {
func (p *peer) linkLoop() {
tick := time.NewTicker(time.Second)
defer tick.Stop()
p.doSendSwitchMsgs()
for {
select {
case _, ok := <-p.doSend:
@ -185,11 +186,9 @@ func (p *peer) linkLoop() {
}
p.sendSwitchMsg()
case _ = <-tick.C:
//break // FIXME disabled the below completely to test something
pdinfo := p.dinfo // FIXME this is a bad workarond NPE on the next line
if pdinfo != nil {
dinfo := *pdinfo
p.core.dht.peers <- &dinfo
dinfo := p.dinfo // FIXME? are pointer reads *always* atomic?
if dinfo != nil {
p.core.dht.peers <- dinfo
}
}
}