[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] possibly incorrect) code to make routers get resolved when ...
- To: or-cvs@freehaven.net
- Subject: [or-cvs] possibly incorrect) code to make routers get resolved when ...
- From: nickm@seul.org (Nick Mathewson)
- Date: Thu, 8 May 2003 08:32:33 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Thu, 08 May 2003 08:32:47 -0400
- Reply-to: or-dev@freehaven.net
- Sender: owner-or-cvs@freehaven.net
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv24399/src/or
Modified Files:
or.h routers.c
Log Message:
(possibly incorrect) code to make routers get resolved when they're
inserted into the directory.
Roger: If you can answer the question with your name on it, you may
prevent a segfault before it happens. :)
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- or.h 8 May 2003 03:36:53 -0000 1.80
+++ or.h 8 May 2003 12:32:30 -0000 1.81
@@ -798,6 +798,8 @@
void router_forget_router(uint32_t addr, uint16_t port);
int router_get_list_from_file(char *routerfile);
int router_resolve(routerinfo_t *router);
+int router_resolve_directory(directory_t *dir);
+
/* Reads a list of known routers, unsigned. */
int router_get_list_from_string(char *s);
/* Exported for debugging */
Index: routers.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routers.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- routers.c 7 May 2003 18:39:44 -0000 1.26
+++ routers.c 8 May 2003 12:32:30 -0000 1.27
@@ -518,7 +518,10 @@
int router_get_list_from_string(char *s)
{
- return router_get_list_from_string_impl(s, &directory);
+ int i;
+ i = router_get_list_from_string_impl(s, &directory);
+ router_resolve_directory(directory);
+ return i;
}
int router_get_list_from_string_impl(char *s, directory_t **dest) {
@@ -548,7 +551,10 @@
int router_get_dir_from_string(char *s, crypto_pk_env_t *pkey)
{
- return router_get_dir_from_string_impl(s, &directory, pkey);
+ int i;
+ i = router_get_dir_from_string_impl(s, &directory, pkey);
+ router_resolve_directory(directory);
+ return i;
}
int router_get_dir_from_string_impl(char *s, directory_t **dest,
@@ -675,6 +681,28 @@
memcpy(&router->addr, rent->h_addr,rent->h_length);
router->addr = ntohl(router->addr); /* get it back into host order */
+ return 0;
+}
+
+int
+router_resolve_directory(directory_t *dir)
+{
+ int i, max;
+ if (!dir)
+ dir = directory;
+
+ max = dir->n_routers;
+ for (i = 0; i < max; ++i) {
+ if (router_resolve(dir->routers[i])) {
+ /* ARMA: Is this the right way to remove a router from the directory? */
+ dir->routers[i]->next = NULL;
+ routerlist_free(dir->routers[i]);
+ dir->routers[i] = dir->routers[--max];
+ dir->routers[max] = NULL;
+ --dir->n_routers;
+ }
+ }
+
return 0;
}