From 4a2b6c3f900bf969aac40cede2c342d51cac15ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Thu, 8 Aug 2024 13:26:20 +0800 Subject: [PATCH] fix(p2p): close receive on certain errors --- gold/p2p/tcp/tcp.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gold/p2p/tcp/tcp.go b/gold/p2p/tcp/tcp.go index 2c7c552..9aa9c7e 100644 --- a/gold/p2p/tcp/tcp.go +++ b/gold/p2p/tcp/tcp.go @@ -242,8 +242,11 @@ func (conn *Conn) receive(tcpconn *net.TCPConn, hasvalidated bool) { if config.ShowDebugLog { logrus.Debugln("[tcp] recv from", ep, "err:", err) } - _ = tcpconn.CloseRead() - return + if errors.Is(err, net.ErrClosed) || errors.Is(err, io.ErrClosedPipe) { + _ = tcpconn.CloseRead() + return + } + continue } if r.pckt.typ >= packetTypeTop { if config.ShowDebugLog {