5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-22 23:41:35 +00:00

use session.cancel in the router to make blocking safe, reduce size of fromRouter buffer so the drops in the switch are closer to the intended front-drop behavior

This commit is contained in:
Arceliar 2019-08-04 02:21:41 -05:00
parent 7bf5884ac1
commit 1e6a6d2160
2 changed files with 3 additions and 3 deletions

View File

@ -166,8 +166,8 @@ func (r *router) handleTraffic(packet []byte) {
return
}
select {
case sinfo.fromRouter <- &p: // FIXME ideally this should be front drop
default:
case sinfo.fromRouter <- &p:
case <-sinfo.cancel.Finished():
util.PutBytes(p.Payload)
}
}

View File

@ -227,7 +227,7 @@ func (ss *sessions) createSession(theirPermKey *crypto.BoxPubKey) *sessionInfo {
sinfo.myHandle = *crypto.NewHandle()
sinfo.theirAddr = *address.AddrForNodeID(crypto.GetNodeID(&sinfo.theirPermPub))
sinfo.theirSubnet = *address.SubnetForNodeID(crypto.GetNodeID(&sinfo.theirPermPub))
sinfo.fromRouter = make(chan *wire_trafficPacket, 32)
sinfo.fromRouter = make(chan *wire_trafficPacket, 1)
sinfo.recv = make(chan []byte, 32)
sinfo.send = make(chan []byte, 32)
ss.sinfos[sinfo.myHandle] = &sinfo