[or-cvs] r11801: Fix the "400 OK" issue when replying to a vote. (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Tue Oct 9 17:07:13 UTC 2007


Author: nickm
Date: 2007-10-09 13:07:13 -0400 (Tue, 09 Oct 2007)
New Revision: 11801

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/dirvote.c
Log:
 r15574 at catbus:  nickm | 2007-10-09 13:01:53 -0400
 Fix the "400 OK" issue when replying to a vote.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r15574] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-10-09 15:27:45 UTC (rev 11800)
+++ tor/trunk/ChangeLog	2007-10-09 17:07:13 UTC (rev 11801)
@@ -36,6 +36,9 @@
   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

Modified: tor/trunk/src/or/dirvote.c
===================================================================
--- tor/trunk/src/or/dirvote.c	2007-10-09 15:27:45 UTC (rev 11800)
+++ tor/trunk/src/or/dirvote.c	2007-10-09 17:07:13 UTC (rev 11801)
@@ -1350,10 +1350,10 @@
   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 @@
         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 @@
               !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 @@
   if (end_of_vote && !strcmpstart(end_of_vote, "network-status-version "))
     goto again;
 
-  if (any_failed)
-    goto err;
+  goto done;
 
-  if (!*status_out)
-    *status_out = 200;
-  *msg_out = "ok";
-
-  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



More information about the tor-commits mailing list