From 15e358a5e8ff4fdd83b3f3eac75accff2eb44dcf Mon Sep 17 00:00:00 2001 From: xtaci Date: Tue, 12 Mar 2024 13:56:31 +0800 Subject: [PATCH] upd deps to kcp-go@v5.6.8 --- go.mod | 2 +- go.sum | 2 ++ vendor/github.com/xtaci/kcp-go/v5/sess.go | 16 +++++++++++++--- vendor/modules.txt | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index ca432b4..d9764e8 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ require ( github.com/golang/snappy v0.0.4 github.com/pkg/errors v0.9.1 github.com/urfave/cli v1.22.14 - github.com/xtaci/kcp-go/v5 v5.6.7 + github.com/xtaci/kcp-go/v5 v5.6.8 github.com/xtaci/smux v1.5.24 github.com/xtaci/tcpraw v1.2.25 golang.org/x/crypto v0.17.0 diff --git a/go.sum b/go.sum index e878ea9..8b0d1e9 100644 --- a/go.sum +++ b/go.sum @@ -63,6 +63,8 @@ github.com/xtaci/kcp-go/v5 v5.6.6 h1:SxSjZoaaLzQKxbIfzE1FYLMKtR2veox5mvKO7AliZ5I github.com/xtaci/kcp-go/v5 v5.6.6/go.mod h1:oE9j2NVqAkuKO5o8ByKGch3vgVX3BNf8zqP8JiGq0bM= github.com/xtaci/kcp-go/v5 v5.6.7 h1:7+rnxNFIsjEwTXQk4cSZpXM4pO0hqtpwE1UFFoJBffA= github.com/xtaci/kcp-go/v5 v5.6.7/go.mod h1:oE9j2NVqAkuKO5o8ByKGch3vgVX3BNf8zqP8JiGq0bM= +github.com/xtaci/kcp-go/v5 v5.6.8 h1:jlI/0jAyjoOjT/SaGB58s4bQMJiNS41A2RKzR6TMWeI= +github.com/xtaci/kcp-go/v5 v5.6.8/go.mod h1:oE9j2NVqAkuKO5o8ByKGch3vgVX3BNf8zqP8JiGq0bM= github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae h1:J0GxkO96kL4WF+AIT3M4mfUVinOCPgf2uUWYFUzN0sM= github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae/go.mod h1:gXtu8J62kEgmN++bm9BVICuT/e8yiLI2KFobd/TRFsE= github.com/xtaci/smux v1.5.24 h1:77emW9dtnOxxOQ5ltR+8BbsX1kzcOxQ5gB+aaV9hXOY= diff --git a/vendor/github.com/xtaci/kcp-go/v5/sess.go b/vendor/github.com/xtaci/kcp-go/v5/sess.go index 227d99b..4e32399 100644 --- a/vendor/github.com/xtaci/kcp-go/v5/sess.go +++ b/vendor/github.com/xtaci/kcp-go/v5/sess.go @@ -195,6 +195,7 @@ func newUDPSession(conv uint32, dataShards, parityShards int, l *Listener, conn // Read implements net.Conn func (s *UDPSession) Read(b []byte) (n int, err error) { +RESET_TIMER: var timeout *time.Timer // deadline for current reading operation var c <-chan time.Time @@ -243,6 +244,10 @@ func (s *UDPSession) Read(b []byte) (n int, err error) { // wait for read event or timeout or error select { case <-s.chReadEvent: + if timeout != nil { + timeout.Stop() + goto RESET_TIMER + } case <-c: return 0, errors.WithStack(errTimeout) case <-s.chSocketReadError: @@ -258,6 +263,7 @@ func (s *UDPSession) Write(b []byte) (n int, err error) { return s.WriteBuffers( // WriteBuffers write a vector of byte slices to the underlying connection func (s *UDPSession) WriteBuffers(v [][]byte) (n int, err error) { +RESET_TIMER: var timeout *time.Timer var c <-chan time.Time if !s.wd.IsZero() { @@ -308,6 +314,10 @@ func (s *UDPSession) WriteBuffers(v [][]byte) (n int, err error) { select { case <-s.chWriteEvent: + if timeout != nil { + timeout.Stop() + goto RESET_TIMER + } case <-c: return 0, errors.WithStack(errTimeout) case <-s.chSocketWriteError: @@ -375,9 +385,9 @@ func (s *UDPSession) RemoteAddr() net.Addr { return s.remote } // SetDeadline sets the deadline associated with the listener. A zero time value disables the deadline. func (s *UDPSession) SetDeadline(t time.Time) error { s.mu.Lock() - defer s.mu.Unlock() s.rd = t s.wd = t + s.mu.Unlock() s.notifyReadEvent() s.notifyWriteEvent() return nil @@ -386,8 +396,8 @@ func (s *UDPSession) SetDeadline(t time.Time) error { // SetReadDeadline implements the Conn SetReadDeadline method. func (s *UDPSession) SetReadDeadline(t time.Time) error { s.mu.Lock() - defer s.mu.Unlock() s.rd = t + s.mu.Unlock() s.notifyReadEvent() return nil } @@ -395,8 +405,8 @@ func (s *UDPSession) SetReadDeadline(t time.Time) error { // SetWriteDeadline implements the Conn SetWriteDeadline method. func (s *UDPSession) SetWriteDeadline(t time.Time) error { s.mu.Lock() - defer s.mu.Unlock() s.wd = t + s.mu.Unlock() s.notifyWriteEvent() return nil } diff --git a/vendor/modules.txt b/vendor/modules.txt index 24a6654..c35b9e3 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -35,7 +35,7 @@ github.com/tjfoc/gmsm/sm4 # github.com/urfave/cli v1.22.14 ## explicit; go 1.11 github.com/urfave/cli -# github.com/xtaci/kcp-go/v5 v5.6.7 +# github.com/xtaci/kcp-go/v5 v5.6.8 ## explicit; go 1.21 github.com/xtaci/kcp-go/v5 # github.com/xtaci/smux v1.5.24