Have the OOM handler also count the age the data in a stream buffer
Count freed buffer bytes from buffers when oom-killing circuits.

Also, aggressively clear the buffers to try to make their bytes go
away fast rather than waiting for the close-marked-connection code
to get 'em.
doxygen comments for 10169 code
Changess file for #10169
Rename MaxMemInCellQueues to MaxMemInQueues
Drop the MaxMemInQueues lower limit down to 256 MB.

on #9686, gmorehose reports that the 500 MB lower limit is too high
for raspberry pi users.
Disable (Cell,Entry,ExitPort)Statistics on bridges

In 0.2.3.8-alpha we attempted to "completely disable stats if we aren't
running as a relay", but instead disabled them only if we aren't running
as a server.

This commit leaves DirReqStatistics enabled on both relays and bridges,
and disables (Cell,Entry,ExitPort)Statistics on bridges.
Report complete directory request statistics on bridges.

When we wrote the directory request statistics code in August 2009, we
thought that these statistics were only relevant for bridges, and that
bridges should not report them.  That's why we added a switch to discard
relevant observations made by bridges.  This code was first released in
0.2.2.1-alpha.

In May 2012 we learned that we didn't fully disable directory request
statistics on bridges.  Bridges did report directory request statistics,
but these statistics contained empty dirreq-v3-ips and dirreq-v3-reqs
lines.  But the remaining dirreq-* lines have always been non-empty.  (We
didn't notice for almost three years, because directory-request statistics
were disabled by default until 0.2.3.1-alpha, and all statistics have been
removed from bridge descriptors before publishing them on the metrics
website.)

Proposal 201, created in May 2012, suggests to add a new line called
bridge-v3-reqs that is similar to dirreq-v3-reqs, but that is published
only by bridges.  This proposal is still open as of December 2013.

Since October 2012 we're using dirreq-v3-resp (not -reqs) lines in
combination with bridge-ips lines to estimate bridge user numbers; see
task 8462.  This estimation method has superseded the older approach that
was only based on bridge-ips lines in November 2013.  Using dirreq-v3-resp
and bridge-ips lines is a workaround.  The cleaner approach would be to
use dirreq-v3-reqs instead.

This commit makes bridges report the same directory request statistics as
relays, including dirreq-v3-ips and dirreq-v3-reqs lines.  It makes
proposal 201 obsolete.
Merge remote-tracking branch 'public/bug10169_023' into bug10169_024

Conflicts:
	doc/tor.1.txt
	src/or/config.c
	src/or/or.h

The conflicts were all pretty trivial.
bug10449: a dying owning controller makes Tor exit immediately

If you want a slow shutdown, send SIGNAL SHUTDOWN.

(Why not just have the default be SIGNAL QUIT?  Because this case
should only happen when an owning controller has crashed, and a
crashed controller won't be able to give the user any "tor is
shutting down" feedback, and so the user gets confused for a while.
See bug 10449 for more info)
Fix bugs in bug10169 bugfix memory tracking

The chunk_grow() and chunk_copy() functions weren't adjusting the
memory totals properly.

Bugfix not on any released Tor version.
Actually release buffer freelists when handling OOM conditions.

Otherwise freeing buffers won't help for a little while.
Merge remote-tracking branch 'public/bug10169_023' into bug10169_024
Merge remote-tracking branch 'public/bug10169_024' into bug10169_025_v2

Conflicts:
	src/or/circuitlist.c
Debugging code inbuffers.c for debugging chunk allocation.

Currently on; will disable later in this branch.
Start writing tests for 10169.

Now we cover more chunk allocation functions.
Several tests for buffer allocation
Add tests for buffer time tracking.
Refactor OOM-handling functions for more testability

This patch splits out some of the functions in OOM handling so that
it's easier to check them without involving the rest of Tor or
requiring that the circuits be "wired up".
Initial unit tests for OOM handling