[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Only warn once per nickname from add_nickname_list_to_smart...
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] Only warn once per nickname from add_nickname_list_to_smart...
- From: nickm@xxxxxxxx (Nick Mathewson)
- Date: Sun, 3 Apr 2005 00:53:37 -0500 (EST)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Sun, 03 Apr 2005 00:54:00 -0500
- Reply-to: or-dev@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv30424/src/or
Modified Files:
routerlist.c
Log Message:
Only warn once per nickname from add_nickname_list_to_smartlist per failure.
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.224
retrieving revision 1.225
diff -u -d -r1.224 -r1.225
--- routerlist.c 2 Apr 2005 22:02:13 -0000 1.224
+++ routerlist.c 3 Apr 2005 05:53:34 -0000 1.225
@@ -288,6 +288,10 @@
}
}
+/** List of string for nicknames we've warned about and haven't yet succeeded.
+ */
+static smartlist_t *warned_nicknames = NULL;
+
/** Given a comma-and-whitespace separated list of nicknames, see which
* nicknames in <b>list</b> name routers in our routerlist that are
* currently running. Add the routerinfos for those routers to <b>sl</b>.
@@ -303,25 +307,39 @@
tor_assert(sl);
nickname_list = smartlist_create();
+ if (!warned_nicknames)
+ warned_nicknames = smartlist_create();
smartlist_split_string(nickname_list, list, ",",
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
SMARTLIST_FOREACH(nickname_list, const char *, nick, {
+ int warned;
if (!is_legal_nickname_or_hexdigest(nick)) {
log_fn(LOG_WARN,"Nickname %s is misformed; skipping", nick);
continue;
}
router = router_get_by_nickname(nick);
+ warned = smartlist_string_isin(warned_nicknames, nick);
if (router) {
- if (router->is_running)
+ if (router->is_running) {
smartlist_add(sl,router);
- else
- log_fn(warn_if_down ? LOG_WARN : LOG_DEBUG,
- "Nickname list includes '%s' which is known but down.",nick);
- } else
- log_fn(has_fetched_directory ? LOG_WARN : LOG_INFO,
- "Nickname list includes '%s' which isn't a known router.",nick);
+ if (warned)
+ smartlist_string_remove(warned_nicknames, nick);
+ } else {
+ if (!warned) {
+ log_fn(warn_if_down ? LOG_WARN : LOG_DEBUG,
+ "Nickname list includes '%s' which is known but down.",nick);
+ smartlist_add(warned_nicknames, tor_strdup(nick));
+ }
+ }
+ } else {
+ if (!warned) {
+ log_fn(has_fetched_directory ? LOG_WARN : LOG_INFO,
+ "Nickname list includes '%s' which isn't a known router.",nick);
+ smartlist_add(warned_nicknames, tor_strdup(nick));
+ }
+ }
});
SMARTLIST_FOREACH(nickname_list, char *, nick, tor_free(nick));
smartlist_free(nickname_list);
@@ -733,6 +751,11 @@
if (routerlist)
routerlist_free(routerlist);
routerlist = NULL;
+ if (warned_nicknames) {
+ SMARTLIST_FOREACH(warned_nicknames, char *, cp, tor_free(cp));
+ smartlist_free(warned_nicknames);
+ warned_nicknames = NULL;
+ }
}
void free_trusted_dir_servers(void)