smux: return os.ErrDeadlineExceeded when timeout

This commit is contained in:
nadoo committed 2021-05-01 00:32:55 +08:00
1 parent e9e4515e67
commit 70cf30b5e6
4 files changed
+16 -8

No files matched your search

+5 -2
View File
@@ -4,8 +4,10 @@ import (
"container/heap"
"encoding/binary"
"errors"
"fmt"
"io"
"net"
"os"
"sync"
"sync/atomic"
"time"
@@ -21,8 +23,9 @@ var (
ErrInvalidProtocol = errors.New("invalid protocol")
ErrConsumed = errors.New("peer consumed more than sent")
ErrGoAway = errors.New("stream id overflows, should start a new connection")
ErrTimeout = errors.New("timeout")
ErrWouldBlock = errors.New("operation would block on IO")
// ErrTimeout = errors.New("timeout")
ErrTimeout = fmt.Errorf("smux: %w", os.ErrDeadlineExceeded)
ErrWouldBlock = errors.New("operation would block on IO")
)
type writeRequest struct {
+5
View File
@@ -4,6 +4,7 @@ import (
"errors"
"net"
"net/url"
"sync"
"github.com/nadoo/glider/log"
"github.com/nadoo/glider/proxy"
@@ -15,6 +16,7 @@ import (
type SmuxClient struct {
dialer proxy.Dialer
addr string
mu sync.Mutex
session *smux.Session
}
@@ -66,6 +68,9 @@ func (s *SmuxClient) DialUDP(network, addr string) (net.PacketConn, net.Addr, er
}
func (s *SmuxClient) initConn() error {
s.mu.Lock()
defer s.mu.Unlock()
conn, err := s.dialer.Dial("tcp", s.addr)
if err != nil {
log.F("[smux] dial to %s error: %s", s.addr, err)