Check spawn_func() return value

If we don't, we can wind up with a wedged cpuworker, and write to it
for ages and ages.

Found by skruffy.  This was a bug in 2dda97e8fd898757, a.k.a. svn
revision 402. It's been there since we have been using cpuworkers.
Removing is_internal_IP() function. Resolves ticket 4645.
Using proper functions to create tor_addr_t.
Fixes for bug4645 fix.
More hacking around spawn_func issues

This time, we use a pthread_attr to make sure that if pthread_create
succeeds, the thread is successfully detached.

This probably isn't the big thing going on with 4345, since it'd be
a bit weird for pthread_detach to be failing.  But it's worth
getting it right.
Remove TunnelDirConns and PreferTunnelledDirConns

These options were added back in 0.1.2.5-alpha, but no longer make any
sense now that all directories support tunneled connections and
BEGIN_DIR cells.  These options were on by default; now they are
always-on.

This is a fix for 10849, where TunnelDirConns 0 would break hidden
services -- and that bug arrived, I think, in 0.2.0.10-alpha.
Log only one message for dangerous log settings.

We log only one message, containing a complete list of what's
wrong.  We log the complete list whenever any of the possible things
that could have gotten wrong gets worse.

Fix for #9870. Bugfix on 10480dff01bece13fab, which we merged in
0.2.5.1-alpha.
Faster circuit_get_by_rend_token_and_purpose()

On busy servers, this function takes up something like 3-7% in
different profiles, and gets invoked every time we need to participate
as the midpoint in a hidden service.

So maybe walking through a linked list of all the circuits here wasn't
a good idea.
Merge remote-tracking branch 'public/bug9841_024_v2' into bug9841_025

Conflicts:
	src/or/circuitlist.c
Tweak sign of rend_token params for consistency
Tests for rend_token maps

This gets coverage of everything except for the cases which should be
impossible.
Update ns downloads when we receive a bridge descriptor

This prevents long stalls when we're starting with a state file but
with no bridge descriptors.  Fixes bug 9229.  I believe this bug has
been present since 0.2.0.3-alpha.
Fix our check for the "first" bridge descriptor.

This is meant to be a better bug 9229 fix -- or at least, one more
in tune with the intent of the original code, which calls
router_retry_directory_downloads() only on the first bridge descriptor.
should_disable_dir_fetches() now returns 1 if DisableNetwork==1

This change prevents LD_BUG warnings and bootstrap failure messages
when we try to do directory fetches when starting with
DisableNetwork == 1, a consensus present, but no descriptors (or
insufficient descriptors) yet.

Fixes bug 11200 and bug 10405.  It's a bugfix on 0.2.3.9-alpha.
Thanks to mcs for walking me through the repro instructions!
Fix a use-after-free in test_circuitlist.c

Found by clang-3.4 analyzers.
memarea.c: use flexible array member for mem

This make clang's memory sanitizer happier that we aren't reading
off the end of a char[1].  We hadn't replaced the char[1] with a
char[FLEXIBLE_ARRAY_MEMBER] before because we were doing a union
trick to force alignment.  Now we use __attribute__(aligned) where
available, and we do the union trick elsewhere.

Most of this patch is just replacing accesses to (x)->u.mem with
(x)->U_MEM, where U_MEM is defined as "u.mem" or "mem" depending on
our implementation.
csiphash: don't attempt unaligned access

In digestmap_set/get benchmarks, doing unaligned access on x86
doesn't save more than a percent or so in the fast case.  In the
slow case (where we cross a cache line), it could be pretty
expensive.  It also makes ubsan unhappy.
Fix a ubsan warning in our ctypes replacements

ubsan doesn't like 1<<31, since that's an undefined integer
overflow.  Instead, we should do 1u<<31.
Fix a ubsan warning in addr_mask_get_bits

ubsan doesn't like us to do (1u<<32) when 32 is wider than
unsigned.  Fortunately, we already special-case
addr_mask_get_bits(0), so we can just change the loop bounds.
changes file for bug11232