dhruvbird/dns-srv — pull request #4 by gavllew (2013-05-14 13:11:42+00:00)
Title: Try all candidates at a given priority before progressing to lower priorities

We have a SRV configuration that is designed to load-balance across two servers with equal priority and weighting. However, if one of those servers was down, every other connection attempt would fail - the code is only attempting one candidate per priority.

RFC 2782 has the following to say regarding priority:
Priority
The priority of this target host. A client MUST attempt to
contact the target host with the lowest-numbered priority it can
reach; target hosts with the same priority SHOULD be tried in an
order defined by the weight field. The range is 0-65535. This
is a 16 bit unsigned integer in network byte order.

This suggests that other candidates at the same priority should also be tried. My change adds all available candidates to the target list, but the order of the candidates depends first on the priority, and second on the weighting.