mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	randomize the delay after tcp disconnects, to prevent synchronization issues
This commit is contained in:
		
							parent
							
								
									f599a1a2c1
								
							
						
					
					
						commit
						19014a198e
					
				
					 1 changed files with 2 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -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()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue