forked from quic-go/quic-go
add a sync.Pool of byte buffers with maximum packet size as cap
ref #217
This commit is contained in:
@@ -86,7 +86,8 @@ func (s *Server) Serve(conn *net.UDPConn) error {
|
||||
s.connMutex.Unlock()
|
||||
|
||||
for {
|
||||
data := make([]byte, protocol.MaxPacketSize)
|
||||
data := getPacketBuffer()
|
||||
data = data[:protocol.MaxPacketSize]
|
||||
n, remoteAddr, err := conn.ReadFromUDP(data)
|
||||
if err != nil {
|
||||
if strings.HasSuffix(err.Error(), "use of closed network connection") {
|
||||
|
||||
Reference in New Issue
Block a user