mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Only call stillAlive if channel read succeeds
This commit is contained in:
		
							parent
							
								
									747b50bb7c
								
							
						
					
					
						commit
						7d1c03d2ac
					
				
					 1 changed files with 4 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -86,7 +86,7 @@ func (s *tunConn) reader() error {
 | 
			
		|||
	}()
 | 
			
		||||
	for {
 | 
			
		||||
		select {
 | 
			
		||||
		case r := <-read:
 | 
			
		||||
		case r, ok := <-read:
 | 
			
		||||
			if r && n > 0 {
 | 
			
		||||
				bs := append(util.GetBytes(), b[:n]...)
 | 
			
		||||
				select {
 | 
			
		||||
| 
						 | 
				
			
			@ -95,7 +95,9 @@ func (s *tunConn) reader() error {
 | 
			
		|||
					util.PutBytes(bs)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			s.stillAlive() // TODO? Only stay alive if we read >0 bytes?
 | 
			
		||||
			if ok {
 | 
			
		||||
				s.stillAlive() // TODO? Only stay alive if we read >0 bytes?
 | 
			
		||||
			}
 | 
			
		||||
		case <-s.stop:
 | 
			
		||||
			return nil
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue