Skip to content

Commit

Permalink
fix: close conn after read
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkAfCod authored and GrapeBaBa committed May 31, 2024
1 parent c7e93e7 commit c676684
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions p2p/discover/portal_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ func (p *PortalProtocol) processContent(target *enode.Node, resp []byte) (byte,
}
// Read ALL the data from the connection until EOF and return it
data, err := io.ReadAll(conn)
conn.Close()
if err != nil {
p.Log.Error("failed to read from utp connection", "err", err)
return 0xff, nil, err
Expand Down Expand Up @@ -1189,6 +1190,7 @@ func (p *PortalProtocol) handleOffer(id enode.ID, addr *net.UDPAddr, request *po
// Read ALL the data from the connection until EOF and return it
var data []byte
data, err = io.ReadAll(conn)
conn.Close()
if err != nil {
p.Log.Error("failed to read from utp connection", "err", err)
return
Expand Down

0 comments on commit c676684

Please sign in to comment.