summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
Diffstat (limited to 'src/or')
-rw-r--r--src/or/buffers.c6
-rw-r--r--src/or/circuitlist.c19
-rw-r--r--src/or/config.c18
-rw-r--r--src/or/cpuworker.c7
-rw-r--r--src/or/directory.c6
-rw-r--r--src/or/entrynodes.c2
-rw-r--r--src/or/or.h19
-rw-r--r--src/or/routerlist.c17
-rw-r--r--src/or/routerparse.c2
9 files changed, 40 insertions, 56 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index fb186081cf..e54751db28 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -117,6 +117,9 @@ chunk_repack(chunk_t *chunk)
chunk->data = &chunk->mem[0];
}
+/** Keep track of total size of allocated chunks for consistency asserts */
+static size_t total_bytes_allocated_in_chunks = 0;
+
#if defined(ENABLE_BUF_FREELISTS) || defined(RUNNING_DOXYGEN)
/** A freelist of chunks. */
typedef struct chunk_freelist_t {
@@ -148,9 +151,6 @@ static chunk_freelist_t freelists[] = {
* could help with? */
static uint64_t n_freelist_miss = 0;
-/** DOCDOC */
-static size_t total_bytes_allocated_in_chunks = 0;
-
static void assert_freelist_ok(chunk_freelist_t *fl);
/** Return the freelist to hold chunks of size <b>alloc</b>, or NULL if
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index c54a95419a..90fc93f3a8 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -1821,7 +1821,7 @@ circuit_max_queued_cell_age(const circuit_t *c, uint32_t now)
age = now - cell->inserted_time;
if (! CIRCUIT_IS_ORIGIN(c)) {
- const or_circuit_t *orcirc = TO_OR_CIRCUIT((circuit_t*)c);
+ const or_circuit_t *orcirc = CONST_TO_OR_CIRCUIT(c);
if (NULL != (cell = TOR_SIMPLEQ_FIRST(&orcirc->p_chan_cells.head))) {
uint32_t age2 = now - cell->inserted_time;
if (age2 > age)
@@ -1863,10 +1863,10 @@ circuit_max_queued_data_age(const circuit_t *c, uint32_t now)
{
if (CIRCUIT_IS_ORIGIN(c)) {
return circuit_get_streams_max_data_age(
- TO_ORIGIN_CIRCUIT((circuit_t*)c)->p_streams, now);
+ CONST_TO_ORIGIN_CIRCUIT(c)->p_streams, now);
} else {
return circuit_get_streams_max_data_age(
- TO_OR_CIRCUIT((circuit_t*)c)->n_streams, now);
+ CONST_TO_OR_CIRCUIT(c)->n_streams, now);
}
}
@@ -2057,15 +2057,10 @@ assert_circuit_ok(const circuit_t *c)
tor_assert(c->purpose >= CIRCUIT_PURPOSE_MIN_ &&
c->purpose <= CIRCUIT_PURPOSE_MAX_);
- {
- /* Having a separate variable for this pleases GCC 4.2 in ways I hope I
- * never understand. -NM. */
- circuit_t *nonconst_circ = (circuit_t*) c;
- if (CIRCUIT_IS_ORIGIN(c))
- origin_circ = TO_ORIGIN_CIRCUIT(nonconst_circ);
- else
- or_circ = TO_OR_CIRCUIT(nonconst_circ);
- }
+ if (CIRCUIT_IS_ORIGIN(c))
+ origin_circ = CONST_TO_ORIGIN_CIRCUIT(c);
+ else
+ or_circ = CONST_TO_OR_CIRCUIT(c);
if (c->n_chan) {
tor_assert(!c->n_hop);
diff --git a/src/or/config.c b/src/or/config.c
index 3954c582ef..1faf13871b 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -237,6 +237,7 @@ static config_var_t option_vars_[] = {
V(ExitPortStatistics, BOOL, "0"),
V(ExtendAllowPrivateAddresses, BOOL, "0"),
VPORT(ExtORPort, LINELIST, NULL),
+ V(ExtORPortCookieAuthFile, STRING, NULL),
V(ExtraInfoStatistics, BOOL, "1"),
V(FallbackDir, LINELIST, NULL),
@@ -307,7 +308,7 @@ static config_var_t option_vars_[] = {
V(MaxAdvertisedBandwidth, MEMUNIT, "1 GB"),
V(MaxCircuitDirtiness, INTERVAL, "10 minutes"),
V(MaxClientCircuitsPending, UINT, "32"),
- VAR("MaxMeminQueues", MEMUNIT, MaxMemInQueues_raw, "0"),
+ VAR("MaxMemInQueues", MEMUNIT, MaxMemInQueues_raw, "0"),
OBSOLETE("MaxOnionsPending"),
V(MaxOnionQueueDelay, MSEC_INTERVAL, "1750 msec"),
V(MinMeasuredBWsForAuthToIgnoreAdvertised, INT, "500"),
@@ -356,7 +357,7 @@ static config_var_t option_vars_[] = {
V(OptimisticData, AUTOBOOL, "auto"),
V(PortForwarding, BOOL, "0"),
V(PortForwardingHelper, FILENAME, "tor-fw-helper"),
- V(PreferTunneledDirConns, BOOL, "1"),
+ OBSOLETE("PreferTunneledDirConns"),
V(ProtocolWarnings, BOOL, "0"),
V(PublishServerDescriptor, CSV, "1"),
V(PublishHidServDescriptors, BOOL, "1"),
@@ -411,7 +412,7 @@ static config_var_t option_vars_[] = {
V(TransListenAddress, LINELIST, NULL),
VPORT(TransPort, LINELIST, NULL),
V(TransProxyType, STRING, "default"),
- V(TunnelDirConns, BOOL, "1"),
+ OBSOLETE("TunnelDirConns"),
V(UpdateBridgesFromAuthority, BOOL, "0"),
V(UseBridges, BOOL, "0"),
V(UseEntryGuards, BOOL, "1"),
@@ -3274,8 +3275,6 @@ options_validate(or_options_t *old_options, or_options_t *options,
if (options->UseBridges && !options->Bridges)
REJECT("If you set UseBridges, you must specify at least one bridge.");
- if (options->UseBridges && !options->TunnelDirConns)
- REJECT("If you set UseBridges, you must set TunnelDirConns.");
for (cl = options->Bridges; cl; cl = cl->next) {
bridge_line_t *bridge_line = parse_bridge_line(cl->value);
@@ -3388,15 +3387,6 @@ options_validate(or_options_t *old_options, or_options_t *options,
AF_INET6, 1, msg)<0)
return -1;
- if (options->PreferTunneledDirConns && !options->TunnelDirConns)
- REJECT("Must set TunnelDirConns if PreferTunneledDirConns is set.");
-
- if ((options->Socks4Proxy || options->Socks5Proxy) &&
- !options->HTTPProxy && !options->PreferTunneledDirConns)
- REJECT("When Socks4Proxy or Socks5Proxy is configured, "
- "PreferTunneledDirConns and TunnelDirConns must both be "
- "set to 1, or HTTPProxy must be configured.");
-
if (options->AutomapHostsSuffixes) {
SMARTLIST_FOREACH(options->AutomapHostsSuffixes, char *, suf,
{
diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c
index 6b6a68afe5..61b2c29b38 100644
--- a/src/or/cpuworker.c
+++ b/src/or/cpuworker.c
@@ -528,7 +528,12 @@ spawn_cpuworker(void)
tor_assert(SOCKET_OK(fdarray[1]));
fd = fdarray[0];
- spawn_func(cpuworker_main, (void*)fdarray);
+ if (spawn_func(cpuworker_main, (void*)fdarray) < 0) {
+ tor_close_socket(fdarray[0]);
+ tor_close_socket(fdarray[1]);
+ tor_free(fdarray);
+ return -1;
+ }
log_debug(LD_OR,"just spawned a cpu worker.");
#ifndef TOR_IS_MULTITHREADED
tor_close_socket(fdarray[1]); /* don't need the worker's side of the pipe */
diff --git a/src/or/directory.c b/src/or/directory.c
index 8070a76a55..76cb8fa0bc 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -338,8 +338,6 @@ should_use_directory_guards(const or_options_t *options)
if (options->DownloadExtraInfo || options->FetchDirInfoEarly ||
options->FetchDirInfoExtraEarly || options->FetchUselessDescriptors)
return 0;
- if (! options->PreferTunneledDirConns)
- return 0;
return 1;
}
@@ -834,6 +832,7 @@ directory_command_should_use_begindir(const or_options_t *options,
int or_port, uint8_t router_purpose,
dir_indirection_t indirection)
{
+ (void) router_purpose;
if (!or_port)
return 0; /* We don't know an ORPort -- no chance. */
if (indirection == DIRIND_DIRECT_CONN || indirection == DIRIND_ANON_DIRPORT)
@@ -842,9 +841,6 @@ directory_command_should_use_begindir(const or_options_t *options,
if (!fascist_firewall_allows_address_or(addr, or_port) ||
directory_fetches_from_authorities(options))
return 0; /* We're firewalled or are acting like a relay -- also no. */
- if (!options->TunnelDirConns &&
- router_purpose != ROUTER_PURPOSE_BRIDGE)
- return 0; /* We prefer to avoid using begindir conns. Fine. */
return 1;
}
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 70587bd758..957217ac6c 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -378,7 +378,7 @@ add_an_entry_guard(const node_t *chosen, int reset_status, int prepend,
} else {
const routerstatus_t *rs;
rs = router_pick_directory_server(MICRODESC_DIRINFO|V3_DIRINFO,
- PDS_PREFER_TUNNELED_DIR_CONNS_|PDS_FOR_GUARD);
+ PDS_FOR_GUARD);
if (!rs)
return NULL;
node = node_get_by_id(rs->identity_digest);
diff --git a/src/or/or.h b/src/or/or.h
index 701877c64b..6aa6b59e8e 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -3231,20 +3231,33 @@ typedef struct or_circuit_rendinfo_s {
/** Convert a circuit_t* to a pointer to the enclosing or_circuit_t. Assert
* if the cast is impossible. */
static or_circuit_t *TO_OR_CIRCUIT(circuit_t *);
+static const or_circuit_t *CONST_TO_OR_CIRCUIT(const circuit_t *);
/** Convert a circuit_t* to a pointer to the enclosing origin_circuit_t.
* Assert if the cast is impossible. */
static origin_circuit_t *TO_ORIGIN_CIRCUIT(circuit_t *);
+static const origin_circuit_t *CONST_TO_ORIGIN_CIRCUIT(const circuit_t *);
static INLINE or_circuit_t *TO_OR_CIRCUIT(circuit_t *x)
{
tor_assert(x->magic == OR_CIRCUIT_MAGIC);
return DOWNCAST(or_circuit_t, x);
}
+static INLINE const or_circuit_t *CONST_TO_OR_CIRCUIT(const circuit_t *x)
+{
+ tor_assert(x->magic == OR_CIRCUIT_MAGIC);
+ return DOWNCAST(or_circuit_t, x);
+}
static INLINE origin_circuit_t *TO_ORIGIN_CIRCUIT(circuit_t *x)
{
tor_assert(x->magic == ORIGIN_CIRCUIT_MAGIC);
return DOWNCAST(origin_circuit_t, x);
}
+static INLINE const origin_circuit_t *CONST_TO_ORIGIN_CIRCUIT(
+ const circuit_t *x)
+{
+ tor_assert(x->magic == ORIGIN_CIRCUIT_MAGIC);
+ return DOWNCAST(origin_circuit_t, x);
+}
/** Bitfield type: things that we're willing to use invalid routers for. */
typedef enum invalid_router_usage_t {
@@ -3873,10 +3886,6 @@ typedef struct {
* testing our DNS server. */
int EnforceDistinctSubnets; /**< If true, don't allow multiple routers in the
* same network zone in the same circuit. */
- int TunnelDirConns; /**< If true, use BEGIN_DIR rather than BEGIN when
- * possible. */
- int PreferTunneledDirConns; /**< If true, avoid dirservers that don't
- * support BEGIN_DIR, when possible. */
int PortForwarding; /**< If true, use NAT-PMP or UPnP to automatically
* forward the DirPort and ORPort on the NAT device */
char *PortForwardingHelper; /** < Filename or full path of the port
@@ -4961,8 +4970,6 @@ typedef struct dir_server_t {
* node that's currently a guard. */
#define PDS_FOR_GUARD (1<<5)
-#define PDS_PREFER_TUNNELED_DIR_CONNS_ (1<<16)
-
/** Possible ways to weight routers when choosing one randomly. See
* routerlist_sl_choose_by_bandwidth() for more information.*/
typedef enum bandwidth_weight_rule_t {
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index c15274e991..8f3477a4a4 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -1282,8 +1282,6 @@ const routerstatus_t *
router_pick_directory_server(dirinfo_type_t type, int flags)
{
const routerstatus_t *choice;
- if (get_options()->PreferTunneledDirConns)
- flags |= PDS_PREFER_TUNNELED_DIR_CONNS_;
if (!routerlist)
return NULL;
@@ -1385,8 +1383,6 @@ router_pick_dirserver_generic(smartlist_t *sourcelist,
{
const routerstatus_t *choice;
int busy = 0;
- if (get_options()->PreferTunneledDirConns)
- flags |= PDS_PREFER_TUNNELED_DIR_CONNS_;
choice = router_pick_trusteddirserver_impl(sourcelist, type, flags, &busy);
if (choice || !(flags & PDS_RETRY_IF_NO_SERVERS))
@@ -1411,10 +1407,7 @@ router_pick_dirserver_generic(smartlist_t *sourcelist,
/** Pick a random running valid directory server/mirror from our
* routerlist. Arguments are as for router_pick_directory_server(), except
- * that RETRY_IF_NO_SERVERS is ignored, and:
- *
- * If the PDS_PREFER_TUNNELED_DIR_CONNS_ flag is set, prefer directory servers
- * that we can use with BEGINDIR.
+ * that RETRY_IF_NO_SERVERS is ignored.
*/
static const routerstatus_t *
router_pick_directory_server_impl(dirinfo_type_t type, int flags)
@@ -1428,7 +1421,6 @@ router_pick_directory_server_impl(dirinfo_type_t type, int flags)
const networkstatus_t *consensus = networkstatus_get_latest_consensus();
int requireother = ! (flags & PDS_ALLOW_SELF);
int fascistfirewall = ! (flags & PDS_IGNORE_FASCISTFIREWALL);
- int prefer_tunnel = (flags & PDS_PREFER_TUNNELED_DIR_CONNS_);
int for_guard = (flags & PDS_FOR_GUARD);
int try_excluding = 1, n_excluded = 0;
@@ -1481,8 +1473,7 @@ router_pick_directory_server_impl(dirinfo_type_t type, int flags)
is_overloaded = status->last_dir_503_at + DIR_503_TIMEOUT > now;
- if (prefer_tunnel &&
- (!fascistfirewall ||
+ if ((!fascistfirewall ||
fascist_firewall_allows_address_or(&addr, status->or_port)))
smartlist_add(is_trusted ? trusted_tunnel :
is_overloaded ? overloaded_tunnel : tunnel, (void*)node);
@@ -1569,7 +1560,6 @@ router_pick_trusteddirserver_impl(const smartlist_t *sourcelist,
time_t now = time(NULL);
const int requireother = ! (flags & PDS_ALLOW_SELF);
const int fascistfirewall = ! (flags & PDS_IGNORE_FASCISTFIREWALL);
- const int prefer_tunnel = (flags & PDS_PREFER_TUNNELED_DIR_CONNS_);
const int no_serverdesc_fetching =(flags & PDS_NO_EXISTING_SERVERDESC_FETCH);
const int no_microdesc_fetching =(flags & PDS_NO_EXISTING_MICRODESC_FETCH);
const double auth_weight = (sourcelist == fallback_dir_servers) ?
@@ -1630,8 +1620,7 @@ router_pick_trusteddirserver_impl(const smartlist_t *sourcelist,
}
}
- if (prefer_tunnel &&
- d->or_port &&
+ if (d->or_port &&
(!fascistfirewall ||
fascist_firewall_allows_address_or(&addr, d->or_port)))
smartlist_add(is_overloaded ? overloaded_tunnel : tunnel, (void*)d);
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 14f800e7be..5add728d6d 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -4129,11 +4129,13 @@ microdescs_parse_from_string(const char *s, const char *eos,
microdesc_free(md);
md = NULL;
+ SMARTLIST_FOREACH(tokens, directory_token_t *, t, token_clear(t));
memarea_clear(area);
smartlist_clear(tokens);
s = start_of_next_microdesc;
}
+ SMARTLIST_FOREACH(tokens, directory_token_t *, t, token_clear(t));
memarea_drop_all(area);
smartlist_free(tokens);