diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-10-09 17:07:13 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-10-09 17:07:13 +0000 |
commit | c7981e669f15eedd4bef64cd6bb99b7a0bd2df4e (patch) | |
tree | f7819f37873fb2964abd9beec6630668b81525f6 | |
parent | 5346a0179696f60b69d3cd0a7ece3308da496d75 (diff) | |
download | tor-c7981e669f15eedd4bef64cd6bb99b7a0bd2df4e.tar.gz tor-c7981e669f15eedd4bef64cd6bb99b7a0bd2df4e.zip |
r15574@catbus: nickm | 2007-10-09 13:01:53 -0400
Fix the "400 OK" issue when replying to a vote.
svn:r11801
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | src/or/dirvote.c | 41 |
2 files changed, 27 insertions, 17 deletions
@@ -36,6 +36,9 @@ Changes in version 0.2.0.8-alpha - 2007-??-?? o Minor bugfixes (v3 directory code): - Fix logic to look up a cert by its signing key digest. Bugfix on 0.2.0.7-alpha. + - Only change the reply to a vote to "OK" if it's not already set. This + gets rid of annoying "400 OK" log messages, which may have been masking + some deeper issue. Bugfix on 0.2.0.7-alpha. o Minor bugfixes (performance): - Use a slightly simpler string hashing algorithm (copying Python's diff --git a/src/or/dirvote.c b/src/or/dirvote.c index 1609c1b612..83360588cb 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -1350,10 +1350,10 @@ dirvote_add_vote(const char *vote_body, const char **msg_out, int *status_out) tor_assert(vote_body); tor_assert(msg_out); tor_assert(status_out); - *status_out = 0; if (!pending_vote_list) pending_vote_list = smartlist_create(); + *status_out = 0; *msg_out = NULL; again: @@ -1411,9 +1411,11 @@ dirvote_add_vote(const char *vote_body, const char **msg_out, int *status_out) if (!memcmp(vi_old->vote_digest, vi->vote_digest, DIGEST_LEN)) { /* Ah, it's the same vote. Not a problem. */ log_info(LD_DIR, "Discarding a vote we already have."); - *status_out = 200; - *msg_out = "ok"; - goto err; + if (*status_out < 200) + *status_out = 200; + if (!*msg_out) + *msg_out = "OK"; + goto discard; } else if (v->vote->published < vote->published) { log_notice(LD_DIR, "Replacing an older pending vote from this " "directory."); @@ -1426,9 +1428,10 @@ dirvote_add_vote(const char *vote_body, const char **msg_out, int *status_out) !strcmpstart(end_of_vote, "network-status-version")) goto again; - if (!*status_out) + if (*status_out < 200) *status_out = 200; - *msg_out = "ok"; + if (!*msg_out) + *msg_out = "OK"; return v; } else { *msg_out = "Already have a newer pending vote"; @@ -1446,26 +1449,30 @@ dirvote_add_vote(const char *vote_body, const char **msg_out, int *status_out) if (end_of_vote && !strcmpstart(end_of_vote, "network-status-version ")) goto again; - if (any_failed) - goto err; - - if (!*status_out) - *status_out = 200; - *msg_out = "ok"; + goto done; - return pending_vote; err: any_failed = 1; - if (vote) - networkstatus_vote_free(vote); if (!*msg_out) *msg_out = "Error adding vote"; - if (!*status_out || *status_out == 200) + if (*status_out < 400) *status_out = 400; + discard: + if (vote) + networkstatus_vote_free(vote); + if (end_of_vote && !strcmpstart(end_of_vote, "network-status-version ")) goto again; - return NULL; + + done: + + if (*status_out < 200) + *status_out = 200; + if (!*msg_out) + *msg_out = "ok"; + + return any_failed ? NULL : pending_vote; } /** Try to compute a v3 networkstatus consensus from the currently pending |