aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-11-30 22:23:01 +0000
committerNick Mathewson <nickm@torproject.org>2006-11-30 22:23:01 +0000
commitd1fdabf1c738873e805d4d7dd1772dc98666e18f (patch)
treee71fc6639ed20b0d65fbba56de71aa94851dc6a5 /src
parent8e17ffa351afb8f906488a529d9d328d530af341 (diff)
downloadtor-d1fdabf1c738873e805d4d7dd1772dc98666e18f.tar
tor-d1fdabf1c738873e805d4d7dd1772dc98666e18f.tar.gz
r9843@Kushana: nickm | 2006-11-30 17:22:25 -0500
Turn an xxxx0124 into an #ifdef; avoid leaking memory. svn:r9013
Diffstat (limited to 'src')
-rw-r--r--src/or/main.c4
-rw-r--r--src/or/or.h1
-rw-r--r--src/or/routerparse.c31
3 files changed, 23 insertions, 13 deletions
diff --git a/src/or/main.c b/src/or/main.c
index 9f4084b18..ff0e686f6 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1333,8 +1333,6 @@ extern uint64_t buf_total_used;
extern uint64_t buf_total_alloc;
extern uint64_t rephist_total_alloc;
extern uint32_t rephist_total_num;
-// xxxx0124 remove
-void dump_distinct_digests_xx(int severity);
/**
* Write current memory usage information to the log.
@@ -1438,7 +1436,7 @@ dumpstats(int severity)
rep_hist_dump_stats(now,severity);
rend_service_dump_stats(severity);
dump_pk_ops(severity);
- dump_distinct_digests_xx(severity);
+ dump_distinct_digest_count(severity);
}
/** Called by exit() as we shut down the process.
diff --git a/src/or/or.h b/src/or/or.h
index 07baf6b29..214c53968 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -2783,6 +2783,7 @@ int tor_version_as_new_as(const char *platform, const char *cutoff);
int tor_version_compare(tor_version_t *a, tor_version_t *b);
void sort_version_list(smartlist_t *lst, int remove_duplicates);
void assert_addr_policy_ok(addr_policy_t *t);
+void dump_distinct_digest_count(int severity);
networkstatus_t *networkstatus_parse_from_string(const char *s);
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index a592c3d0f..2c3e0d84b 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -699,16 +699,25 @@ router_parse_list_from_string(const char **s, smartlist_t *dest,
return 0;
}
-void dump_distinct_digests_xx(int severity);
-static digestmap_t *verified_digests_tmp = NULL; // XXXX0124 remove me.
-// remove me too.
+/* For debugging: define to count every descriptor digest we've seen so we
+ * know if we need to try harder to avoid duplicate verifies. */
+#undef COUNT_DISTINCT_DIGESTS
+
+#ifdef COUNT_DISTINCT_DIGESTS
+static digestmap_t *verified_digests = NULL;
+#endif
+
void
-dump_distinct_digests_xx(int severity)
+dump_distinct_digest_count(int severity)
{
- if (!verified_digests_tmp)
- verified_digests_tmp = digestmap_new();
+#ifdef COUNT_DISTINCT_DIGESTS
+ if (!verified_digests)
+ verified_digests = digestmap_new();
log(severity, LD_GENERAL, "%d *distinct* router digests verified",
- digestmap_size(verified_digests_tmp));
+ digestmap_size(verified_digests));
+#else
+ (void)severity; /* suppress "unused parameter" warning */
+#endif
}
/** Helper function: reads a single router entry from *<b>s</b> ...
@@ -925,9 +934,11 @@ router_parse_entry_from_string(const char *s, const char *end,
goto err;
}
note_crypto_pk_op(VERIFY_RTR);
- if (!verified_digests_tmp)
- verified_digests_tmp = digestmap_new();
- digestmap_set(verified_digests_tmp, signed_digest, (void*)(uintptr_t)1);
+#ifdef COUNT_DISTINCT_DIGESTS
+ if (!verified_digests)
+ verified_digests = digestmap_new();
+ digestmap_set(verified_digests, signed_digest, (void*)(uintptr_t)1);
+#endif
if ((t=crypto_pk_public_checksig(router->identity_pkey, signed_digest,
tok->object_body, 128)) != 20) {
log_warn(LD_DIR, "Invalid signature %d",t);