[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Rate-limit warnings related to unrecognized MyFamily elemen...
Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv19514/src/or
Modified Files:
main.c or.h router.c
Log Message:
Rate-limit warnings related to unrecognized MyFamily elements.
Index: main.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.573
retrieving revision 1.574
diff -u -d -r1.573 -r1.574
--- main.c 5 Oct 2005 22:36:33 -0000 1.573
+++ main.c 5 Oct 2005 23:20:45 -0000 1.574
@@ -926,6 +926,7 @@
if (accounting_is_enabled(options))
accounting_record_bandwidth_usage(time(NULL));
+ router_reset_warnings();
routerlist_reset_warnings();
addressmap_clear_transient();
/* first, reload config variables, in case they've changed */
@@ -1382,7 +1383,7 @@
connection_free_all();
if (!postfork) {
config_free_all();
- router_free_all_keys();
+ router_free_all();
}
tor_tls_free_all();
/* stuff in main.c */
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.707
retrieving revision 1.708
diff -u -d -r1.707 -r1.708
--- or.h 5 Oct 2005 22:31:21 -0000 1.707
+++ or.h 5 Oct 2005 23:20:45 -0000 1.708
@@ -2055,7 +2055,8 @@
crypto_pk_env_t *ident_key);
int is_legal_nickname(const char *s);
int is_legal_nickname_or_hexdigest(const char *s);
-void router_free_all_keys(void);
+void router_reset_warnings(void);
+void router_free_all(void);
/********************************* routerlist.c ***************************/
Index: router.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/router.c,v
retrieving revision 1.215
retrieving revision 1.216
diff -u -d -r1.215 -r1.216
--- router.c 4 Oct 2005 22:23:31 -0000 1.215
+++ router.c 5 Oct 2005 23:20:45 -0000 1.216
@@ -756,6 +756,9 @@
return desc_routerinfo->signed_descriptor;
}
+/*DOCDOC*/
+static smartlist_t *warned_nonexistent_family = NULL;
+
/** If <b>force</b> is true, or our descriptor is out-of-date, rebuild
* a fresh routerinfo and signed server descriptor for this OR.
* Return 0 on success, -1 on error.
@@ -810,6 +813,8 @@
if (authdir_mode(options))
ri->is_verified = ri->is_named = 1; /* believe in yourself */
if (options->MyFamily) {
+ if (!warned_nonexistent_family)
+ warned_nonexistent_family = smartlist_create();
smartlist_t *family = smartlist_create();
ri->declared_family = smartlist_create();
smartlist_split_string(family, options->MyFamily, ",",
@@ -822,9 +827,12 @@
else
member = router_get_by_nickname(name, 1);
if (!member) {
- log_fn(LOG_WARN, "I have no descriptor for the router named \"%s\" "
- "in my declared family; I'll use the nickname verbatim, but "
- "this may confuse clients.", name);
+ if (!smartlist_string_isin(warned_nonexistent_family, name)) {
+ log_fn(LOG_WARN, "I have no descriptor for the router named \"%s\" "
+ "in my declared family; I'll use the nickname as is, but "
+ "this may confuse clients.", name);
+ smartlist_add(warned_nonexistent_family, tor_strdup(name));
+ }
smartlist_add(ri->declared_family, name);
name = NULL;
} else {
@@ -833,6 +841,8 @@
base16_encode(fp+1,HEX_DIGEST_LEN+1,
member->identity_digest, DIGEST_LEN);
smartlist_add(ri->declared_family, fp);
+ if (smartlist_string_isin(warned_nonexistent_family, name))
+ smartlist_string_remove(warned_nonexistent_family, name);
}
tor_free(name);
});
@@ -1135,9 +1145,20 @@
return len == HEX_DIGEST_LEN+1 && strspn(s+1,HEX_CHARACTERS)==len-1;
}
-/** Release all resources held in router keys. */
+/** Forget that we have issued any router-related warnings, so that we'll
+ * warn again if we see the same errors. */
void
-router_free_all_keys(void)
+router_reset_warnings(void)
+{
+ if (warned_nonexistent_family) {
+ SMARTLIST_FOREACH(warned_nonexistent_family, char *, cp, tor_free(cp));
+ smartlist_clear(warned_nonexistent_family);
+ }
+}
+
+/** Release all static resources held in router.c */
+void
+router_free_all(void)
{
if (onionkey)
crypto_free_pk_env(onionkey);
@@ -1149,5 +1170,8 @@
tor_mutex_free(key_lock);
if (desc_routerinfo)
routerinfo_free(desc_routerinfo);
+ if (warned_nonexistent_family) {
+ SMARTLIST_FOREACH(warned_nonexistent_family, char *, cp, tor_free(cp));
+ smartlist_free(warned_nonexistent_family);
+ }
}
-