Complete multicast requests on first response

This is the simplest thing that works, is consistent with what happens
if there's a local answer, and avoids having all multicast requests
last 250ms or more.

Since we're no longer waiting *at least* the timeout period, I've
bumped the multicast response timeout up to half a second.

There was also a bug whereby the query would be entered into the
inflight map even if the socket write had failed (and the channel had
been closed).
This commit is contained in:
Michael Bridgen committed 2014-10-22 13:35:40 +01:00
1 parent e21069f3ab
commit 156314a802
2 files changed
+9 -7

No files matched your search

+1 -2
View File
@@ -41,10 +41,9 @@ func queryHandler(zone Zone, mdnsClient *MDNSClient) dns.HandlerFunc {
} else {
Debug.Printf("Failed lookup for %s; sending mDNS query", q.Name)
// We don't know the answer; see if someone else does
channel := make(chan *ResponseA, ChannelSize)
channel := make(chan *ResponseA)
replies := make([]net.IP, 0)
go func() {
// Loop terminates when channel is closed by MDNSClient on timeout
for resp := range channel {
Debug.Printf("Got address response %s to query %s addr %s", resp.Name, q.Name, resp.Addr)
replies = append(replies, resp.Addr)