aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2020-07-14 12:49:14 -0400
committerDavid Goulet <dgoulet@torproject.org>2020-07-20 14:54:13 -0400
commit35871e46e89ae0182703b2e20fe9e9c1e0f20cef (patch)
treecdc1a6bae3c5002a38f8f3d6e672b18bc0b867a4
parent502f3f5afe84d7b5ad02f8fc2262232bbd9beb13 (diff)
downloadtor-35871e46e89ae0182703b2e20fe9e9c1e0f20cef.tar.gz
tor-35871e46e89ae0182703b2e20fe9e9c1e0f20cef.zip
relay: Don't lookup our address before rebuilding our descriptor
Tor periodic events have moved to a role base model where relays have specific events. One of those is to rebuild the descriptor and that is ran every minute. This removes the call to router_rebuild_descriptor() from router_get_my_routerinfo_with_err() because that is the only code path that can call for a rebuild every second. Instead, when we mark the descriptor as dirty, immediately reschedule the descriptor check periodic event so it can be rebuilt that way instead of randomly when router_get_my_routerinfo_with_err() is called. Related to #40025 Signed-off-by: David Goulet <dgoulet@torproject.org>
-rw-r--r--src/feature/relay/router.c26
1 files changed, 4 insertions, 22 deletions
diff --git a/src/feature/relay/router.c b/src/feature/relay/router.c
index cebc44b1f5..2d79a9ba4d 100644
--- a/src/feature/relay/router.c
+++ b/src/feature/relay/router.c
@@ -38,6 +38,7 @@
#include "feature/relay/dns.h"
#include "feature/relay/relay_config.h"
#include "feature/relay/relay_find_addr.h"
+#include "feature/relay/relay_periodic.h"
#include "feature/relay/router.h"
#include "feature/relay/routerkeys.h"
#include "feature/relay/routermode.h"
@@ -1757,16 +1758,6 @@ router_get_my_routerinfo_with_err,(int *err))
return NULL;
}
- if (!desc_clean_since) {
- int rebuild_err = router_rebuild_descriptor(0);
- if (rebuild_err < 0) {
- if (err)
- *err = rebuild_err;
-
- return NULL;
- }
- }
-
if (!desc_routerinfo) {
if (err)
*err = TOR_ROUTERINFO_ERROR_DESC_REBUILDING;
@@ -2400,21 +2391,10 @@ router_rebuild_descriptor(int force)
int err = 0;
routerinfo_t *ri;
extrainfo_t *ei;
- uint32_t addr;
- const or_options_t *options = get_options();
if (desc_clean_since && !force)
return 0;
- if (router_pick_published_address(options, &addr, 0) < 0 ||
- router_get_advertised_or_port(options) == 0) {
- /* Stop trying to rebuild our descriptor every second. We'll
- * learn that it's time to try again when ip_address_changed()
- * marks it dirty. */
- desc_clean_since = time(NULL);
- return TOR_ROUTERINFO_ERROR_DESC_REBUILDING;
- }
-
log_info(LD_OR, "Rebuilding relay descriptor%s", force ? " (forced)" : "");
err = router_build_fresh_descriptor(&ri, &ei);
@@ -2514,11 +2494,13 @@ mark_my_descriptor_dirty(const char *reason)
if (BUG(reason == NULL)) {
reason = "marked descriptor dirty for unspecified reason";
}
- if (server_mode(options) && options->PublishServerDescriptor_)
+ if (server_mode(options) && options->PublishServerDescriptor_) {
log_info(LD_OR, "Decided to publish new relay descriptor: %s", reason);
+ }
desc_clean_since = 0;
if (!desc_dirty_reason)
desc_dirty_reason = reason;
+ reschedule_descriptor_update_check();
}
/** How frequently will we republish our descriptor because of large (factor