chore: handle the possibility of multiple ClientTrace.GotConn calls

This commit is contained in:
wwqgtxx committed 2026-05-02 19:39:32 +08:00
1 parent 2d94970cab
commit 2a8da25d26
1 file changed
+12 -3
+12 -3
View File
@@ -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
}
},
})