[or-cvs] cleanups on 008pre1 items
Roger Dingledine
arma at seul.org
Wed Jun 30 21:48:05 UTC 2004
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
directory.c dirserv.c main.c router.c routerlist.c
Log Message:
cleanups on 008pre1 items
Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/src/or/directory.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- directory.c 25 Jun 2004 00:29:30 -0000 1.110
+++ directory.c 30 Jun 2004 21:48:02 -0000 1.111
@@ -80,6 +80,9 @@
directory_get_from_dirserver(uint8_t purpose, const char *payload,
int payload_len)
{
+ /* FFFF we might pass pick_directory_server a boolean to prefer
+ * picking myself for some purposes, or prefer picking not myself
+ * for other purposes. */
directory_initiate_command(router_pick_directory_server(),
purpose, payload, payload_len);
}
@@ -498,6 +501,10 @@
if(!strcmp(url,"/running-routers")) { /* running-routers fetch */
dlen = dirserv_get_runningrouters(&cp);
+ if(dlen < 0) { /* we failed to create cp */
+ connection_write_to_buf(answer503, strlen(answer503), conn);
+ return 0;
+ }
snprintf(tmp, sizeof(tmp), "HTTP/1.0 200 OK\r\nContent-Length: %d\r\nContent-Type: text/plain\r\n\r\n",
(int)dlen);
Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dirserv.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- dirserv.c 30 Jun 2004 16:37:08 -0000 1.56
+++ dirserv.c 30 Jun 2004 21:48:02 -0000 1.57
@@ -455,6 +455,7 @@
continue; /* only list successfully handshaked OR's. */
if(!conn->nickname) /* it's an OP, don't list it */
continue;
+ /* XXX008 need to change this to list "!nickname" for down routers */
if (!router_nickname_is_approved(conn->nickname))
continue; /* If we removed them from the approved list, don't list it.*/
smartlist_add(nicknames, conn->nickname);
@@ -580,7 +581,7 @@
/** Most recently generated encoded signed directory. */
static char *the_directory = NULL;
static int the_directory_len = -1;
-static char *cached_directory = NULL;
+static char *cached_directory = NULL; /* used only by non-auth dirservers */
static time_t cached_directory_published = 0;
static int cached_directory_len = -1;
@@ -588,8 +589,7 @@
{
time_t now;
char filename[512];
- if (!options.AuthoritativeDir)
- return;
+ tor_assert(!options.AuthoritativeDir);
now = time(NULL);
if (when>cached_directory_published &&
when<now+ROUTER_ALLOW_SKEW) {
Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.286
retrieving revision 1.287
diff -u -d -r1.286 -r1.287
--- main.c 30 Jun 2004 16:37:08 -0000 1.286
+++ main.c 30 Jun 2004 21:48:02 -0000 1.287
@@ -451,18 +451,14 @@
router_rebuild_descriptor();
router_upload_dir_desc_to_dirservers();
}
- if(!options.DirPort || !options.AuthoritativeDir) {
- /* XXXX should directories do this next part too? */
- routerlist_remove_old_routers(); /* purge obsolete entries */
- directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 0);
- } else {
+ routerlist_remove_old_routers(); /* purge obsolete entries */
+ if(options.AuthoritativeDir) {
/* We're a directory; dump any old descriptors. */
dirserv_remove_old_servers();
/* dirservers try to reconnect too, in case connections have failed */
router_retry_connections();
- /* fetch another directory, in case it knows something we don't */
- directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 0);
}
+ directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 0);
/* Force an upload of our descriptors every DirFetchPostPeriod seconds. */
rend_services_upload(1);
last_uploaded_services = now;
Index: router.c
===================================================================
RCS file: /home/or/cvsroot/src/or/router.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- router.c 30 Jun 2004 16:37:08 -0000 1.52
+++ router.c 30 Jun 2004 21:48:02 -0000 1.53
@@ -285,14 +285,16 @@
if(!cp) {
log_fn(LOG_INFO,"Cached directory %s not present. Ok.",keydir);
} else {
- if(options.AuthoritativeDir && dirserv_load_from_directory_string(cp) < 0){
- log_fn(LOG_ERR, "Cached directory %s is corrupt", keydir);
- tor_free(cp);
- return -1;
+ if(options.AuthoritativeDir)
+ if(dirserv_load_from_directory_string(cp) < 0){
+ log_fn(LOG_ERR, "Cached directory %s is corrupt", keydir);
+ tor_free(cp);
+ return -1;
+ }
+ } else {
+ /* set time to 1 so it will be replaced on first download. */
+ dirserv_set_cached_directory(cp, 1);
}
- /* set time to 1 so it will be replaced on first download.
- */
- dirserv_set_cached_directory(cp, 1);
tor_free(cp);
}
/* success */
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- routerlist.c 30 Jun 2004 16:48:36 -0000 1.88
+++ routerlist.c 30 Jun 2004 21:48:02 -0000 1.89
@@ -477,11 +477,13 @@
log_fn(LOG_WARN, "Error resolving routerlist");
return -1;
}
- /* Remember the directory, if we're nonauthoritative.*/
- dirserv_set_cached_directory(s, routerlist->published_on);
- /* Learn about the descriptors in the directory, if we're authoritative */
- if (options.AuthoritativeDir)
+ if (options.AuthoritativeDir) {
+ /* Learn about the descriptors in the directory. */
dirserv_load_from_directory_string(s);
+ } else {
+ /* Remember the directory. */
+ dirserv_set_cached_directory(s, routerlist->published_on);
+ }
return 0;
}
@@ -657,16 +659,17 @@
router = smartlist_get(list->routers, i);
for (j=0; j<n_names; ++j) {
name = smartlist_get(rr->running_routers, j);
- if (!strcmp(name, router->nickname)) {
- running=1;
+ if (!strcasecmp(name, router->nickname)) {
+ router->is_running = 1;
+ break;
+ }
+ if (*name == '!' && strcasecmp(name+1, router->nickname)) {
+ router->is_running = 0;
break;
}
}
- router->is_running = 1; /* arma: is this correct? */
}
list->running_routers_updated_on = rr->published_on;
- /* XXXX008 Should there also be a list of which are down, so that we
- * don't mark merely unknown routers as down? */
}
/*
More information about the tor-commits
mailing list