send an ack if we receive a packet and don't have any return traffic, keeping a legacy 4-second keep-alive in case there's no traffic at all to send (to be removed later, after nodes have upgraded), ideally we should either remove ReadTimeout or use it for the switch idle timeout instead

This commit is contained in:
Arceliar 2019-02-02 22:18:55 -06:00
parent 6d83d970bb
commit b44a0f29f3
2 changed files with 65 additions and 32 deletions

View file

@ -3,6 +3,7 @@ package util
// These are misc. utility functions that didn't really fit anywhere else
import "runtime"
import "time"
// A wrapper around runtime.Gosched() so it doesn't need to be imported elsewhere.
func Yield() {
@ -44,3 +45,14 @@ func PutBytes(bs []byte) {
default:
}
}
// This is a workaround to go's broken timer implementation
func TimerStop(t *time.Timer) bool {
if !t.Stop() {
select {
case <-t.C:
default:
}
}
return true
}