5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-12-23 09:55:39 +00:00

adjust tcp timeout and add shadow queues to track dropped packets

This commit is contained in:
Arceliar 2018-06-07 15:04:17 -05:00
parent c1f8baf9b5
commit 63feed8dc3

View File

@ -225,16 +225,20 @@ func (iface *tcpInterface) handler(sock net.Conn, incoming bool) {
}
go func() {
defer buf.Flush()
var shadow uint64
var stack [][]byte
put := func(msg []byte) {
stack = append(stack, msg)
for len(stack) > 32 {
util_putBytes(stack[0])
stack = stack[1:]
p.updateQueueSize(-1)
shadow++
}
}
for {
for ; shadow > 0; shadow-- {
p.updateQueueSize(-1)
}
select {
case msg := <-p.linkOut:
send(msg)
@ -294,7 +298,7 @@ func (iface *tcpInterface) reader(sock net.Conn, in func([]byte)) {
bs := make([]byte, 2*tcp_msgSize)
frag := bs[:0]
for {
timeout := time.Now().Add(6 * time.Second)
timeout := time.Now().Add(2 * time.Minute)
sock.SetReadDeadline(timeout)
n, err := sock.Read(bs[len(frag):])
if err != nil || n == 0 {