if (!networkstatus_list)
networkstatus_list = smartlist_create();
+ routerlist_check_bug_417();
+
tor_snprintf(filename,sizeof(filename),"%s"PATH_SEPARATOR"cached-status",
get_options()->DataDirectory);
entries = tor_listdir(filename);
smartlist_free(entries);
networkstatus_list_clean(time(NULL));
routers_update_all_from_networkstatus();
+ routerlist_check_bug_417();
return 0;
}
const char *body = signed_descriptor_get_body(desc);
size_t len = desc->signed_descriptor_len;
+ routerlist_check_bug_417();
+
if (purpose != ROUTER_PURPOSE_GENERAL) {
/* we shouldn't cache it. be happy and return. */
return 0;
tor_free(fname);
router_journal_len += len;
+
+ routerlist_check_bug_417();
return 0;
}
if (!routerlist)
return 0;
+ routerlist_check_bug_417();
+
/* Don't save deadweight. */
routerlist_remove_old_routers();
tor_free(fname);
SMARTLIST_FOREACH(chunk_list, sized_chunk_t *, c, tor_free(c));
smartlist_free(chunk_list);
+
+ routerlist_check_bug_417();
return r;
}
size_t fname_len = strlen(options->DataDirectory)+32;
char *fname = tor_malloc(fname_len), *contents = NULL;
+ routerlist_check_bug_417();
+
if (!routerlist)
router_get_routerlist(); /* mallocs and inits it in place */
routerlist_remove_old_routers();
}
+ routerlist_check_bug_417();
+
return 0;
}
routerlist_insert(routerlist_t *rl, routerinfo_t *ri)
{
routerinfo_t *ri_old;
+ routerlist_check_bug_417();
ri_old = digestmap_set(rl->identity_map, ri->cache_info.identity_digest, ri);
tor_assert(!ri_old);
digestmap_set(rl->desc_digest_map, ri->cache_info.signed_descriptor_digest,
ri->routerlist_index = smartlist_len(rl->routers) - 1;
router_dir_info_changed();
// routerlist_assert_ok(rl);
+ routerlist_check_bug_417();
}
/**DOCDOC*/
routerinfo_t *ri = digestmap_get(rl->identity_map,
ei->cache_info.identity_digest);
extrainfo_t *ei_tmp;
+ routerlist_check_bug_417();
if (!ri || routerinfo_incompatible_with_extrainfo(ri,ei)) {
int found = 0;
if (ei->pending_sig || ei->bad_sig) {
extrainfo_free(ei);
- return;
+ goto done;
}
/* The signature checks out; let's see if one of the old routers
* matches. */
});
if (!found) {
extrainfo_free(ei);
- return;
+ goto done;
}
}
ei);
if (ei_tmp)
extrainfo_free(ei_tmp);
+
+ done:
+ routerlist_check_bug_417();
}
/** If we're a directory cache and routerlist <b>rl</b> doesn't have
static void
routerlist_insert_old(routerlist_t *rl, routerinfo_t *ri)
{
+ routerlist_check_bug_417();
if (get_options()->DirPort &&
ri->purpose == ROUTER_PURPOSE_GENERAL &&
!digestmap_get(rl->desc_digest_map,
routerinfo_free(ri);
}
// routerlist_assert_ok(rl);
+ routerlist_check_bug_417();
}
/** Remove an item <b>ri</b> from the routerlist <b>rl</b>, updating indices
{
routerinfo_t *ri_tmp;
extrainfo_t *ei_tmp;
+ routerlist_check_bug_417();
idx = _routerlist_find_elt(rl->routers, ri, idx);
if (idx < 0)
return;
extrainfo_free(ei_tmp);
}
// routerlist_assert_ok(rl);
+ routerlist_check_bug_417();
}
/** DOCDOC */
{
signed_descriptor_t *sd_tmp;
extrainfo_t *ei_tmp;
+ routerlist_check_bug_417();
idx = _routerlist_find_elt(rl->old_routers, sd, idx);
if (idx < 0)
return;
if (ei_tmp)
extrainfo_free(ei_tmp);
+ routerlist_check_bug_417();
// routerlist_assert_ok(rl);
}
{
routerinfo_t *ri_tmp;
extrainfo_t *ei_tmp;
+ routerlist_check_bug_417();
tor_assert(ri_old != ri_new);
idx = _routerlist_find_elt(rl->routers, ri_old, idx);
router_dir_info_changed();
routerinfo_free(ri_old);
}
// routerlist_assert_ok(rl);
+ routerlist_check_bug_417();
}
/** Free all memory held by the routerlist module. */
local_routerstatus_t *status;
tor_assert(digest);
+ routerlist_check_bug_417();
SMARTLIST_FOREACH(trusted_dir_servers, trusted_dir_server_t *, d,
if (!memcmp(d->digest, digest, DIGEST_LEN))
d->is_running = up);
control_event_networkstatus_changed_single(status);
}
router_dir_info_changed();
+ routerlist_check_bug_417();
}
/** Add <b>router</b> to the routerlist, if we don't already have it. Replace
int authdir_believes_valid = 0;
routerinfo_t *old_router;
+ routerlist_check_bug_417();
tor_assert(msg);
if (!routerlist)
tor_assert(msg);
*msg = NULL;
+ routerlist_check_bug_417();
if (!(ri = router_parse_entry_from_string(s, NULL, 1))) {
log_warn(LD_DIR, "Error parsing router descriptor; dropping.");
*msg = "Couldn't parse router descriptor.";
}
}
+/** Debugging function. With any luck, we can remove this soon. Fail with an
+ * assertion if the symptoms for bug 417/404 seem to be present. */
+void
+routerlist_check_bug_417(void)
+{
+ /* XXXX020 remove this function once bug 417/404 is fixed. */
+ routerlist_t *rl = router_get_routerlist();
+ routerinfo_t *ri_generated, *r2, *r;
+ int idx = -1;
+
+ ri_generated = router_get_my_routerinfo();
+
+ r = digestmap_get(rl->identity_map,
+ ri_generated->cache_info.identity_digest);
+ if (r) {
+ idx = r->routerlist_index;
+ tor_assert(idx >= 0);
+ tor_assert(idx < smartlist_len(rl->routers));
+ r2 = smartlist_get(rl->routers, idx);
+ tor_assert(r == r2);
+ } else {
+#if 0
+ /* Too slow; the bug seems to be in the former case anyway. */
+ SMARTLIST_FROEACH(rl->routers, routerinfo_t *, ri,
+ {
+ tor_assert(!router_is_me(ri));
+ });
+#endif
+ }
+
+ tor_assert(ri_generated->routerlist_index == 0);
+}
+
/** Allocate and return a new string representing the contact info
* and platform string for <b>router</b>,
* surrounded by quotes and using standard C escapes.