From dbe990cac86ab3f1790735cc9c54f9eac6d3c5bf 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: Fri, 21 Feb 2025 00:56:15 +0900 Subject: [PATCH] fix(p2p): tcp sync: unlock of unlocked mutex --- gold/p2p/tcp/tcp.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gold/p2p/tcp/tcp.go b/gold/p2p/tcp/tcp.go index 3457a1c..6033ba5 100644 --- a/gold/p2p/tcp/tcp.go +++ b/gold/p2p/tcp/tcp.go @@ -459,7 +459,8 @@ func (conn *Conn) WriteToPeer(b []byte, ep p2p.EndPoint) (n int, err error) { if len(b) >= 65536 { return 0, errors.New("data size " + strconv.Itoa(len(b)) + " is too large") } - if (!conn.suberr || len(conn.subs) > 0) && !conn.cplk.TryLock() { + locked := conn.cplk.TryLock() + if !locked && (!conn.suberr || len(conn.subs) > 0) { if config.ShowDebugLog { logrus.Debug("[tcp] try sub write to", tcpep) }