[asterisk-commits] file: branch group/dns_srv r433304 - /team/group/dns_srv/main/dns_srv.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Mar 23 10:34:43 CDT 2015
Author: file
Date: Mon Mar 23 10:34:41 2015
New Revision: 433304
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=433304
Log:
Fix sorting of SRV records. The code assumed it was pre-sorted based on priority but it is not.
Modified:
team/group/dns_srv/main/dns_srv.c
Modified: team/group/dns_srv/main/dns_srv.c
URL: http://svnview.digium.com/svn/asterisk/team/group/dns_srv/main/dns_srv.c?view=diff&rev=433304&r1=433303&r2=433304
==============================================================================
--- team/group/dns_srv/main/dns_srv.c (original)
+++ team/group/dns_srv/main/dns_srv.c Mon Mar 23 10:34:41 2015
@@ -131,13 +131,22 @@
while (AST_LIST_FIRST(&result->records)) {
unsigned int random_weight;
unsigned int weight_sum;
- unsigned short cur_priority = ((struct ast_dns_srv_record *)AST_LIST_FIRST(&result->records))->priority;
+ unsigned short cur_priority = 0;
struct dns_records temp_list = AST_LIST_HEAD_NOLOCK_INIT_VALUE;
weight_sum = 0;
+ /* 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 all records which match this priority */
AST_LIST_TRAVERSE_SAFE_BEGIN(&result->records, current, list) {
- if (((struct ast_dns_srv_record *)current)->priority != cur_priority)
- break;
+ if (((struct ast_dns_srv_record *)current)->priority != cur_priority) {
+ continue;
+ }
AST_LIST_MOVE_CURRENT(&temp_list, list);
}
More information about the asterisk-commits
mailing list