[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] short-circuit half the cost of node-picking in the general ...



Update of /home2/or/cvsroot/tor/src/or
In directory moria:/home/arma/work/onion/cvs/tor/src/or

Modified Files:
	routerlist.c 
Log Message:
short-circuit half the cost of node-picking in the general case.


Index: routerlist.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.416
retrieving revision 1.417
diff -u -p -d -r1.416 -r1.417
--- routerlist.c	4 Jan 2006 06:43:03 -0000	1.416
+++ routerlist.c	5 Jan 2006 10:59:46 -0000	1.417
@@ -809,20 +809,22 @@ router_choose_random_node(const char *pr
                           int allow_unverified, int strict)
 {
   smartlist_t *sl, *excludednodes;
-  routerinfo_t *choice;
+  routerinfo_t *choice = NULL;
 
   excludednodes = smartlist_create();
   add_nickname_list_to_smartlist(excludednodes,excluded,0,0,1);
 
   /* Try the preferred nodes first. Ignore need_uptime and need_capacity,
    * since the user explicitly asked for these nodes. */
-  sl = smartlist_create();
-  add_nickname_list_to_smartlist(sl,preferred,1,1,1);
-  smartlist_subtract(sl,excludednodes);
-  if (excludedsmartlist)
-    smartlist_subtract(sl,excludedsmartlist);
-  choice = smartlist_choose(sl);
-  smartlist_free(sl);
+  if (preferred) {
+    sl = smartlist_create();
+    add_nickname_list_to_smartlist(sl,preferred,1,1,1);
+    smartlist_subtract(sl,excludednodes);
+    if (excludedsmartlist)
+      smartlist_subtract(sl,excludedsmartlist);
+    choice = smartlist_choose(sl);
+    smartlist_free(sl);
+  }
   if (!choice && !strict) {
     /* Then give up on our preferred choices: any node
      * will do that has the required attributes. */