diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-12-22 04:53:11 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-12-22 04:53:11 +0000 |
commit | 98a376fab1725c81df84a1782b3b625958e4c6ba (patch) | |
tree | 4961240d483831348828a71151f67e75594c8836 /src | |
parent | df22dcb602ff45f32444ba1f882d092996345771 (diff) | |
download | tor-98a376fab1725c81df84a1782b3b625958e4c6ba.tar.gz tor-98a376fab1725c81df84a1782b3b625958e4c6ba.zip |
More propagating of things that need to be was_router_added_t now.
svn:r17721
Diffstat (limited to 'src')
-rw-r--r-- | src/or/dirserv.c | 9 | ||||
-rw-r--r-- | src/or/or.h | 12 | ||||
-rw-r--r-- | src/or/routerlist.c | 12 |
3 files changed, 20 insertions, 13 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c index c33e7ab444..de7401d4a8 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -584,8 +584,7 @@ dirserv_add_multiple_descriptors(const char *desc, uint8_t purpose, 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 @@ dirserv_add_multiple_descriptors(const char *desc, uint8_t purpose, 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 @@ dirserv_add_multiple_descriptors(const char *desc, uint8_t purpose, 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)"; } diff --git a/src/or/or.h b/src/or/or.h index 9093127ee3..06d1b89355 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -4375,10 +4375,11 @@ void router_set_status(const char *digest, int up); 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 @@ was_router_added_t router_add_to_routerlist(routerinfo_t *router, 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, diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 03bce599a8..006713f017 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -3069,13 +3069,14 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg, * 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 @@ router_add_extrainfo_to_routerlist(extrainfo_t *ei, const char **msg, 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 @@ router_load_extrainfo_from_string(const char *s, const char *eos, 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 : |