Switch connAddr (udp map key) from string to a struct that allocates less. Reduce some other allocations. Use larger channel buffers to reduce backpressure from runtime jitter.

This commit is contained in:
Arceliar 2018-01-13 07:26:26 -06:00
parent ef1e0c902f
commit 75965b6da4
6 changed files with 60 additions and 28 deletions

View file

@ -274,9 +274,14 @@ func (c *Core) DEBUG_getGlobalUDPAddr() net.Addr {
}
func (c *Core) DEBUG_maybeSendUDPKeys(saddr string) {
addr := connAddr(saddr)
udpAddr, err := net.ResolveUDPAddr("udp", saddr)
if err != nil {
panic(err)
}
var addr connAddr
addr.fromUDPAddr(udpAddr)
c.udp.mutex.RLock()
_, isIn := c.udp.conns[connAddr(addr)]
_, isIn := c.udp.conns[addr]
c.udp.mutex.RUnlock()
if !isIn {
c.udp.sendKeys(addr)