From 957166799ec39663c00da4f974d6627e5fd9d0ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 4 Dec 2024 17:14:58 +0800 Subject: [PATCH] Fix CloseOnHandshakeFailure --- common/network/handshake.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/common/network/handshake.go b/common/network/handshake.go index d2203e0..273b9e3 100644 --- a/common/network/handshake.go +++ b/common/network/handshake.go @@ -33,7 +33,7 @@ func ReportHandshakeFailure(reporter any, err error) error { return nil } -func CloseOnHandshakeFailure(reporter any, onClose CloseHandlerFunc, err error) error { +func CloseOnHandshakeFailure(reporter io.Closer, onClose CloseHandlerFunc, err error) error { if err != nil { if handshakeConn, isHandshakeConn := common.Cast[HandshakeFailure](reporter); isHandshakeConn { hErr := handshakeConn.HandshakeFailure(err) @@ -51,12 +51,10 @@ func CloseOnHandshakeFailure(reporter any, onClose CloseHandlerFunc, err error) }](reporter); isTCPConn { tcpConn.SetLinger(0) } - if closer, isCloser := reporter.(io.Closer); isCloser { - err = E.Append(err, closer.Close(), func(err error) error { - return E.Cause(err, "close") - }) - } } + err = E.Append(err, reporter.Close(), func(err error) error { + return E.Cause(err, "close") + }) } if onClose != nil { onClose(err)