mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	make sure we don't replace an existing listener
This commit is contained in:
		
							parent
							
								
									917ca6c1c5
								
							
						
					
					
						commit
						426d157025
					
				
					 1 changed files with 8 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -155,8 +155,14 @@ func (t *tcp) listener(l *tcpListener, listenaddr string) {
 | 
			
		|||
	}
 | 
			
		||||
	// Track the listener so that we can find it again in future
 | 
			
		||||
	t.mutex.Lock()
 | 
			
		||||
	t.listeners[listenaddr] = l
 | 
			
		||||
	t.mutex.Unlock()
 | 
			
		||||
	if _, isIn := t.listeners[listenaddr]; isIn {
 | 
			
		||||
		t.mutex.Unlock()
 | 
			
		||||
		l.listener.Close()
 | 
			
		||||
		return
 | 
			
		||||
	} else {
 | 
			
		||||
		t.listeners[listenaddr] = l
 | 
			
		||||
		t.mutex.Unlock()
 | 
			
		||||
	}
 | 
			
		||||
	// And here we go!
 | 
			
		||||
	accepted := make(chan bool)
 | 
			
		||||
	defer func() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue