aboutsummaryrefslogtreecommitdiff
path: root/src/or/rephist.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-12-07 15:29:54 +0000
committerRoger Dingledine <arma@torproject.org>2004-12-07 15:29:54 +0000
commit802d374a99cae37ec33a098e4df79cd9165e624e (patch)
tree46a58925649c55096ac1911a5e64184570ba61e8 /src/or/rephist.c
parenta2d80ec767b68482e6ed98fefc3162e8ab1fdb93 (diff)
downloadtor-802d374a99cae37ec33a098e4df79cd9165e624e.tar.gz
tor-802d374a99cae37ec33a098e4df79cd9165e624e.zip
I'm a bad person.
Stop treating the uint16_t's as null-terminated strings, and stop looking at the byte after them to see if it's null, because sometimes you're not allowed to look there. svn:r3108
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r--src/or/rephist.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c
index b08150be4d..568988f269 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -666,12 +666,14 @@ void rep_hist_note_used_port(uint16_t port, time_t now) {
add_predicted_port(port, now);
}
-#define PREFERRED_PORTS_RELEVANCE_TIME (6*3600) /* 6 hours */
+#define PREDICTED_PORTS_RELEVANCE_TIME (6*3600) /* 6 hours */
-/** Allocate and return a string of space-separated port numbers that
+/** Return a pointer to the list of port numbers that
* are likely to be asked for in the near future.
+ *
+ * The caller promises not to mess with it.
*/
-char *rep_hist_get_predicted_ports(time_t now) {
+smartlist_t *rep_hist_get_predicted_ports(time_t now) {
int i;
uint16_t *tmp_port;
time_t *tmp_time;
@@ -682,8 +684,9 @@ char *rep_hist_get_predicted_ports(time_t now) {
/* clean out obsolete entries */
for (i = 0; i < smartlist_len(predicted_ports_list); ++i) {
tmp_time = smartlist_get(predicted_ports_times, i);
- if (*tmp_time + PREFERRED_PORTS_RELEVANCE_TIME < now) {
+ if (*tmp_time + PREDICTED_PORTS_RELEVANCE_TIME < now) {
tmp_port = smartlist_get(predicted_ports_list, i);
+ log_fn(LOG_DEBUG, "Expiring predicted port %d", *tmp_port);
smartlist_del(predicted_ports_list, i);
smartlist_del(predicted_ports_times, i);
tor_free(tmp_port);
@@ -691,6 +694,6 @@ char *rep_hist_get_predicted_ports(time_t now) {
i--;
}
}
- return smartlist_join_strings(predicted_ports_list, " ", 0, NULL);
+ return predicted_ports_list;
}