5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-22 18:50:27 +00:00

Debug some issues with the state machine that tracks idle connections in link.go

This commit is contained in:
Arceliar 2019-02-15 19:35:10 -06:00
parent 2ba427a737
commit 6f0bbbfb98
2 changed files with 19 additions and 8 deletions

View File

@ -216,6 +216,8 @@ func (intf *linkInterface) handler() error {
case signalReady <- struct{}{}: case signalReady <- struct{}{}:
default: default:
} }
intf.link.core.log.Debugf("Sending packet to %s: %s, source %s",
strings.ToUpper(intf.info.linkType), themString, intf.info.local)
} }
} }
}() }()
@ -235,18 +237,21 @@ func (intf *linkInterface) handler() error {
recvTimer := time.NewTimer(recvTime) recvTimer := time.NewTimer(recvTime)
defer util.TimerStop(recvTimer) defer util.TimerStop(recvTimer)
for { for {
intf.link.core.log.Debugf("State of %s: %s, source %s :: isAlive %t isReady %t sendTimerRunning %t recvTimerRunning %t",
strings.ToUpper(intf.info.linkType), themString, intf.info.local,
isAlive, isReady, sendTimerRunning, recvTimerRunning)
select { select {
case gotMsg, ok := <-signalAlive: case gotMsg, ok := <-signalAlive:
if !ok { if !ok {
return return
} }
if !isAlive { util.TimerStop(recvTimer)
isAlive = true recvTimerRunning = false
if !isReady { isAlive = true
// (Re-)enable in the switch if !isReady {
isReady = true // (Re-)enable in the switch
intf.link.core.switchTable.idleIn <- intf.peer.port intf.link.core.switchTable.idleIn <- intf.peer.port
} isReady = true
} }
if gotMsg && !sendTimerRunning { if gotMsg && !sendTimerRunning {
// We got a message // We got a message
@ -255,6 +260,10 @@ func (intf *linkInterface) handler() error {
sendTimer.Reset(sendTime) sendTimer.Reset(sendTime)
sendTimerRunning = true sendTimerRunning = true
} }
if !gotMsg {
intf.link.core.log.Debugf("Received ack from %s: %s, source %s",
strings.ToUpper(intf.info.linkType), themString, intf.info.local)
}
case sentMsg, ok := <-signalSent: case sentMsg, ok := <-signalSent:
// Stop any running ack timer // Stop any running ack timer
if !ok { if !ok {
@ -273,12 +282,13 @@ func (intf *linkInterface) handler() error {
if !ok { if !ok {
return return
} }
if !isAlive || !isReady { if !isAlive {
// Disable in the switch // Disable in the switch
isReady = false isReady = false
} else { } else {
// Keep enabled in the switch // Keep enabled in the switch
intf.link.core.switchTable.idleIn <- intf.peer.port intf.link.core.switchTable.idleIn <- intf.peer.port
isReady = true
} }
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

View File

@ -780,6 +780,7 @@ func (t *switchTable) doWorker() {
t.queues.bufs = make(map[string]switch_buffer) // Packets per PacketStreamID (string) t.queues.bufs = make(map[string]switch_buffer) // Packets per PacketStreamID (string)
idle := make(map[switchPort]struct{}) // this is to deduplicate things idle := make(map[switchPort]struct{}) // this is to deduplicate things
for { for {
t.core.log.Debugf("Switch state: idle = %d, buffers = %d", len(idle), len(t.queues.bufs))
select { select {
case bytes := <-t.packetIn: case bytes := <-t.packetIn:
// Try to send it somewhere (or drop it if it's corrupt or at a dead end) // Try to send it somewhere (or drop it if it's corrupt or at a dead end)