mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-12-02 18:16:47 +00:00
chore: handle the possibility of multiple ClientTrace.GotConn calls
This commit is contained in:
1 parent
2d94970cab
commit
2a8da25d26
1 file changed
+12
-3
@@ -354,7 +354,10 @@ func (c *Client) DialStreamOne(ctx context.Context) (net.Conn, error) {
|
||||
addrCtx := httputils.NewAddrContext(&conn.NetAddr, reqCtx)
|
||||
streamCtx := httptrace.WithClientTrace(addrCtx, &httptrace.ClientTrace{
|
||||
GotConn: func(info httptrace.GotConnInfo) {
|
||||
gotConn <- true
|
||||
select {
|
||||
case gotConn <- true:
|
||||
default: // GotConn maybe called multiple times, ignore the second and later calls
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -452,7 +455,10 @@ func (c *Client) DialStreamUp(ctx context.Context) (net.Conn, error) {
|
||||
addrCtx := httputils.NewAddrContext(&conn.NetAddr, reqCtx)
|
||||
downloadCtx := httptrace.WithClientTrace(addrCtx, &httptrace.ClientTrace{
|
||||
GotConn: func(info httptrace.GotConnInfo) {
|
||||
gotConn <- true
|
||||
select {
|
||||
case gotConn <- true:
|
||||
default: // GotConn maybe called multiple times, ignore the second and later calls
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -596,7 +602,10 @@ func (c *Client) DialPacketUp(ctx context.Context) (net.Conn, error) {
|
||||
addrCtx := httputils.NewAddrContext(&conn.NetAddr, reqCtx)
|
||||
downloadCtx := httptrace.WithClientTrace(addrCtx, &httptrace.ClientTrace{
|
||||
GotConn: func(info httptrace.GotConnInfo) {
|
||||
gotConn <- true
|
||||
select {
|
||||
case gotConn <- true:
|
||||
default: // GotConn maybe called multiple times, ignore the second and later calls
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user