aboutsummaryrefslogtreecommitdiff
path: root/src/or/rephist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-05-16 10:40:21 -0400
committerNick Mathewson <nickm@torproject.org>2012-05-16 10:40:21 -0400
commitee246bbe95a3adbc86ac8eb3794f55011c2059d5 (patch)
tree9cc5db4e694a246d2f806c0da2cd747bb004ece4 /src/or/rephist.c
parent891cf72f7103bc5b4de26ac974c0fd42a9d3c88f (diff)
parent0888c2f8f55037b49fead49091013f2cc7de17c5 (diff)
downloadtor-ee246bbe95a3adbc86ac8eb3794f55011c2059d5.tar
tor-ee246bbe95a3adbc86ac8eb3794f55011c2059d5.tar.gz
Merge remote-tracking branch 'public/bug3296'
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r--src/or/rephist.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 59e08e59f..0727c6851 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -1868,6 +1868,26 @@ rep_hist_get_predicted_ports(time_t now)
return out;
}
+/**
+ * Take a list of uint16_t *, and remove every port in the list from the
+ * current list of predicted ports.
+ */
+void
+rep_hist_remove_predicted_ports(const smartlist_t *rmv_ports)
+{
+ /* Let's do this on O(N), not O(N^2). */
+ bitarray_t *remove_ports = bitarray_init_zero(UINT16_MAX);
+ SMARTLIST_FOREACH(rmv_ports, const uint16_t *, p,
+ bitarray_set(remove_ports, *p));
+ SMARTLIST_FOREACH_BEGIN(predicted_ports_list, predicted_port_t *, pp) {
+ if (bitarray_is_set(remove_ports, pp->port)) {
+ tor_free(pp);
+ SMARTLIST_DEL_CURRENT(predicted_ports_list, pp);
+ }
+ } SMARTLIST_FOREACH_END(pp);
+ bitarray_free(remove_ports);
+}
+
/** The user asked us to do a resolve. Rather than keeping track of
* timings and such of resolves, we fake it for now by treating
* it the same way as a connection to port 80. This way we will continue