fix marker for selector

This commit is contained in:
ginuerzh 2024-06-07 20:57:47 +08:00
parent 118ee91c95
commit ce60160cd7
3 changed files with 24 additions and 11 deletions

View File

@ -104,7 +104,7 @@ func (c *Chain) Route(ctx context.Context, network, address string, opts ...chai
tr.Options().Route = rt
node = node.Copy()
node.Options().Transport = tr
rt = NewRoute()
rt = NewRoute(ChainRouteOption(c))
}
rt.addNode(node)

View File

@ -129,10 +129,11 @@ func (r *route) connect(ctx context.Context, logger logger.Logger) (conn net.Con
metrics.Labels{"chain": name, "node": node.Name}); v != nil {
v.Inc()
}
} else {
if marker != nil {
marker.Reset()
}
return
}
if marker != nil {
marker.Reset()
}
}
}()

View File

@ -70,6 +70,19 @@ func (d *http2Dialer) Dial(ctx context.Context, address string, opts ...dialer.D
opt(&options)
}
{
// Check whether the connection is established properly
netd := options.NetDialer
if netd == nil {
netd = net_dialer.DefaultNetDialer
}
conn, err := netd.Dial(ctx, "tcp", address)
if err != nil {
return nil, err
}
conn.Close()
}
client = &http.Client{
Transport: &http.Transport{
TLSClientConfig: d.options.TLSConfig,
@ -81,17 +94,16 @@ func (d *http2Dialer) Dial(ctx context.Context, address string, opts ...dialer.D
return netd.Dial(ctx, network, addr)
},
ForceAttemptHTTP2: true,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
MaxIdleConns: 16,
IdleConnTimeout: 30 * time.Second,
TLSHandshakeTimeout: 30 * time.Second,
ExpectContinueTimeout: 15 * time.Second,
},
}
d.clients[address] = client
}
var c net.Conn
c = &conn{
var c net.Conn = &conn{
localAddr: &net.TCPAddr{},
remoteAddr: raddr,
onClose: func() {