mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	fix concurrency bug in iface.go
This commit is contained in:
		
							parent
							
								
									0fb1165b76
								
							
						
					
					
						commit
						28db566b37
					
				
					 1 changed files with 1 additions and 1 deletions
				
			
		| 
						 | 
					@ -225,11 +225,11 @@ func (tun *TunAdapter) reader() error {
 | 
				
			||||||
				panic("Given empty dstNodeID and dstNodeIDMask - this shouldn't happen")
 | 
									panic("Given empty dstNodeID and dstNodeIDMask - this shouldn't happen")
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			// Dial to the remote node
 | 
								// Dial to the remote node
 | 
				
			||||||
 | 
								packet := append(util.GetBytes(), bs[:n]...)
 | 
				
			||||||
			go func() {
 | 
								go func() {
 | 
				
			||||||
				// FIXME just spitting out a goroutine to do this is kind of ugly and means we drop packets until the dial finishes
 | 
									// FIXME just spitting out a goroutine to do this is kind of ugly and means we drop packets until the dial finishes
 | 
				
			||||||
				tun.mutex.Lock()
 | 
									tun.mutex.Lock()
 | 
				
			||||||
				_, known := tun.dials[*dstNodeID]
 | 
									_, known := tun.dials[*dstNodeID]
 | 
				
			||||||
				packet := append(util.GetBytes(), bs[:n]...)
 | 
					 | 
				
			||||||
				tun.dials[*dstNodeID] = append(tun.dials[*dstNodeID], packet)
 | 
									tun.dials[*dstNodeID] = append(tun.dials[*dstNodeID], packet)
 | 
				
			||||||
				for len(tun.dials[*dstNodeID]) > 32 {
 | 
									for len(tun.dials[*dstNodeID]) > 32 {
 | 
				
			||||||
					util.PutBytes(tun.dials[*dstNodeID][0])
 | 
										util.PutBytes(tun.dials[*dstNodeID][0])
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue