mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	have the switch queue drop packts to ourself when the total size of all packets is at least queueTotalMaxSize, instead of an arbitrary unconfigurable packet count
This commit is contained in:
		
							parent
							
								
									6803f209b0
								
							
						
					
					
						commit
						c55d7b4705
					
				
					 1 changed files with 8 additions and 2 deletions
				
			
		| 
						 | 
					@ -814,17 +814,23 @@ func (t *switchTable) doWorker() {
 | 
				
			||||||
	go func() {
 | 
						go func() {
 | 
				
			||||||
		// Keep taking packets from the idle worker and sending them to the above whenever it's idle, keeping anything extra in a (fifo, head-drop) buffer
 | 
							// Keep taking packets from the idle worker and sending them to the above whenever it's idle, keeping anything extra in a (fifo, head-drop) buffer
 | 
				
			||||||
		var buf [][]byte
 | 
							var buf [][]byte
 | 
				
			||||||
 | 
							var size int
 | 
				
			||||||
		for {
 | 
							for {
 | 
				
			||||||
			buf = append(buf, <-t.toRouter)
 | 
								bs := <-t.toRouter
 | 
				
			||||||
 | 
								size += len(bs)
 | 
				
			||||||
 | 
								buf = append(buf, bs)
 | 
				
			||||||
			for len(buf) > 0 {
 | 
								for len(buf) > 0 {
 | 
				
			||||||
				select {
 | 
									select {
 | 
				
			||||||
				case bs := <-t.toRouter:
 | 
									case bs := <-t.toRouter:
 | 
				
			||||||
 | 
										size += len(bs)
 | 
				
			||||||
					buf = append(buf, bs)
 | 
										buf = append(buf, bs)
 | 
				
			||||||
					for len(buf) > 32 {
 | 
										for size > int(t.queueTotalMaxSize) {
 | 
				
			||||||
 | 
											size -= len(buf[0])
 | 
				
			||||||
						util.PutBytes(buf[0])
 | 
											util.PutBytes(buf[0])
 | 
				
			||||||
						buf = buf[1:]
 | 
											buf = buf[1:]
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				case sendingToRouter <- buf[0]:
 | 
									case sendingToRouter <- buf[0]:
 | 
				
			||||||
 | 
										size -= len(buf[0])
 | 
				
			||||||
					buf = buf[1:]
 | 
										buf = buf[1:]
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue