dns_srv: Fix SRV sorting when records with priority zero exist with non-zero.
authorJoshua Colp <jcolp@digium.com>
Sun, 10 May 2015 13:36:51 +0000 (10:36 -0300)
committerJoshua Colp <jcolp@digium.com>
Sun, 10 May 2015 13:39:32 +0000 (10:39 -0300)
commitf82bd76e3c6672b4796d8742baa8125067de3ccf
tree67e98f65479bb0918d63d78a31fa886175228757
parent32eb812b28ffc1745e08cb507d8c4409d3ed297a
dns_srv: Fix SRV sorting when records with priority zero exist with non-zero.

The DNS SRV sorting code currently has an issue when records with a priority
of zero exist with records of a non-zero priority. This occurs because the
sorting code considers zero to mean unset when in reality is a valid
value. If the current priority is zero it will get replaced with any remaining
record that has a priority of non-zero, until no records of those exist after
which the records of priority zero are handled.

This change makes it so that the priority of the first remaining record is
the current starting priority. There is also a small optimization to prevent
iterating records when the starting priority is already zero.

Change-Id: I103511f35b50428f770bd4db3ffef70fb6f82d35
main/dns_srv.c