mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	better way to empty ipv6rwc buffer
This commit is contained in:
		
							parent
							
								
									86e5306eec
								
							
						
					
					
						commit
						e5d638ff4b
					
				
					 1 changed files with 7 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -129,10 +129,10 @@ func (k *keyStore) sendToSubnet(subnet address.Subnet, bs []byte) {
 | 
			
		|||
 | 
			
		||||
func (k *keyStore) update(key ed25519.PublicKey) *keyInfo {
 | 
			
		||||
	k.mutex.Lock()
 | 
			
		||||
	defer k.mutex.Unlock()
 | 
			
		||||
	var kArray keyArray
 | 
			
		||||
	copy(kArray[:], key)
 | 
			
		||||
	var info *keyInfo
 | 
			
		||||
	var packets [][]byte
 | 
			
		||||
	if info = k.keyToInfo[kArray]; info == nil {
 | 
			
		||||
		info = new(keyInfo)
 | 
			
		||||
		info.key = kArray
 | 
			
		||||
| 
						 | 
				
			
			@ -142,15 +142,19 @@ func (k *keyStore) update(key ed25519.PublicKey) *keyInfo {
 | 
			
		|||
		k.addrToInfo[info.address] = info
 | 
			
		||||
		k.subnetToInfo[info.subnet] = info
 | 
			
		||||
		if buf := k.addrBuffer[info.address]; buf != nil {
 | 
			
		||||
			k.core.WriteTo(buf.packet, iwt.Addr(info.key[:]))
 | 
			
		||||
			packets = append(packets, buf.packet)
 | 
			
		||||
			delete(k.addrBuffer, info.address)
 | 
			
		||||
		}
 | 
			
		||||
		if buf := k.subnetBuffer[info.subnet]; buf != nil {
 | 
			
		||||
			k.core.WriteTo(buf.packet, iwt.Addr(info.key[:]))
 | 
			
		||||
			packets = append(packets, buf.packet)
 | 
			
		||||
			delete(k.subnetBuffer, info.subnet)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	k.resetTimeout(info)
 | 
			
		||||
	k.mutex.Unlock()
 | 
			
		||||
	for _, packet := range packets {
 | 
			
		||||
		k.core.WriteTo(packet, iwt.Addr(info.key[:]))
 | 
			
		||||
	}
 | 
			
		||||
	return info
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue