[asterisk-commits] kpfleming: branch kpfleming/SRV-priority-handling r87201 - /team/kpfleming/SR...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Oct 26 15:56:48 CDT 2007


Author: kpfleming
Date: Fri Oct 26 15:56:48 2007
New Revision: 87201

URL: http://svn.digium.com/view/asterisk?view=rev&rev=87201
Log:
and... we have SRV weight handling now as well... if this code works as it appears it should

Modified:
    team/kpfleming/SRV-priority-handling/main/srv.c

Modified: team/kpfleming/SRV-priority-handling/main/srv.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/SRV-priority-handling/main/srv.c?view=diff&rev=87201&r1=87200&r2=87201
==============================================================================
--- team/kpfleming/SRV-priority-handling/main/srv.c (original)
+++ team/kpfleming/SRV-priority-handling/main/srv.c Fri Oct 26 15:56:48 2007
@@ -182,10 +182,24 @@
 				break;
 			}
 
-			random_weight = 1 + (unsigned int) ((float) weight_sum * (ast_random() / (RAND_MAX + 1.0)));
+			random_weight = 1 + (unsigned int) ((float) weight_sum * (ast_random() / ((float) RAND_MAX + 1.0)));
+
+			AST_LIST_TRAVERSE_SAFE_BEGIN(&temp_list, current, list) {
+				if (current->weight < random_weight)
+					continue;
+
+				AST_LIST_REMOVE_CURRENT(&temp_list, list);
+				AST_LIST_INSERT_TAIL(&newlist, current, list);
+			}
+			AST_LIST_TRAVERSE_SAFE_END;
 		}
 
 	}
+
+	/* now that the new list has been ordered,
+	   put it in place */
+
+	AST_LIST_APPEND_LIST(&context->entries, &newlist, list);
 }
 
 int ast_get_srv(struct ast_channel *chan, char *host, int hostlen, int *port, const char *service)




More information about the asterisk-commits mailing list