From c6766840d46b9aa22736d83b3c8bf4566ef2cc4a Mon Sep 17 00:00:00 2001 From: thinkAfCod Date: Thu, 30 May 2024 17:20:29 +0800 Subject: [PATCH] fix: close conn after read --- p2p/discover/portal_protocol.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/p2p/discover/portal_protocol.go b/p2p/discover/portal_protocol.go index 229120502c12..a56f7e6dc82f 100644 --- a/p2p/discover/portal_protocol.go +++ b/p2p/discover/portal_protocol.go @@ -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 @@ -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