diff options
author | Joshua Colp <jcolp@digium.com> | 2015-05-12 04:59:18 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2015-05-12 04:59:19 -0500 |
commit | 4f84142c9448ac1c5d2d72a9552d18c6f10f786b (patch) | |
tree | d4ea30aafba86ce911e387b8c1d5123f4c0bcc68 /main | |
parent | 4da293459297ed66fbb85aa53e328bd560e73d17 (diff) | |
parent | f82bd76e3c6672b4796d8742baa8125067de3ccf (diff) |
Merge "dns_srv: Fix SRV sorting when records with priority zero exist with non-zero."
Diffstat (limited to 'main')
-rw-r--r-- | main/dns_srv.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/main/dns_srv.c b/main/dns_srv.c index f5d038ae7..e4a3d8bbd 100644 --- a/main/dns_srv.c +++ b/main/dns_srv.c @@ -112,13 +112,15 @@ void dns_srv_sort(struct ast_dns_result *result) struct dns_records newlist = AST_LIST_HEAD_NOLOCK_INIT_VALUE; while (AST_LIST_FIRST(&result->records)) { - unsigned short cur_priority = 0; + unsigned short cur_priority = ((struct ast_dns_srv_record *)(AST_LIST_FIRST(&result->records)))->priority; struct dns_records temp_list = AST_LIST_HEAD_NOLOCK_INIT_VALUE; - /* Find the lowest current priority to work on */ - AST_LIST_TRAVERSE(&result->records, current, list) { - if (!cur_priority || ((struct ast_dns_srv_record *)current)->priority < cur_priority) { - cur_priority = ((struct ast_dns_srv_record *)current)->priority; + /* Find the lowest current priority to work on, but if the priority is already zero there is no lower priority */ + if (cur_priority) { + AST_LIST_TRAVERSE(&result->records, current, list) { + if (((struct ast_dns_srv_record *)current)->priority < cur_priority) { + cur_priority = ((struct ast_dns_srv_record *)current)->priority; + } } } |