[or-cvs] r17721: {tor} More propagating of things that need to be was_router_added_ (tor/trunk/src/or)

nickm at seul.org nickm at seul.org
Mon Dec 22 04:53:11 UTC 2008


Author: nickm
Date: 2008-12-21 23:53:11 -0500 (Sun, 21 Dec 2008)
New Revision: 17721

Modified:
   tor/trunk/src/or/dirserv.c
   tor/trunk/src/or/or.h
   tor/trunk/src/or/routerlist.c
Log:
More propagating of things that need to be was_router_added_t now.

Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c	2008-12-22 04:36:52 UTC (rev 17720)
+++ tor/trunk/src/or/dirserv.c	2008-12-22 04:53:11 UTC (rev 17721)
@@ -584,8 +584,7 @@
                                  const char *source,
                                  const char **msg)
 {
-  int r=ROUTER_ADDED_NOTIFY_GENERATOR; /* highest possible return value. */
-  int r_tmp;
+  was_router_added_t r, r_tmp;
   const char *msg_out;
   smartlist_t *list;
   const char *s;
@@ -596,6 +595,8 @@
   int general = purpose == ROUTER_PURPOSE_GENERAL;
   tor_assert(msg);
 
+  r=ROUTER_ADDED_NOTIFY_GENERATOR; /*Least severe return value. */
+
   format_iso_time(time_buf, now);
   if (tor_snprintf(annotation_buf, sizeof(annotation_buf),
                    "@uploaded-at %s\n"
@@ -644,8 +645,8 @@
   if (! *msg) {
     if (!n_parsed) {
       *msg = "No descriptors found in your POST.";
-      if (r > -1)
-        r = -1;
+      if (WRA_WAS_ADDED(r))
+        r = ROUTER_WAS_NOT_NEW;
     } else {
       *msg = "(no message)";
     }

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2008-12-22 04:36:52 UTC (rev 17720)
+++ tor/trunk/src/or/or.h	2008-12-22 04:53:11 UTC (rev 17721)
@@ -4375,10 +4375,11 @@
 typedef enum was_router_added_t {
   ROUTER_ADDED_SUCCESSFULLY = 0,
   ROUTER_ADDED_NOTIFY_GENERATOR = 1,
-  ROUTER_WAS_NOT_NEW = -1,
-  ROUTER_NOT_IN_CONSENSUS = -2,
-  ROUTER_NOT_IN_CONSENSUS_OR_NETWORKSTATUS = -3,
-  ROUTER_AUTHDIR_REJECTS = -4,
+  ROUTER_BAD_EI = -1,
+  ROUTER_WAS_NOT_NEW = -2,
+  ROUTER_NOT_IN_CONSENSUS = -3,
+  ROUTER_NOT_IN_CONSENSUS_OR_NETWORKSTATUS = -4,
+  ROUTER_AUTHDIR_REJECTS = -5,
 } was_router_added_t;
 
 static int WRA_WAS_ADDED(was_router_added_t s);
@@ -4405,7 +4406,8 @@
                                             const char **msg,
                                             int from_cache,
                                             int from_fetch);
-int router_add_extrainfo_to_routerlist(extrainfo_t *ei, const char **msg,
+was_router_added_t router_add_extrainfo_to_routerlist(
+                                        extrainfo_t *ei, const char **msg,
                                         int from_cache, int from_fetch);
 void routerlist_remove_old_routers(void);
 int router_load_single_router(const char *s, uint8_t purpose, int cache,

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2008-12-22 04:36:52 UTC (rev 17720)
+++ tor/trunk/src/or/routerlist.c	2008-12-22 04:53:11 UTC (rev 17721)
@@ -3069,13 +3069,14 @@
  * as for router_add_to_routerlist().  Return true iff we actually inserted
  * it.
  */
-int
+was_router_added_t
 router_add_extrainfo_to_routerlist(extrainfo_t *ei, const char **msg,
                                    int from_cache, int from_fetch)
 {
   int inserted;
   (void)from_fetch;
   if (msg) *msg = NULL;
+  /*XXXX021 Do something with msg */
 
   inserted = extrainfo_insert(router_get_routerlist(), ei);
 
@@ -3083,7 +3084,10 @@
     signed_desc_append_to_journal(&ei->cache_info,
                                   &routerlist->extrainfo_store);
 
-  return inserted;
+  if (inserted)
+    return ROUTER_ADDED_SUCCESSFULLY;
+  else
+    return ROUTER_BAD_EI;
 }
 
 /** Sorting helper: return <0, 0, or >0 depending on whether the
@@ -3528,9 +3532,9 @@
   log_info(LD_DIR, "%d elements to add", smartlist_len(extrainfo_list));
 
   SMARTLIST_FOREACH(extrainfo_list, extrainfo_t *, ei, {
-      int added =
+      was_router_added_t added =
         router_add_extrainfo_to_routerlist(ei, &msg, from_cache, !from_cache);
-      if (added && requested_fingerprints) {
+      if (WRA_WAS_ADDED(added) && requested_fingerprints) {
         char fp[HEX_DIGEST_LEN+1];
         base16_encode(fp, sizeof(fp), descriptor_digests ?
                         ei->cache_info.signed_descriptor_digest :



More information about the tor-commits mailing list