1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-21 02:40:24 +08:00

feat(p2p): add tcp fast fail except

This commit is contained in:
源文雨
2024-08-07 23:03:06 +08:00
parent aa6f5ee100
commit d577ae2e16

View File

@@ -447,7 +447,7 @@ 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 && !conn.cplk.TryLock() {
if (!conn.suberr || len(conn.subs) > 0) && !conn.cplk.TryLock() {
logrus.Infoln("[tcp] try sub write")
n, err = conn.writeToPeer(b, tcpep, true) // try sub write
if err == nil {