mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Use a sync.Pool to reuse packet buffers in QueuePacketConn.
This is meant to reduce overall allocations. See past discussion at https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40260#note_2885524 ff.
This commit is contained in:
parent
97c930013b
commit
c097d5f3bc
4 changed files with 116 additions and 14 deletions
|
@ -79,7 +79,11 @@ func (t *Transport) Listen(addr net.Addr, numKCPInstances int) (*SnowflakeListen
|
|||
ln: make([]*kcp.Listener, 0, numKCPInstances),
|
||||
}
|
||||
|
||||
handler := newHTTPHandler(addr, numKCPInstances)
|
||||
// kcp-go doesn't provide an accessor for the current MTU setting (and
|
||||
// anyway we could not create a kcp.Listener without creating a
|
||||
// net.PacketConn for it first), so assume the default kcp.IKCP_MTU_DEF
|
||||
// (1400 bytes) and don't increase it elsewhere.
|
||||
handler := newHTTPHandler(addr, numKCPInstances, kcp.IKCP_MTU_DEF)
|
||||
server := &http.Server{
|
||||
Addr: addr.String(),
|
||||
Handler: handler,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue