[or-cvs] Scan list of servers in directory after reloading fingerpri...
Nick Mathewson
nickm at seul.org
Tue Apr 13 20:06:10 UTC 2004
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv26911/src/or
Modified Files:
dirserv.c
Log Message:
Scan list of servers in directory after reloading fingerprint list; remove any servers that are no longer recognized.
Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dirserv.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- dirserv.c 6 Apr 2004 20:16:12 -0000 1.36
+++ dirserv.c 13 Apr 2004 20:06:08 -0000 1.37
@@ -15,6 +15,7 @@
static int the_directory_is_dirty = 1;
static int list_running_servers(char **nicknames_out);
+static void directory_remove_unrecognized(void);
/************** Fingerprint handling code ************/
@@ -98,6 +99,8 @@
memcpy(fingerprint_list, fingerprint_list_tmp,
sizeof(fingerprint_entry_t)*n_fingerprints_tmp);
n_fingerprints = n_fingerprints_tmp;
+ /* Delete any routers whose fingerprints we no longer recognize */
+ directory_remove_unrecognized();
return 0;
}
/* error */
@@ -163,6 +166,7 @@
time_t published;
size_t desc_len;
char *descriptor;
+ routerinfo_t *router;
} descriptor_entry_t;
static descriptor_entry_t *descriptor_list[MAX_ROUTERS_IN_DIR];
@@ -172,6 +176,7 @@
{
tor_free(desc->descriptor);
tor_free(desc->nickname);
+ routerinfo_free(desc->router);
free(desc);
}
@@ -293,13 +298,27 @@
(*desc_ent_ptr)->descriptor = tor_malloc(desc_len+1);
strncpy((*desc_ent_ptr)->descriptor, start, desc_len);
(*desc_ent_ptr)->descriptor[desc_len] = '\0';
+ (*desc_ent_ptr)->router = ri;
*desc = end;
directory_set_dirty();
- routerinfo_free(ri);
return 1;
}
+static void
+directory_remove_unrecognized(void)
+{
+ int i;
+ for (i = 0; i < n_descriptors; ++i) {
+ if (dirserv_router_fingerprint_is_known(descriptor_list[i]->router)<=0) {
+ log(LOG_INFO, "Router %s is no longer recognized",
+ descriptor_list[i]->nickname);
+ free_descriptor_entry(descriptor_list[i]);
+ descriptor_list[i--] = descriptor_list[--n_descriptors];
+ }
+ }
+}
+
void
directory_set_dirty()
{
More information about the tor-commits
mailing list