[tor-commits] [tor/release-0.2.4] Add dirserv_has_measured_bw() predicate wrapper for dirserv_query_measured_bw_cache()
arma at torproject.org
arma at torproject.org
Thu Apr 11 05:29:51 UTC 2013
commit d64e5969f470a18fe15a6a2863cf4b2b59b1bd27
Author: Andrea Shepard <andrea at torproject.org>
Date: Mon Mar 18 11:56:42 2013 -0700
Add dirserv_has_measured_bw() predicate wrapper for dirserv_query_measured_bw_cache()
---
src/or/dirserv.c | 13 +++++++++----
src/or/dirserv.h | 1 +
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index c769bed..47a4a73 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -1886,8 +1886,7 @@ router_counts_toward_thresholds(const node_t *node, time_t now,
{
/* Have measured bw? */
int have_mbw =
- dirserv_query_measured_bw_cache(node->ri->cache_info.identity_digest,
- NULL, NULL);
+ dirserv_has_measured_bw(node->ri->cache_info.identity_digest);
return node->ri && router_is_active(node->ri, node, now) &&
!digestmap_get(omit_as_sybil, node->ri->cache_info.identity_digest) &&
@@ -2166,6 +2165,13 @@ dirserv_query_measured_bw_cache(const char *node_id, long *bw_out,
return rv;
}
+/** Predicate wrapper for dirserv_query_measured_bw_cache() */
+int
+dirserv_has_measured_bw(const char *node_id)
+{
+ return dirserv_query_measured_bw_cache(node_id, NULL, NULL);
+}
+
/** Get the best estimate of a router's bandwidth for dirauth purposes,
* preferring measured to advertised values if available. */
@@ -2214,8 +2220,7 @@ dirserv_count_measured_bws(routerlist_t *rl)
/* Iterate over the routerlist and count measured bandwidths */
SMARTLIST_FOREACH_BEGIN(rl->routers, routerinfo_t *, ri) {
/* Check if we know a measured bandwidth for this one */
- if (dirserv_query_measured_bw_cache(ri->cache_info.identity_digest,
- NULL, NULL)) {
+ if (dirserv_has_measured_bw(ri->cache_info.identity_digest)) {
++routers_with_measured_bw;
}
} SMARTLIST_FOREACH_END(ri);
diff --git a/src/or/dirserv.h b/src/or/dirserv.h
index 887a499..8728a0b 100644
--- a/src/or/dirserv.h
+++ b/src/or/dirserv.h
@@ -154,6 +154,7 @@ void dirserv_expire_measured_bw_cache(time_t now);
int dirserv_get_measured_bw_cache_size(void);
int dirserv_query_measured_bw_cache(const char *node_id, long *bw_out,
time_t *as_of_out);
+int dirserv_has_measured_bw(const char *node_id);
#endif
int dirserv_read_measured_bandwidths(const char *from_file,
More information about the tor-commits
mailing list