From 4ccc8d029266dc673d901c01a7a8f59b4f530542 Mon Sep 17 00:00:00 2001 From: Sebastian Hahn Date: Tue, 8 Nov 2011 12:44:12 +0100 Subject: [PATCH 1/3] Don't exit on dirauths for some config transitions --- changes/bug4438 | 6 ++++++ src/or/router.c | 19 +++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 changes/bug4438 diff --git a/changes/bug4438 b/changes/bug4438 new file mode 100644 index 0000000000..f6d0c49e3b --- /dev/null +++ b/changes/bug4438 @@ -0,0 +1,6 @@ + o Minor bugfixes: + - Fix a dirauth-only exit on sighup that could happen during some + configuration state transitions. We now don't treat it as a fatal + error when the new descriptor we just generated in init_keys + isn't accepted. Fixes bug 4438; bugfix on FIXME. + diff --git a/src/or/router.c b/src/or/router.c index c9f141b7f0..6199e9e3cc 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -646,15 +646,26 @@ init_keys(void) return -1; } if (mydesc) { + was_router_added_t added; ri = router_parse_entry_from_string(mydesc, NULL, 1, 0, NULL); if (!ri) { log_err(LD_GENERAL,"Generated a routerinfo we couldn't parse."); return -1; } - if (!WRA_WAS_ADDED(dirserv_add_descriptor(ri, &m, "self"))) { - log_err(LD_GENERAL,"Unable to add own descriptor to directory: %s", - m?m:""); - return -1; + added = dirserv_add_descriptor(ri, &m, "self"); + if (!WRA_WAS_ADDED(added)) { + if (WRA_WAS_REJECTED(added)) { + log_err(LD_GENERAL, "Unable to add own descriptor to directory: %s", + m?m:""); + return -1; + } else { + /* If the descriptor wasn't rejected, that's ok. This can happen + * when some config options are toggled that affect workers, but + * we don't really need new keys yet so the descriptor doesn't + * change and the old one is still fresh. */ + log_info(LD_GENERAL, "Couldn't add own descriptor to directory: %s", + m?m:"unknown error>"); + } } } } From 54520e49cd2a10778e7c58d797f22a768da6557a Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 28 Mar 2012 10:41:12 -0400 Subject: [PATCH 2/3] Say that bug4438 was a fix on 0.2.1.9-alpha. Specifically, it was a fix on 33e2053ebca5d, where we introduced the WRA_* and ROUTER_* codes for dirserv_add_descriptor. Previously, we had checked for a _negative_ return from dirserv_add_descriptor, which meant "rejected". An insufficiently new descriptor would give a 0-valued return. But when we switched from numbers to enums, we got this check wrong and had init_keys() give an error whenever the descriptor wasn't accepted. --- changes/bug4438 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes/bug4438 b/changes/bug4438 index f6d0c49e3b..94690e18e0 100644 --- a/changes/bug4438 +++ b/changes/bug4438 @@ -2,5 +2,5 @@ - Fix a dirauth-only exit on sighup that could happen during some configuration state transitions. We now don't treat it as a fatal error when the new descriptor we just generated in init_keys - isn't accepted. Fixes bug 4438; bugfix on FIXME. + isn't accepted. Fixes bug 4438; bugfix on 0.2.1.9-alpha. From db81cdbb0f9a69bc7bb0a4f77ff0fe44875f7cda Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 28 Mar 2012 10:47:17 -0400 Subject: [PATCH 3/3] Tweak the bug4438 fix a little: different check, better log Instead of checking for 'rejected' and calling everything else okay, let's check for 'outdated' and call everythign else a problem. This way we don't risk missing future errors so much. When logging a message that _looks_ like an error message at info, we should mention that it isn't really a problem. --- src/or/router.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/or/router.c b/src/or/router.c index 6199e9e3cc..451d95d03c 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -654,17 +654,18 @@ init_keys(void) } added = dirserv_add_descriptor(ri, &m, "self"); if (!WRA_WAS_ADDED(added)) { - if (WRA_WAS_REJECTED(added)) { + if (!WRA_WAS_OUTDATED(added)) { log_err(LD_GENERAL, "Unable to add own descriptor to directory: %s", m?m:""); return -1; } else { - /* If the descriptor wasn't rejected, that's ok. This can happen + /* If the descriptor was outdated, that's ok. This can happen * when some config options are toggled that affect workers, but * we don't really need new keys yet so the descriptor doesn't * change and the old one is still fresh. */ - log_info(LD_GENERAL, "Couldn't add own descriptor to directory: %s", - m?m:"unknown error>"); + log_info(LD_GENERAL, "Couldn't add own descriptor to directory " + "after key init: %s. This is usually not a problem.", + m?m:""); } } }