[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Fix a bug weasel found: when we are an authority and somebo...
Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv14151/src/or
Modified Files:
dirserv.c
Log Message:
Fix a bug weasel found: when we are an authority and somebody requests "all" statuses, cconsider regenerating our own.
Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/dirserv.c,v
retrieving revision 1.269
retrieving revision 1.270
diff -u -d -r1.269 -r1.270
--- dirserv.c 20 Nov 2005 16:53:49 -0000 1.269
+++ dirserv.c 29 Nov 2005 17:14:10 -0000 1.270
@@ -1139,6 +1139,14 @@
/** For authoritative directories: the current (v2) network status */
static cached_dir_t the_v2_networkstatus = { NULL, NULL, 0, 0, 0 };
+static int
+should_generate_v2_networkstatus(void)
+{
+ return get_options()->AuthoritativeDir &&
+ the_v2_networkstatus_is_dirty &&
+ the_v2_networkstatus_is_dirty + DIR_REGEN_SLACK_TIME < time(NULL);
+}
+
/** For authoritative directories only: replace the contents of
* <b>the_v2_networkstatus</b> with a newly generated network status
* object. */
@@ -1336,7 +1344,10 @@
warn(LD_BUG,"Unable to generate an authoritative network status.");
}
} else if (!strcmp(key, "all")) {
- digestmap_iter_t *iter = digestmap_iter_init(cached_v2_networkstatus);
+ digestmap_iter_t *iter;
+ if (should_generate_v2_networkstatus(void))
+ generate_v2_networkstatus();
+ iter = digestmap_iter_init(cached_v2_networkstatus);
while (!digestmap_iter_done(iter)) {
const char *ident;
void *val;
@@ -1353,10 +1364,7 @@
SMARTLIST_FOREACH(digests, char *, cp,
{
cached_dir_t *cached;
- if (router_digest_is_me(cp) &&
- get_options()->AuthoritativeDir &&
- the_v2_networkstatus_is_dirty &&
- the_v2_networkstatus_is_dirty + DIR_REGEN_SLACK_TIME < time(NULL))
+ if (router_digest_is_me(cp) && should_generate_v2_networkstatus(void))
generate_v2_networkstatus();
cached = digestmap_get(cached_v2_networkstatus, cp);
if (cached) {