[or-cvs] r9435: avoid messy crashes (bugfix by nick) (tor/trunk/src/or)

arma at seul.org arma at seul.org
Sat Jan 27 18:33:35 UTC 2007


Author: arma
Date: 2007-01-27 13:33:33 -0500 (Sat, 27 Jan 2007)
New Revision: 9435

Modified:
   tor/trunk/src/or/routerlist.c
Log:
avoid messy crashes (bugfix by nick)


Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2007-01-27 09:24:23 UTC (rev 9434)
+++ tor/trunk/src/or/routerlist.c	2007-01-27 18:33:33 UTC (rev 9435)
@@ -1053,7 +1053,7 @@
 routerstatus_t *
 routerstatus_sl_choose_by_bandwidth(smartlist_t *sl)
 {
-  return smartlist_choose_by_bandwidth(sl, 1, 0);
+  return smartlist_choose_by_bandwidth(sl, 1, 1);
 }
 
 /** Return a random running router from the routerlist.  If any node
@@ -2630,6 +2630,25 @@
   return best;
 }
 
+/** Find a routerstatus_t that corresponds to <b>hexdigest</b>, if
+ * any. Prefer ones that belong to authorities. */
+routerstatus_t *
+routerstatus_get_by_hexdigest(const char *hexdigest)
+{
+  char digest[DIGEST_LEN];
+  local_routerstatus_t *rs;
+  trusted_dir_server_t *ds;
+
+  if (strlen(hexdigest) < HEX_DIGEST_LEN ||
+      base16_decode(digest,DIGEST_LEN,hexdigest,HEX_DIGEST_LEN) < 0)
+    return NULL;
+  if ((ds = router_get_trusteddirserver_by_digest(digest)))
+    return &(ds->fake_status.status);
+  if ((rs = router_get_combined_status_by_digest(digest)))
+    return &(rs->status);
+  return NULL;
+}
+
 /** Return true iff any networkstatus includes a descriptor whose digest
  * is that of <b>desc</b>. */
 static int



More information about the tor-commits mailing list