fix: don't close tuic when read timeout

This commit is contained in:
wwqgtxx 2022-11-25 11:04:28 +08:00
parent 30ca59dab7
commit 142d17ebad

View file

@ -214,6 +214,7 @@ func (t *Client) DialContext(ctx context.Context, metadata *C.Metadata, dialFn f
if err != nil {
return nil, err
}
stream, err := func() (quic.Stream, error) {
defer func() {
t.deferQuicConn(quicConn, err)
}()
@ -230,6 +231,9 @@ func (t *Client) DialContext(ctx context.Context, metadata *C.Metadata, dialFn f
if err != nil {
return nil, err
}
return stream, err
}()
if t.RequestTimeout > 0 {
_ = stream.SetReadDeadline(time.Now().Add(time.Duration(t.RequestTimeout) * time.Millisecond))
}