mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	correctly update buffer sizs when buffers overflow, and returned freed packets to the byte store
This commit is contained in:
		
							parent
							
								
									ad5dc9ea87
								
							
						
					
					
						commit
						ba4047b51a
					
				
					 1 changed files with 5 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -631,8 +631,12 @@ func (b *switch_buffers) cleanup(t *switchTable) {
 | 
			
		|||
			packet, buf.packets = buf.packets[0], buf.packets[1:]
 | 
			
		||||
			buf.size -= uint64(len(packet.bytes))
 | 
			
		||||
			b.size -= uint64(len(packet.bytes))
 | 
			
		||||
			util_putBytes(packet.bytes)
 | 
			
		||||
			if len(buf.packets) == 0 {
 | 
			
		||||
				delete(b.bufs, streamID)
 | 
			
		||||
			} else {
 | 
			
		||||
				// Need to update the map, since buf was retrieved by value
 | 
			
		||||
				b.bufs[streamID] = buf
 | 
			
		||||
			}
 | 
			
		||||
			break
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -672,6 +676,7 @@ func (t *switchTable) handleIdle(port switchPort, bufs *switch_buffers) bool {
 | 
			
		|||
		if len(buf.packets) == 0 {
 | 
			
		||||
			delete(bufs.bufs, best)
 | 
			
		||||
		} else {
 | 
			
		||||
			// Need to update the map, since buf was retrieved by value
 | 
			
		||||
			bufs.bufs[best] = buf
 | 
			
		||||
		}
 | 
			
		||||
		to.sendPacket(packet.bytes)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue