forked from quic-go/quic-go
return the cancellation cause for cancelled dials (#4078)
This commit is contained in:
@@ -233,7 +233,7 @@ func (c *client) dial(ctx context.Context) error {
|
|||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
c.conn.shutdown()
|
c.conn.shutdown()
|
||||||
return ctx.Err()
|
return context.Cause(ctx)
|
||||||
case err := <-errorChan:
|
case err := <-errorChan:
|
||||||
return err
|
return err
|
||||||
case recreateErr := <-recreateChan:
|
case recreateErr := <-recreateChan:
|
||||||
|
|||||||
@@ -82,6 +82,26 @@ var _ = Describe("Handshake tests", func() {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
It("returns the cancellation reason when a dial is canceled", func() {
|
||||||
|
ctx, cancel := context.WithCancelCause(context.Background())
|
||||||
|
errChan := make(chan error, 1)
|
||||||
|
go func() {
|
||||||
|
_, err := quic.DialAddr(
|
||||||
|
ctx,
|
||||||
|
"localhost:1234", // nobody is listening on this port, but we're going to cancel this dial anyway
|
||||||
|
getTLSClientConfig(),
|
||||||
|
getQuicConfig(nil),
|
||||||
|
)
|
||||||
|
errChan <- err
|
||||||
|
}()
|
||||||
|
|
||||||
|
cancel(errors.New("application cancelled"))
|
||||||
|
var err error
|
||||||
|
Eventually(errChan).Should(Receive(&err))
|
||||||
|
Expect(err).To(HaveOccurred())
|
||||||
|
Expect(err).To(MatchError("application cancelled"))
|
||||||
|
})
|
||||||
|
|
||||||
Context("using different cipher suites", func() {
|
Context("using different cipher suites", func() {
|
||||||
for n, id := range map[string]uint16{
|
for n, id := range map[string]uint16{
|
||||||
"TLS_AES_128_GCM_SHA256": tls.TLS_AES_128_GCM_SHA256,
|
"TLS_AES_128_GCM_SHA256": tls.TLS_AES_128_GCM_SHA256,
|
||||||
|
|||||||
Reference in New Issue
Block a user