Loading src/or/directory.c +4 −3 Original line number Diff line number Diff line Loading @@ -2161,11 +2161,12 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers, if (authdir_mode_v3(options) && !strcmp(url,"/tor/post/vote")) { /* server descriptor post */ const char *msg = "OK"; if (dirvote_add_vote(body, &msg)) { write_http_status_line(conn, 200, "Vote stored"); int status; if (dirvote_add_vote(body, &msg, &status)) { write_http_status_line(conn, status, "Vote stored"); } else { tor_assert(msg); write_http_status_line(conn, 400, msg); write_http_status_line(conn, status, msg); } goto done; } Loading src/or/dirvote.c +10 −3 Original line number Diff line number Diff line Loading @@ -1131,12 +1131,13 @@ dirvote_perform_vote(void) { cached_dir_t *new_vote = generate_v3_networkstatus(); pending_vote_t *pending_vote; int status; const char *msg = ""; if (!new_vote) return; if (!(pending_vote = dirvote_add_vote(new_vote->dir, &msg))) { if (!(pending_vote = dirvote_add_vote(new_vote->dir, &msg, &status))) { log_warn(LD_DIR, "Couldn't store my own vote! (I told myself, '%s'.)", msg); return; Loading Loading @@ -1171,7 +1172,7 @@ dirvote_clear_pending_votes(void) /** DOCDOC */ pending_vote_t * dirvote_add_vote(const char *vote_body, const char **msg_out) dirvote_add_vote(const char *vote_body, const char **msg_out, int *status_out) { networkstatus_vote_t *vote; networkstatus_voter_info_t *vi; Loading @@ -1179,6 +1180,8 @@ dirvote_add_vote(const char *vote_body, const char **msg_out) pending_vote_t *pending_vote = NULL; tor_assert(vote_body); tor_assert(msg_out); tor_assert(status_out); *status_out = 0; if (!pending_vote_list) pending_vote_list = smartlist_create(); Loading Loading @@ -1216,6 +1219,7 @@ dirvote_add_vote(const char *vote_body, const char **msg_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; } else if (v->vote->published < vote->published) { Loading @@ -1240,7 +1244,8 @@ dirvote_add_vote(const char *vote_body, const char **msg_out) vote->published); pending_vote->vote = vote; smartlist_add(pending_vote_list, pending_vote); if (!*status_out) *status_out = 200; *msg_out = "ok"; return pending_vote; err: Loading @@ -1248,6 +1253,8 @@ dirvote_add_vote(const char *vote_body, const char **msg_out) networkstatus_vote_free(vote); if (!*msg_out) *msg_out = "Error adding vote"; if (!*status_out) *status_out = 400; /*XXXX020 free other fields */ return NULL; } Loading src/or/or.h +2 −1 Original line number Diff line number Diff line Loading @@ -2851,7 +2851,8 @@ void dirvote_act(time_t now); void dirvote_perform_vote(void); void dirvote_clear_pending_votes(void); struct pending_vote_t * dirvote_add_vote(const char *vote_body, const char **msg_out); const char **msg_out, int *status_out); int dirvote_compute_consensus(void); int dirvote_add_signatures(const char *detached_signatures_body); int dirvote_publish_consensus(void); Loading Loading
src/or/directory.c +4 −3 Original line number Diff line number Diff line Loading @@ -2161,11 +2161,12 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers, if (authdir_mode_v3(options) && !strcmp(url,"/tor/post/vote")) { /* server descriptor post */ const char *msg = "OK"; if (dirvote_add_vote(body, &msg)) { write_http_status_line(conn, 200, "Vote stored"); int status; if (dirvote_add_vote(body, &msg, &status)) { write_http_status_line(conn, status, "Vote stored"); } else { tor_assert(msg); write_http_status_line(conn, 400, msg); write_http_status_line(conn, status, msg); } goto done; } Loading
src/or/dirvote.c +10 −3 Original line number Diff line number Diff line Loading @@ -1131,12 +1131,13 @@ dirvote_perform_vote(void) { cached_dir_t *new_vote = generate_v3_networkstatus(); pending_vote_t *pending_vote; int status; const char *msg = ""; if (!new_vote) return; if (!(pending_vote = dirvote_add_vote(new_vote->dir, &msg))) { if (!(pending_vote = dirvote_add_vote(new_vote->dir, &msg, &status))) { log_warn(LD_DIR, "Couldn't store my own vote! (I told myself, '%s'.)", msg); return; Loading Loading @@ -1171,7 +1172,7 @@ dirvote_clear_pending_votes(void) /** DOCDOC */ pending_vote_t * dirvote_add_vote(const char *vote_body, const char **msg_out) dirvote_add_vote(const char *vote_body, const char **msg_out, int *status_out) { networkstatus_vote_t *vote; networkstatus_voter_info_t *vi; Loading @@ -1179,6 +1180,8 @@ dirvote_add_vote(const char *vote_body, const char **msg_out) pending_vote_t *pending_vote = NULL; tor_assert(vote_body); tor_assert(msg_out); tor_assert(status_out); *status_out = 0; if (!pending_vote_list) pending_vote_list = smartlist_create(); Loading Loading @@ -1216,6 +1219,7 @@ dirvote_add_vote(const char *vote_body, const char **msg_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; } else if (v->vote->published < vote->published) { Loading @@ -1240,7 +1244,8 @@ dirvote_add_vote(const char *vote_body, const char **msg_out) vote->published); pending_vote->vote = vote; smartlist_add(pending_vote_list, pending_vote); if (!*status_out) *status_out = 200; *msg_out = "ok"; return pending_vote; err: Loading @@ -1248,6 +1253,8 @@ dirvote_add_vote(const char *vote_body, const char **msg_out) networkstatus_vote_free(vote); if (!*msg_out) *msg_out = "Error adding vote"; if (!*status_out) *status_out = 400; /*XXXX020 free other fields */ return NULL; } Loading
src/or/or.h +2 −1 Original line number Diff line number Diff line Loading @@ -2851,7 +2851,8 @@ void dirvote_act(time_t now); void dirvote_perform_vote(void); void dirvote_clear_pending_votes(void); struct pending_vote_t * dirvote_add_vote(const char *vote_body, const char **msg_out); const char **msg_out, int *status_out); int dirvote_compute_consensus(void); int dirvote_add_signatures(const char *detached_signatures_body); int dirvote_publish_consensus(void); Loading