From 19014a198eb1a94f884a3a7086dde85f35e9f596 Mon Sep 17 00:00:00 2001 From: Arceliar Date: Thu, 21 Jun 2018 10:38:31 -0500 Subject: [PATCH] randomize the delay after tcp disconnects, to prevent synchronization issues --- src/yggdrasil/tcp.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/yggdrasil/tcp.go b/src/yggdrasil/tcp.go index 5408b6bf..1e62f469 100644 --- a/src/yggdrasil/tcp.go +++ b/src/yggdrasil/tcp.go @@ -17,6 +17,7 @@ package yggdrasil import ( "errors" "fmt" + "math/rand" "net" "sync" "sync/atomic" @@ -112,6 +113,7 @@ func (iface *tcpInterface) call(saddr string, socksaddr *string) { defer func() { // Block new calls for a little while, to mitigate livelock scenarios time.Sleep(tcp_timeout) + time.Sleep(time.Duration(rand.Intn(1000)) * time.Millisecond) iface.mutex.Lock() delete(iface.calls, saddr) iface.mutex.Unlock()