From aa6f5ee100048770647df51c59ae1a39dcea0e8a 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: Wed, 7 Aug 2024 22:56:02 +0800 Subject: [PATCH] fix(p2p): wrong issub init --- gold/p2p/tcp/tcp.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gold/p2p/tcp/tcp.go b/gold/p2p/tcp/tcp.go index 327458f..b348f71 100644 --- a/gold/p2p/tcp/tcp.go +++ b/gold/p2p/tcp/tcp.go @@ -182,8 +182,6 @@ func (conn *Conn) receive(tcpconn *net.TCPConn, hasvalidated bool) { } if issub { - defer conn.peers.Delete(ep.String()) - } else { defer func() { conn.sblk.Lock() for i, sub := range conn.subs { @@ -194,6 +192,8 @@ func (conn *Conn) receive(tcpconn *net.TCPConn, hasvalidated bool) { } conn.sblk.Unlock() }() + } else { + defer conn.peers.Delete(ep.String()) } go conn.keep(ep) @@ -242,9 +242,8 @@ func (conn *Conn) receive(tcpconn *net.TCPConn, hasvalidated bool) { if config.ShowDebugLog { logrus.Debugln("[tcp] recv from", ep, "err:", err) } - // _ = tcpconn.CloseRead() - // return - continue + _ = tcpconn.CloseRead() + return } if r.pckt.typ >= packetTypeTop { if config.ShowDebugLog {