mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	less aggresive queue size reduction
This commit is contained in:
		
							parent
							
								
									d96ae156a1
								
							
						
					
					
						commit
						ff3c8cb687
					
				
					 1 changed files with 5 additions and 2 deletions
				
			
		| 
						 | 
					@ -108,6 +108,7 @@ type peer struct {
 | 
				
			||||||
	ports      map[switchPort]*peer
 | 
						ports      map[switchPort]*peer
 | 
				
			||||||
	table      *lookupTable
 | 
						table      *lookupTable
 | 
				
			||||||
	queue      packetQueue
 | 
						queue      packetQueue
 | 
				
			||||||
 | 
						max        uint64
 | 
				
			||||||
	seq        uint64 // this and idle are used to detect when to drop packets from queue
 | 
						seq        uint64 // this and idle are used to detect when to drop packets from queue
 | 
				
			||||||
	idle       bool
 | 
						idle       bool
 | 
				
			||||||
	drop       bool // set to true if we're dropping packets from the queue
 | 
						drop       bool // set to true if we're dropping packets from the queue
 | 
				
			||||||
| 
						 | 
					@ -276,14 +277,13 @@ func (p *peer) sendPacketFrom(from phony.Actor, packet []byte) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (p *peer) _sendPacket(packet []byte) {
 | 
					func (p *peer) _sendPacket(packet []byte) {
 | 
				
			||||||
	size := p.queue.size
 | 
					 | 
				
			||||||
	p.queue.push(packet)
 | 
						p.queue.push(packet)
 | 
				
			||||||
	switch {
 | 
						switch {
 | 
				
			||||||
	case p.idle:
 | 
						case p.idle:
 | 
				
			||||||
		p.idle = false
 | 
							p.idle = false
 | 
				
			||||||
		p._handleIdle()
 | 
							p._handleIdle()
 | 
				
			||||||
	case p.drop:
 | 
						case p.drop:
 | 
				
			||||||
		for p.queue.size > size {
 | 
							for p.queue.size > p.max {
 | 
				
			||||||
			p.queue.drop()
 | 
								p.queue.drop()
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
| 
						 | 
					@ -306,6 +306,9 @@ func (p *peer) _handleIdle() {
 | 
				
			||||||
		p.seq++
 | 
							p.seq++
 | 
				
			||||||
		p.bytesSent += uint64(size)
 | 
							p.bytesSent += uint64(size)
 | 
				
			||||||
		p.intf.out(packets)
 | 
							p.intf.out(packets)
 | 
				
			||||||
 | 
							if p.drop {
 | 
				
			||||||
 | 
								p.max = p.queue.size
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		p.idle = true
 | 
							p.idle = true
 | 
				
			||||||
		p.drop = false
 | 
							p.drop = false
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue