mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	Show queue capacity in getSwitchQueues
This commit is contained in:
		
							parent
							
								
									7d8a1859f0
								
							
						
					
					
						commit
						69cd736112
					
				
					 3 changed files with 29 additions and 19 deletions
				
			
		| 
						 | 
				
			
			@ -542,8 +542,9 @@ func (a *admin) getData_getSwitchQueues() admin_nodeInfo {
 | 
			
		|||
			{"queues", queues},
 | 
			
		||||
			{"queues_count", len(switchTable.queues.bufs)},
 | 
			
		||||
			{"queues_size", switchTable.queues.size},
 | 
			
		||||
			{"max_queues_count", switchTable.queues.maxbufs},
 | 
			
		||||
			{"max_queues_size", switchTable.queues.maxsize},
 | 
			
		||||
			{"highest_queues_count", switchTable.queues.maxbufs},
 | 
			
		||||
			{"highest_queues_size", switchTable.queues.maxsize},
 | 
			
		||||
			{"maximum_queues_size", switch_buffer_maxSize},
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	a.core.switchTable.doAdmin(getSwitchQueues)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -601,6 +601,8 @@ type switch_packetInfo struct {
 | 
			
		|||
	time  time.Time // Timestamp of when the packet arrived
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const switch_buffer_maxSize = 4 * 1048576 // Maximum 4 MB
 | 
			
		||||
 | 
			
		||||
// Used to keep track of buffered packets
 | 
			
		||||
type switch_buffer struct {
 | 
			
		||||
	packets []switch_packetInfo // Currently buffered packets, which may be dropped if it grows too large
 | 
			
		||||
| 
						 | 
				
			
			@ -627,8 +629,8 @@ func (b *switch_buffers) cleanup(t *switchTable) {
 | 
			
		|||
			delete(b.bufs, streamID)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	const maxSize = 4 * 1048576 // Maximum 4 MB
 | 
			
		||||
	for b.size > maxSize {
 | 
			
		||||
 | 
			
		||||
	for b.size > switch_buffer_maxSize {
 | 
			
		||||
		// Drop a random queue
 | 
			
		||||
		target := rand.Uint64() % b.size
 | 
			
		||||
		var size uint64 // running total
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue