From ab0b4410894277ca39b47d681214f61b6dc3dde2 Mon Sep 17 00:00:00 2001 From: Dmitry Motylev Date: Thu, 10 Aug 2017 12:35:26 +0100 Subject: [PATCH] goroutines leak fixed --- resolver_miekg.go | 7 ++++--- resolver_std.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/resolver_miekg.go b/resolver_miekg.go index 1ca0f7f..f4d66f3 100644 --- a/resolver_miekg.go +++ b/resolver_miekg.go @@ -134,9 +134,10 @@ func matchIP(rrs []dns.RR, matcher IPMatcherFunc) (bool, error) { // If any address matches, the mechanism matches func (r *MiekgDNSResolver) MatchIP(name string, matcher IPMatcherFunc) (bool, error) { var wg sync.WaitGroup - hits := make(chan hit) + qTypes := []uint16{dns.TypeA, dns.TypeAAAA} + hits := make(chan hit, len(qTypes)) - for _, qType := range []uint16{dns.TypeA, dns.TypeAAAA} { + for _, qType := range qTypes { wg.Add(1) go func(qType uint16) { defer wg.Done() @@ -184,7 +185,7 @@ func (r *MiekgDNSResolver) MatchMX(name string, matcher IPMatcherFunc) (bool, er } var wg sync.WaitGroup - hits := make(chan hit) + hits := make(chan hit, len(res.Answer)) for _, rr := range res.Answer { mx, ok := rr.(*dns.MX) diff --git a/resolver_std.go b/resolver_std.go index 000a33c..347a92a 100644 --- a/resolver_std.go +++ b/resolver_std.go @@ -117,7 +117,7 @@ func (r *DNSResolver) MatchMX(name string, matcher IPMatcherFunc) (bool, error) } var wg sync.WaitGroup - hits := make(chan hit) + hits := make(chan hit, len(mxs)) for _, mx := range mxs { wg.Add(1)