Skip to content

Commit

Permalink
webrtc: put buffer back to pool (#2574)
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt authored Sep 22, 2023
1 parent 4ae549a commit 79d0f8d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions p2p/transport/webrtc/udpmux/muxed_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"errors"
"net"
"time"

pool "github.com/libp2p/go-buffer-pool"
)

var _ net.PacketConn = &muxedConnection{}
Expand Down Expand Up @@ -59,6 +61,7 @@ func (c *muxedConnection) ReadFrom(p []byte) (int, net.Addr, error) {
if n < len(buf) {
log.Debugf("short read, had %d, read %d", len(buf), n)
}
pool.Put(buf)
return n, c.remote, nil
case <-c.ctx.Done():
return 0, nil, c.ctx.Err()
Expand Down

0 comments on commit 79d0f8d

Please sign in to comment.