From 5841fa51b0ded33de6a6c4226456b619b16030d0 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Sat, 19 Nov 2022 10:35:45 +0800 Subject: [PATCH] fix: rollback batchExchange's code --- dns/util.go | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/dns/util.go b/dns/util.go index 90693eae..5bf09b8f 100644 --- a/dns/util.go +++ b/dns/util.go @@ -216,7 +216,7 @@ func batchExchange(ctx context.Context, clients []dnsClient, m *D.Msg) (msg *D.M fast, ctx := picker.WithTimeout[*D.Msg](ctx, resolver.DefaultDNSTimeout) for _, client := range clients { r := client - fn := func() (*D.Msg, error) { + fast.Go(func() (*D.Msg, error) { m, err := r.ExchangeContext(ctx, m) if err != nil { return nil, err @@ -224,27 +224,6 @@ func batchExchange(ctx context.Context, clients []dnsClient, m *D.Msg) (msg *D.M return nil, errors.New("server failure") } return m, nil - } - fast.Go(func() (*D.Msg, error) { - ch := make(chan result, 1) - go func() { - m, err := fn() - ch <- result{ - Msg: m, - Error: err, - } - }() - select { - case r := <-ch: - return r.Msg, r.Error - case <-ctx.Done(): - select { - case r := <-ch: - return r.Msg, r.Error - default: - return nil, ctx.Err() - } - } }) }