mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	use session.cancel in the router to make blocking safe, reduce size of fromRouter buffer so the drops in the switch are closer to the intended front-drop behavior
This commit is contained in:
		
							parent
							
								
									7bf5884ac1
								
							
						
					
					
						commit
						1e6a6d2160
					
				
					 2 changed files with 3 additions and 3 deletions
				
			
		| 
						 | 
					@ -166,8 +166,8 @@ func (r *router) handleTraffic(packet []byte) {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	select {
 | 
						select {
 | 
				
			||||||
	case sinfo.fromRouter <- &p: // FIXME ideally this should be front drop
 | 
						case sinfo.fromRouter <- &p:
 | 
				
			||||||
	default:
 | 
						case <-sinfo.cancel.Finished():
 | 
				
			||||||
		util.PutBytes(p.Payload)
 | 
							util.PutBytes(p.Payload)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -227,7 +227,7 @@ func (ss *sessions) createSession(theirPermKey *crypto.BoxPubKey) *sessionInfo {
 | 
				
			||||||
	sinfo.myHandle = *crypto.NewHandle()
 | 
						sinfo.myHandle = *crypto.NewHandle()
 | 
				
			||||||
	sinfo.theirAddr = *address.AddrForNodeID(crypto.GetNodeID(&sinfo.theirPermPub))
 | 
						sinfo.theirAddr = *address.AddrForNodeID(crypto.GetNodeID(&sinfo.theirPermPub))
 | 
				
			||||||
	sinfo.theirSubnet = *address.SubnetForNodeID(crypto.GetNodeID(&sinfo.theirPermPub))
 | 
						sinfo.theirSubnet = *address.SubnetForNodeID(crypto.GetNodeID(&sinfo.theirPermPub))
 | 
				
			||||||
	sinfo.fromRouter = make(chan *wire_trafficPacket, 32)
 | 
						sinfo.fromRouter = make(chan *wire_trafficPacket, 1)
 | 
				
			||||||
	sinfo.recv = make(chan []byte, 32)
 | 
						sinfo.recv = make(chan []byte, 32)
 | 
				
			||||||
	sinfo.send = make(chan []byte, 32)
 | 
						sinfo.send = make(chan []byte, 32)
 | 
				
			||||||
	ss.sinfos[sinfo.myHandle] = &sinfo
 | 
						ss.sinfos[sinfo.myHandle] = &sinfo
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue