Skip to content

Commit

Permalink
goroutines leak fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
dmotylev authored and zaccone committed Aug 11, 2017
1 parent 692baf2 commit ab0b441
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions resolver_miekg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion resolver_std.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ab0b441

Please sign in to comment.