Commit 47c8433a authored by Nick Mathewson's avatar Nick Mathewson 🐻
Browse files

Make the get_options() return const

This lets us make a lot of other stuff const, allows the compiler to
generate (slightly) better code, and will make me get slightly fewer
patches from folks who stick mutable stuff into or_options_t.

const: because not every input is an output!
parent 22efe203
...@@ -1459,7 +1459,7 @@ log_unsafe_socks_warning(int socks_protocol, const char *address, ...@@ -1459,7 +1459,7 @@ log_unsafe_socks_warning(int socks_protocol, const char *address,
{ {
static ratelim_t socks_ratelim = RATELIM_INIT(SOCKS_WARN_INTERVAL); static ratelim_t socks_ratelim = RATELIM_INIT(SOCKS_WARN_INTERVAL);
or_options_t *options = get_options(); const or_options_t *options = get_options();
char *m = NULL; char *m = NULL;
if (! options->WarnUnsafeSocks) if (! options->WarnUnsafeSocks)
return; return;
......
...@@ -1948,7 +1948,7 @@ inform_testing_reachability(void) ...@@ -1948,7 +1948,7 @@ inform_testing_reachability(void)
static INLINE int static INLINE int
should_use_create_fast_for_circuit(origin_circuit_t *circ) should_use_create_fast_for_circuit(origin_circuit_t *circ)
{ {
or_options_t *options = get_options(); const or_options_t *options = get_options();
tor_assert(circ->cpath); tor_assert(circ->cpath);
tor_assert(circ->cpath->extend_info); tor_assert(circ->cpath->extend_info);
...@@ -2083,7 +2083,7 @@ circuit_send_next_onion_skin(origin_circuit_t *circ) ...@@ -2083,7 +2083,7 @@ circuit_send_next_onion_skin(origin_circuit_t *circ)
if (circ->build_state->onehop_tunnel) if (circ->build_state->onehop_tunnel)
control_event_bootstrap(BOOTSTRAP_STATUS_REQUESTING_STATUS, 0); control_event_bootstrap(BOOTSTRAP_STATUS_REQUESTING_STATUS, 0);
if (!can_complete_circuit && !circ->build_state->onehop_tunnel) { if (!can_complete_circuit && !circ->build_state->onehop_tunnel) {
or_options_t *options = get_options(); const or_options_t *options = get_options();
can_complete_circuit=1; can_complete_circuit=1;
/* FFFF Log a count of known routers here */ /* FFFF Log a count of known routers here */
log_notice(LD_GENERAL, log_notice(LD_GENERAL,
...@@ -2650,7 +2650,7 @@ choose_good_exit_server_general(int need_uptime, int need_capacity) ...@@ -2650,7 +2650,7 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
smartlist_t *connections; smartlist_t *connections;
int best_support = -1; int best_support = -1;
int n_best_support=0; int n_best_support=0;
or_options_t *options = get_options(); const or_options_t *options = get_options();
const smartlist_t *the_nodes; const smartlist_t *the_nodes;
const node_t *node=NULL; const node_t *node=NULL;
...@@ -2851,7 +2851,7 @@ static const node_t * ...@@ -2851,7 +2851,7 @@ static const node_t *
choose_good_exit_server(uint8_t purpose, choose_good_exit_server(uint8_t purpose,
int need_uptime, int need_capacity, int is_internal) int need_uptime, int need_capacity, int is_internal)
{ {
or_options_t *options = get_options(); const or_options_t *options = get_options();
router_crn_flags_t flags = CRN_NEED_DESC; router_crn_flags_t flags = CRN_NEED_DESC;
if (need_uptime) if (need_uptime)
flags |= CRN_NEED_UPTIME; flags |= CRN_NEED_UPTIME;
...@@ -2881,7 +2881,7 @@ choose_good_exit_server(uint8_t purpose, ...@@ -2881,7 +2881,7 @@ choose_good_exit_server(uint8_t purpose,
static void static void
warn_if_last_router_excluded(origin_circuit_t *circ, const extend_info_t *exit) warn_if_last_router_excluded(origin_circuit_t *circ, const extend_info_t *exit)
{ {
or_options_t *options = get_options(); const or_options_t *options = get_options();
routerset_t *rs = options->ExcludeNodes; routerset_t *rs = options->ExcludeNodes;
const char *description; const char *description;
uint8_t purpose = circ->_base.purpose; uint8_t purpose = circ->_base.purpose;
...@@ -3095,7 +3095,7 @@ choose_good_middle_server(uint8_t purpose, ...@@ -3095,7 +3095,7 @@ choose_good_middle_server(uint8_t purpose,
const node_t *r, *choice; const node_t *r, *choice;
crypt_path_t *cpath; crypt_path_t *cpath;
smartlist_t *excluded; smartlist_t *excluded;
or_options_t *options = get_options(); const or_options_t *options = get_options();
router_crn_flags_t flags = CRN_NEED_DESC; router_crn_flags_t flags = CRN_NEED_DESC;
tor_assert(_CIRCUIT_PURPOSE_MIN <= purpose && tor_assert(_CIRCUIT_PURPOSE_MIN <= purpose &&
purpose <= _CIRCUIT_PURPOSE_MAX); purpose <= _CIRCUIT_PURPOSE_MAX);
...@@ -3137,7 +3137,7 @@ choose_good_entry_server(uint8_t purpose, cpath_build_state_t *state) ...@@ -3137,7 +3137,7 @@ choose_good_entry_server(uint8_t purpose, cpath_build_state_t *state)
{ {
const node_t *choice; const node_t *choice;
smartlist_t *excluded; smartlist_t *excluded;
or_options_t *options = get_options(); const or_options_t *options = get_options();
router_crn_flags_t flags = CRN_NEED_GUARD|CRN_NEED_DESC; router_crn_flags_t flags = CRN_NEED_GUARD|CRN_NEED_DESC;
const node_t *node; const node_t *node;
...@@ -3388,7 +3388,8 @@ build_state_get_exit_nickname(cpath_build_state_t *state) ...@@ -3388,7 +3388,8 @@ build_state_get_exit_nickname(cpath_build_state_t *state)
*/ */
static int static int
entry_guard_set_status(entry_guard_t *e, const node_t *node, entry_guard_set_status(entry_guard_t *e, const node_t *node,
time_t now, or_options_t *options, const char **reason) time_t now, const or_options_t *options,
const char **reason)
{ {
char buf[HEX_DIGEST_LEN+1]; char buf[HEX_DIGEST_LEN+1];
int changed = 0; int changed = 0;
...@@ -3471,7 +3472,7 @@ entry_is_live(entry_guard_t *e, int need_uptime, int need_capacity, ...@@ -3471,7 +3472,7 @@ entry_is_live(entry_guard_t *e, int need_uptime, int need_capacity,
int assume_reachable, const char **msg) int assume_reachable, const char **msg)
{ {
const node_t *node; const node_t *node;
or_options_t *options = get_options(); const or_options_t *options = get_options();
tor_assert(msg); tor_assert(msg);
if (e->bad_since) { if (e->bad_since) {
...@@ -3597,7 +3598,7 @@ control_event_guard_deferred(void) ...@@ -3597,7 +3598,7 @@ control_event_guard_deferred(void)
#if 0 #if 0
int n = 0; int n = 0;
const char *msg; const char *msg;
or_options_t *options = get_options(); const or_options_t *options = get_options();
if (!entry_guards) if (!entry_guards)
return; return;
SMARTLIST_FOREACH(entry_guards, entry_guard_t *, entry, SMARTLIST_FOREACH(entry_guards, entry_guard_t *, entry,
...@@ -3665,7 +3666,7 @@ add_an_entry_guard(const node_t *chosen, int reset_status) ...@@ -3665,7 +3666,7 @@ add_an_entry_guard(const node_t *chosen, int reset_status)
/** If the use of entry guards is configured, choose more entry guards /** If the use of entry guards is configured, choose more entry guards
* until we have enough in the list. */ * until we have enough in the list. */
static void static void
pick_entry_guards(or_options_t *options) pick_entry_guards(const or_options_t *options)
{ {
int changed = 0; int changed = 0;
...@@ -3798,7 +3799,7 @@ remove_dead_entry_guards(time_t now) ...@@ -3798,7 +3799,7 @@ remove_dead_entry_guards(time_t now)
* think that things are unlisted. * think that things are unlisted.
*/ */
void void
entry_guards_compute_status(or_options_t *options, time_t now) entry_guards_compute_status(const or_options_t *options, time_t now)
{ {
int changed = 0; int changed = 0;
digestmap_t *reasons; digestmap_t *reasons;
...@@ -3988,7 +3989,7 @@ entry_nodes_should_be_added(void) ...@@ -3988,7 +3989,7 @@ entry_nodes_should_be_added(void)
/** Add all nodes in EntryNodes that aren't currently guard nodes to the list /** Add all nodes in EntryNodes that aren't currently guard nodes to the list
* of guard nodes, at the front. */ * of guard nodes, at the front. */
static void static void
entry_guards_prepend_from_config(or_options_t *options) entry_guards_prepend_from_config(const or_options_t *options)
{ {
smartlist_t *entry_nodes, *entry_fps; smartlist_t *entry_nodes, *entry_fps;
smartlist_t *old_entry_guards_on_list, *old_entry_guards_not_on_list; smartlist_t *old_entry_guards_on_list, *old_entry_guards_not_on_list;
...@@ -4067,7 +4068,7 @@ entry_guards_prepend_from_config(or_options_t *options) ...@@ -4067,7 +4068,7 @@ entry_guards_prepend_from_config(or_options_t *options)
* list already and we must stick to it. * list already and we must stick to it.
*/ */
int int
entry_list_is_constrained(or_options_t *options) entry_list_is_constrained(const or_options_t *options)
{ {
if (options->EntryNodes) if (options->EntryNodes)
return 1; return 1;
...@@ -4084,7 +4085,7 @@ entry_list_is_constrained(or_options_t *options) ...@@ -4084,7 +4085,7 @@ entry_list_is_constrained(or_options_t *options)
const node_t * const node_t *
choose_random_entry(cpath_build_state_t *state) choose_random_entry(cpath_build_state_t *state)
{ {
or_options_t *options = get_options(); const or_options_t *options = get_options();
smartlist_t *live_entry_guards = smartlist_create(); smartlist_t *live_entry_guards = smartlist_create();
smartlist_t *exit_family = smartlist_create(); smartlist_t *exit_family = smartlist_create();
const node_t *chosen_exit = const node_t *chosen_exit =
...@@ -4694,7 +4695,7 @@ static void ...@@ -4694,7 +4695,7 @@ static void
launch_direct_bridge_descriptor_fetch(bridge_info_t *bridge) launch_direct_bridge_descriptor_fetch(bridge_info_t *bridge)
{ {
char *address; char *address;
or_options_t *options = get_options(); const or_options_t *options = get_options();
if (connection_get_by_type_addr_port_purpose( if (connection_get_by_type_addr_port_purpose(
CONN_TYPE_DIR, &bridge->addr, bridge->port, CONN_TYPE_DIR, &bridge->addr, bridge->port,
...@@ -4735,7 +4736,7 @@ retry_bridge_descriptor_fetch_directly(const char *digest) ...@@ -4735,7 +4736,7 @@ retry_bridge_descriptor_fetch_directly(const char *digest)
* descriptor, fetch a new copy of its descriptor -- either directly * descriptor, fetch a new copy of its descriptor -- either directly
* from the bridge or via a bridge authority. */ * from the bridge or via a bridge authority. */
void void
fetch_bridge_descriptors(or_options_t *options, time_t now) fetch_bridge_descriptors(const or_options_t *options, time_t now)
{ {
int num_bridge_auths = get_n_authorities(BRIDGE_DIRINFO); int num_bridge_auths = get_n_authorities(BRIDGE_DIRINFO);
int ask_bridge_directly; int ask_bridge_directly;
...@@ -4929,7 +4930,7 @@ any_pending_bridge_descriptor_fetches(void) ...@@ -4929,7 +4930,7 @@ any_pending_bridge_descriptor_fetches(void)
* down. Else return 0. If <b>act</b> is 1, then mark the down guards * down. Else return 0. If <b>act</b> is 1, then mark the down guards
* up; else just observe and report. */ * up; else just observe and report. */
static int static int
entries_retry_helper(or_options_t *options, int act) entries_retry_helper(const or_options_t *options, int act)
{ {
const node_t *node; const node_t *node;
int any_known = 0; int any_known = 0;
...@@ -4968,7 +4969,7 @@ entries_retry_helper(or_options_t *options, int act) ...@@ -4968,7 +4969,7 @@ entries_retry_helper(or_options_t *options, int act)
/** Do we know any descriptors for our bridges / entrynodes, and are /** Do we know any descriptors for our bridges / entrynodes, and are
* all the ones we have descriptors for down? */ * all the ones we have descriptors for down? */
int int
entries_known_but_down(or_options_t *options) entries_known_but_down(const or_options_t *options)
{ {
tor_assert(entry_list_is_constrained(options)); tor_assert(entry_list_is_constrained(options));
return entries_retry_helper(options, 0); return entries_retry_helper(options, 0);
...@@ -4976,7 +4977,7 @@ entries_known_but_down(or_options_t *options) ...@@ -4976,7 +4977,7 @@ entries_known_but_down(or_options_t *options)
/** Mark all down known bridges / entrynodes up. */ /** Mark all down known bridges / entrynodes up. */
void void
entries_retry_all(or_options_t *options) entries_retry_all(const or_options_t *options)
{ {
tor_assert(entry_list_is_constrained(options)); tor_assert(entry_list_is_constrained(options));
entries_retry_helper(options, 1); entries_retry_helper(options, 1);
......
...@@ -51,11 +51,11 @@ void extend_info_free(extend_info_t *info); ...@@ -51,11 +51,11 @@ void extend_info_free(extend_info_t *info);
const node_t *build_state_get_exit_node(cpath_build_state_t *state); const node_t *build_state_get_exit_node(cpath_build_state_t *state);
const char *build_state_get_exit_nickname(cpath_build_state_t *state); const char *build_state_get_exit_nickname(cpath_build_state_t *state);
void entry_guards_compute_status(or_options_t *options, time_t now); void entry_guards_compute_status(const or_options_t *options, time_t now);
int entry_guard_register_connect_status(const char *digest, int succeeded, int entry_guard_register_connect_status(const char *digest, int succeeded,
int mark_relay_status, time_t now); int mark_relay_status, time_t now);
void entry_nodes_should_be_added(void); void entry_nodes_should_be_added(void);
int entry_list_is_constrained(or_options_t *options); int entry_list_is_constrained(const or_options_t *options);
const node_t *choose_random_entry(cpath_build_state_t *state); const node_t *choose_random_entry(cpath_build_state_t *state);
int entry_guards_parse_state(or_state_t *state, int set, char **msg); int entry_guards_parse_state(or_state_t *state, int set, char **msg);
void entry_guards_update_state(or_state_t *state); void entry_guards_update_state(or_state_t *state);
...@@ -72,12 +72,12 @@ void learned_router_identity(const tor_addr_t *addr, uint16_t port, ...@@ -72,12 +72,12 @@ void learned_router_identity(const tor_addr_t *addr, uint16_t port,
void bridge_add_from_config(const tor_addr_t *addr, uint16_t port, void bridge_add_from_config(const tor_addr_t *addr, uint16_t port,
const char *digest); const char *digest);
void retry_bridge_descriptor_fetch_directly(const char *digest); void retry_bridge_descriptor_fetch_directly(const char *digest);
void fetch_bridge_descriptors(or_options_t *options, time_t now); void fetch_bridge_descriptors(const or_options_t *options, time_t now);
void learned_bridge_descriptor(routerinfo_t *ri, int from_cache); void learned_bridge_descriptor(routerinfo_t *ri, int from_cache);
int any_bridge_descriptors_known(void); int any_bridge_descriptors_known(void);
int any_pending_bridge_descriptor_fetches(void); int any_pending_bridge_descriptor_fetches(void);
int entries_known_but_down(or_options_t *options); int entries_known_but_down(const or_options_t *options);
void entries_retry_all(or_options_t *options); void entries_retry_all(const or_options_t *options);
void entry_guards_free_all(void); void entry_guards_free_all(void);
......
...@@ -979,7 +979,7 @@ circuit_find_to_cannibalize(uint8_t purpose, extend_info_t *info, ...@@ -979,7 +979,7 @@ circuit_find_to_cannibalize(uint8_t purpose, extend_info_t *info,
int need_uptime = (flags & CIRCLAUNCH_NEED_UPTIME) != 0; int need_uptime = (flags & CIRCLAUNCH_NEED_UPTIME) != 0;
int need_capacity = (flags & CIRCLAUNCH_NEED_CAPACITY) != 0; int need_capacity = (flags & CIRCLAUNCH_NEED_CAPACITY) != 0;
int internal = (flags & CIRCLAUNCH_IS_INTERNAL) != 0; int internal = (flags & CIRCLAUNCH_IS_INTERNAL) != 0;
or_options_t *options = get_options(); const or_options_t *options = get_options();
/* Make sure we're not trying to create a onehop circ by /* Make sure we're not trying to create a onehop circ by
* cannibalization. */ * cannibalization. */
...@@ -1098,7 +1098,7 @@ void ...@@ -1098,7 +1098,7 @@ void
circuit_expire_all_dirty_circs(void) circuit_expire_all_dirty_circs(void)
{ {
circuit_t *circ; circuit_t *circ;
or_options_t *options = get_options(); const or_options_t *options = get_options();
for (circ=global_circuitlist; circ; circ = circ->next) { for (circ=global_circuitlist; circ; circ = circ->next) {
if (CIRCUIT_IS_ORIGIN(circ) && if (CIRCUIT_IS_ORIGIN(circ) &&
......
...@@ -635,7 +635,7 @@ void ...@@ -635,7 +635,7 @@ void
circuit_build_needed_circs(time_t now) circuit_build_needed_circs(time_t now)
{ {
static time_t time_to_new_circuit = 0; static time_t time_to_new_circuit = 0;
or_options_t *options = get_options(); const or_options_t *options = get_options();
/* launch a new circ for any pending streams that need one */ /* launch a new circ for any pending streams that need one */
connection_ap_attach_pending(); connection_ap_attach_pending();
...@@ -1207,7 +1207,7 @@ circuit_get_open_circ_or_launch(edge_connection_t *conn, ...@@ -1207,7 +1207,7 @@ circuit_get_open_circ_or_launch(edge_connection_t *conn,
int check_exit_policy; int check_exit_policy;
int need_uptime, need_internal; int need_uptime, need_internal;
int want_onehop; int want_onehop;
or_options_t *options = get_options(); const or_options_t *options = get_options();
tor_assert(conn); tor_assert(conn);
tor_assert(circp); tor_assert(circp);
...@@ -1470,7 +1470,7 @@ link_apconn_to_circ(edge_connection_t *apconn, origin_circuit_t *circ, ...@@ -1470,7 +1470,7 @@ link_apconn_to_circ(edge_connection_t *apconn, origin_circuit_t *circ,
/** Return true iff <b>address</b> is matched by one of the entries in /** Return true iff <b>address</b> is matched by one of the entries in
* TrackHostExits. */ * TrackHostExits. */
int int
hostname_in_track_host_exits(or_options_t *options, const char *address) hostname_in_track_host_exits(const or_options_t *options, const char *address)
{ {
if (!options->TrackHostExits) if (!options->TrackHostExits)
return 0; return 0;
...@@ -1494,7 +1494,7 @@ hostname_in_track_host_exits(or_options_t *options, const char *address) ...@@ -1494,7 +1494,7 @@ hostname_in_track_host_exits(or_options_t *options, const char *address)
static void static void
consider_recording_trackhost(edge_connection_t *conn, origin_circuit_t *circ) consider_recording_trackhost(edge_connection_t *conn, origin_circuit_t *circ)
{ {
or_options_t *options = get_options(); const or_options_t *options = get_options();
char *new_address = NULL; char *new_address = NULL;
char fp[HEX_DIGEST_LEN+1]; char fp[HEX_DIGEST_LEN+1];
......
...@@ -50,7 +50,8 @@ int connection_ap_handshake_attach_chosen_circuit(edge_connection_t *conn, ...@@ -50,7 +50,8 @@ int connection_ap_handshake_attach_chosen_circuit(edge_connection_t *conn,
crypt_path_t *cpath); crypt_path_t *cpath);
int connection_ap_handshake_attach_circuit(edge_connection_t *conn); int connection_ap_handshake_attach_circuit(edge_connection_t *conn);
int hostname_in_track_host_exits(or_options_t *options, const char *address); int hostname_in_track_host_exits(const or_options_t *options,
const char *address);
#endif #endif
This diff is collapsed.
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
#define _TOR_CONFIG_H #define _TOR_CONFIG_H
const char *get_dirportfrontpage(void); const char *get_dirportfrontpage(void);
or_options_t *get_options(void); const or_options_t *get_options(void);
or_options_t *get_options_mutable(void);
int set_options(or_options_t *new_val, char **msg); int set_options(or_options_t *new_val, char **msg);
void config_free_all(void); void config_free_all(void);
const char *safe_str_client(const char *address); const char *safe_str_client(const char *address);
...@@ -26,21 +27,21 @@ int config_get_lines(const char *string, config_line_t **result); ...@@ -26,21 +27,21 @@ int config_get_lines(const char *string, config_line_t **result);
void config_free_lines(config_line_t *front); void config_free_lines(config_line_t *front);
setopt_err_t options_trial_assign(config_line_t *list, int use_defaults, setopt_err_t options_trial_assign(config_line_t *list, int use_defaults,
int clear_first, char **msg); int clear_first, char **msg);
int resolve_my_address(int warn_severity, or_options_t *options, int resolve_my_address(int warn_severity, const or_options_t *options,
uint32_t *addr, char **hostname_out); uint32_t *addr, char **hostname_out);
int is_local_addr(const tor_addr_t *addr) ATTR_PURE; int is_local_addr(const tor_addr_t *addr) ATTR_PURE;
void options_init(or_options_t *options); void options_init(or_options_t *options);
char *options_dump(or_options_t *options, int minimal); char *options_dump(const or_options_t *options, int minimal);
int options_init_from_torrc(int argc, char **argv); int options_init_from_torrc(int argc, char **argv);
setopt_err_t options_init_from_string(const char *cf, setopt_err_t options_init_from_string(const char *cf,
int command, const char *command_arg, char **msg); int command, const char *command_arg, char **msg);
int option_is_recognized(const char *key); int option_is_recognized(const char *key);
const char *option_get_canonical_name(const char *key); const char *option_get_canonical_name(const char *key);
config_line_t *option_get_assignment(or_options_t *options, config_line_t *option_get_assignment(const or_options_t *options,
const char *key); const char *key);
int options_save_current(void); int options_save_current(void);
const char *get_torrc_fname(void); const char *get_torrc_fname(void);
char *options_get_datadir_fname2_suffix(or_options_t *options, char *options_get_datadir_fname2_suffix(const or_options_t *options,
const char *sub1, const char *sub2, const char *sub1, const char *sub2,
const char *suffix); const char *suffix);
#define get_datadir_fname2_suffix(sub1, sub2, suffix) \ #define get_datadir_fname2_suffix(sub1, sub2, suffix) \
...@@ -63,14 +64,15 @@ or_state_t *get_or_state(void); ...@@ -63,14 +64,15 @@ or_state_t *get_or_state(void);
int did_last_state_file_write_fail(void); int did_last_state_file_write_fail(void);
int or_state_save(time_t now); int or_state_save(time_t now);
int options_need_geoip_info(or_options_t *options, const char **reason_out); int options_need_geoip_info(const or_options_t *options,
const char **reason_out);
int getinfo_helper_config(control_connection_t *conn, int getinfo_helper_config(control_connection_t *conn,
const char *question, char **answer, const char *question, char **answer,
const char **errmsg); const char **errmsg);
const char *tor_get_digests(void); const char *tor_get_digests(void);
uint32_t get_effective_bwrate(or_options_t *options); uint32_t get_effective_bwrate(const or_options_t *options);
uint32_t get_effective_bwburst(or_options_t *options); uint32_t get_effective_bwburst(const or_options_t *options);
#ifdef CONFIG_PRIVATE #ifdef CONFIG_PRIVATE
/* Used only by config.c and test.c */ /* Used only by config.c and test.c */
......
...@@ -619,7 +619,7 @@ connection_about_to_close_connection(connection_t *conn) ...@@ -619,7 +619,7 @@ connection_about_to_close_connection(connection_t *conn)
circuit_n_conn_done(TO_OR_CONN(conn), 0); circuit_n_conn_done(TO_OR_CONN(conn), 0);
/* now mark things down as needed */ /* now mark things down as needed */
if (connection_or_nonopen_was_started_here(or_conn)) { if (connection_or_nonopen_was_started_here(or_conn)) {
or_options_t *options = get_options(); const or_options_t *options = get_options();
rep_hist_note_connect_failed(or_conn->identity_digest, now); rep_hist_note_connect_failed(or_conn->identity_digest, now);
entry_guard_register_connect_status(or_conn->identity_digest,0, entry_guard_register_connect_status(or_conn->identity_digest,0,
!options->HTTPSProxy, now); !options->HTTPSProxy, now);
...@@ -899,7 +899,7 @@ warn_too_many_conns(void) ...@@ -899,7 +899,7 @@ warn_too_many_conns(void)
/** Check whether we should be willing to open an AF_UNIX socket in /** Check whether we should be willing to open an AF_UNIX socket in
* <b>path</b>. Return 0 if we should go ahead and -1 if we shouldn't. */ * <b>path</b>. Return 0 if we should go ahead and -1 if we shouldn't. */
static int static int
check_location_for_unix_socket(or_options_t *options, const char *path) check_location_for_unix_socket(const or_options_t *options, const char *path)
{ {
int r = -1; int r = -1;
char *p = tor_strdup(path); char *p = tor_strdup(path);
...@@ -1186,7 +1186,7 @@ connection_handle_listener_read(connection_t *conn, int new_type) ...@@ -1186,7 +1186,7 @@ connection_handle_listener_read(connection_t *conn, int new_type)
struct sockaddr *remote = (struct sockaddr*)addrbuf; struct sockaddr *remote = (struct sockaddr*)addrbuf;
/* length of the remote address. Must be whatever accept() needs. */ /* length of the remote address. Must be whatever accept() needs. */
socklen_t remotelen = (socklen_t)sizeof(addrbuf); socklen_t remotelen = (socklen_t)sizeof(addrbuf);
or_options_t *options = get_options(); const or_options_t *options = get_options();
tor_assert((size_t)remotelen >= sizeof(struct sockaddr_in)); tor_assert((size_t)remotelen >= sizeof(struct sockaddr_in));
memset(addrbuf, 0, sizeof(addrbuf)); memset(addrbuf, 0, sizeof(addrbuf));
...@@ -1366,7 +1366,7 @@ connection_connect(connection_t *conn, const char *address, ...@@ -1366,7 +1366,7 @@ connection_connect(connection_t *conn, const char *address,
char addrbuf[256]; char addrbuf[256];
struct sockaddr *dest_addr; struct sockaddr *dest_addr;
int dest_addr_len; int dest_addr_len;
or_options_t *options = get_options(); const or_options_t *options = get_options();
int protocol_family; int protocol_family;
if (get_n_open_sockets() >= get_options()->_ConnLimit-1) { if (get_n_open_sockets() >= get_options()->_ConnLimit-1) {
...@@ -1489,7 +1489,7 @@ connection_proxy_state_to_string(int state) ...@@ -1489,7 +1489,7 @@ connection_proxy_state_to_string(int state)
int int
connection_proxy_connect(connection_t *conn, int type) connection_proxy_connect(connection_t *conn, int type)
{ {
or_options_t *options; const or_options_t *options;
tor_assert(conn); tor_assert(conn);
...@@ -2005,7 +2005,7 @@ int ...@@ -2005,7 +2005,7 @@ int
retry_all_listeners(smartlist_t *replaced_conns, retry_all_listeners(smartlist_t *replaced_conns,
smartlist_t *new_conns) smartlist_t *new_conns)
{ {
or_options_t *options = get_options(); const or_options_t *options = get_options();
int retval = 0; int retval = 0;
const uint16_t old_or_port = router_get_advertised_or_port(options); const uint16_t old_or_port = router_get_advertised_or_port(options);
const uint16_t old_dir_port = router_get_advertised_dir_port(options, 0); const uint16_t old_dir_port = router_get_advertised_dir_port(options, 0);
...@@ -2071,7 +2071,7 @@ retry_all_listeners(smartlist_t *replaced_conns, ...@@ -2071,7 +2071,7 @@ retry_all_listeners(smartlist_t *replaced_conns,
static int static int
connection_is_rate_limited(connection_t *conn) connection_is_rate_limited(connection_t *conn)
{ {
or_options_t *options = get_options(); const or_options_t *options = get_options();
if (conn->linked) if (conn->linked)
return 0; /* Internal connection */ return 0; /* Internal connection */
else if (! options->CountPrivateBandwidth && else if (! options->CountPrivateBandwidth &&
...@@ -2269,7 +2269,7 @@ global_write_bucket_low(connection_t *conn, size_t attempt, int priority) ...@@ -2269,7 +2269,7 @@ global_write_bucket_low(connection_t *conn, size_t attempt, int priority)
if (priority == 1) { /* old-style v1 query */ if (priority == 1) { /* old-style v1 query */
/* Could we handle *two* of these requests within the next two seconds? */ /* Could we handle *two* of these requests within the next two seconds? */
or_options_t *options = get_options(); const or_options_t *options = get_options();
int64_t can_write = (int64_t)smaller_bucket int64_t can_write = (int64_t)smaller_bucket
+ 2*(options->RelayBandwidthRate ? options->RelayBandwidthRate : + 2*(options->RelayBandwidthRate ? options->RelayBandwidthRate :
options->BandwidthRate); options->BandwidthRate);
...@@ -2387,7 +2387,7 @@ connection_consider_empty_write_buckets(connection_t *conn) ...@@ -2387,7 +2387,7 @@ connection_consider_empty_write_buckets(connection_t *conn)
void void
connection_bucket_init(void) connection_bucket_init(void)