aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection_or.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-07-11 16:10:24 -0400
committerNick Mathewson <nickm@torproject.org>2011-07-11 16:13:17 -0400
commit2a594fcde94ada2ef38d33d306b7df189a5e495c (patch)
treee195a35db465872a82795d2804f1a687b81b6e22 /src/or/connection_or.c
parente253e9577fb7d76bd534b343f0f63559b9a47b4a (diff)
downloadtor-2a594fcde94ada2ef38d33d306b7df189a5e495c.tar
tor-2a594fcde94ada2ef38d33d306b7df189a5e495c.tar.gz
Disable recording new broken conns when we have bootstrapped
Rationale: right now there seems to be no way for our bootstrap status to dip under 100% once it has reached 100%. Thus, recording broken connections after that point is useless, and wastes memory. If at some point in the future we allow our bootstrap level to go backwards, then we should change this rule so that we disable recording broken connection states _as long as_ the bootstrap status is 100%.
Diffstat (limited to 'src/or/connection_or.c')
-rw-r--r--src/or/connection_or.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index e755c7eb8..94f8e227b 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -158,12 +158,18 @@ connection_or_set_identity_digest(or_connection_t *conn, const char *digest)
*/
static strmap_t *broken_connection_counts;
+/** If true, do not record information in <b>broken_connection_counts</b>. */
+static int disable_broken_connection_counts = 0;
+
/** Record that an OR connection failed in <b>state</b>. */
static void
note_broken_connection(const char *state)
{
void *ptr;
intptr_t val;
+ if (disable_broken_connection_counts)
+ return;
+
if (!broken_connection_counts)
broken_connection_counts = strmap_new();
@@ -174,13 +180,16 @@ note_broken_connection(const char *state)
strmap_set(broken_connection_counts, state, ptr);
}
-/** Forget all recorded states for failed connections. */
+/** Forget all recorded states for failed connections. If
+ * <b>stop_recording</b> is true, don't record any more. */
void
-clear_broken_connection_map(void)
+clear_broken_connection_map(int stop_recording)
{
if (broken_connection_counts)
strmap_free(broken_connection_counts, NULL);
broken_connection_counts = NULL;
+ if (stop_recording)
+ disable_broken_connection_counts = 1;
}
/** Write a detailed description the state of <b>orconn</b> into the
@@ -209,6 +218,8 @@ static void
connection_or_note_state_when_broken(or_connection_t *orconn)
{
char buf[256];
+ if (disable_broken_connection_counts)
+ return;
connection_or_get_state_description(orconn, buf, sizeof(buf));
log_info(LD_HANDSHAKE,"Connection died in state '%s'", buf);
note_broken_connection(buf);
@@ -240,7 +251,7 @@ connection_or_report_broken_states(int severity, int domain)
int total = 0;
smartlist_t *items;
- if (!broken_connection_counts)
+ if (!broken_connection_counts || disable_broken_connection_counts)
return;
items = smartlist_create();