mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-26 00:11:36 +00:00
misc fixes
This commit is contained in:
parent
f38963c71b
commit
c7b4bfcef5
@ -234,6 +234,9 @@ func (intf *linkInterface) handler() error {
|
|||||||
signalReady := make(chan struct{}, 1)
|
signalReady := make(chan struct{}, 1)
|
||||||
signalSent := make(chan bool, 1)
|
signalSent := make(chan bool, 1)
|
||||||
sendAck := make(chan struct{}, 1)
|
sendAck := make(chan struct{}, 1)
|
||||||
|
sendBlocked := time.NewTimer(time.Second)
|
||||||
|
defer util.TimerStop(sendBlocked)
|
||||||
|
util.TimerStop(sendBlocked)
|
||||||
go func() {
|
go func() {
|
||||||
defer close(signalReady)
|
defer close(signalReady)
|
||||||
defer close(signalSent)
|
defer close(signalSent)
|
||||||
@ -241,7 +244,9 @@ func (intf *linkInterface) handler() error {
|
|||||||
tcpTimer := time.NewTimer(interval) // used for backwards compat with old tcp
|
tcpTimer := time.NewTimer(interval) // used for backwards compat with old tcp
|
||||||
defer util.TimerStop(tcpTimer)
|
defer util.TimerStop(tcpTimer)
|
||||||
send := func(bs []byte) {
|
send := func(bs []byte) {
|
||||||
|
sendBlocked.Reset(time.Second)
|
||||||
intf.msgIO.writeMsg(bs)
|
intf.msgIO.writeMsg(bs)
|
||||||
|
util.TimerStop(sendBlocked)
|
||||||
select {
|
select {
|
||||||
case signalSent <- len(bs) > 0:
|
case signalSent <- len(bs) > 0:
|
||||||
default:
|
default:
|
||||||
@ -269,7 +274,7 @@ func (intf *linkInterface) handler() error {
|
|||||||
strings.ToUpper(intf.info.linkType), themString, intf.info.local)
|
strings.ToUpper(intf.info.linkType), themString, intf.info.local)
|
||||||
send(nil)
|
send(nil)
|
||||||
case msg := <-intf.peer.linkOut:
|
case msg := <-intf.peer.linkOut:
|
||||||
intf.msgIO.writeMsg(msg)
|
send(msg)
|
||||||
case msg, ok := <-out:
|
case msg, ok := <-out:
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
@ -360,6 +365,10 @@ func (intf *linkInterface) handler() error {
|
|||||||
intf.link.core.switchTable.idleIn <- intf.peer.port
|
intf.link.core.switchTable.idleIn <- intf.peer.port
|
||||||
isReady = true
|
isReady = true
|
||||||
}
|
}
|
||||||
|
case <-sendBlocked.C:
|
||||||
|
// We blocked while trying to send something
|
||||||
|
isReady = false
|
||||||
|
intf.link.core.switchTable.blockPeer(intf.peer.port)
|
||||||
case <-sendTimer.C:
|
case <-sendTimer.C:
|
||||||
// We haven't sent anything, so signal a send of a 0 packet to let them know we're alive
|
// We haven't sent anything, so signal a send of a 0 packet to let them know we're alive
|
||||||
select {
|
select {
|
||||||
|
@ -677,12 +677,12 @@ func (t *switchTable) handleIn(packet []byte, idle map[switchPort]struct{}) bool
|
|||||||
//nothing
|
//nothing
|
||||||
case coordLen < bestCoordLen:
|
case coordLen < bestCoordLen:
|
||||||
update = true
|
update = true
|
||||||
/*
|
/*
|
||||||
case coordLen > bestCoordLen:
|
case coordLen > bestCoordLen:
|
||||||
//nothing
|
//nothing
|
||||||
case port < best.port:
|
case port < best.port:
|
||||||
update = true
|
update = true
|
||||||
*/
|
*/
|
||||||
default:
|
default:
|
||||||
//nothing
|
//nothing
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user