Use SOCKET_OK/TOR_INVALID_SOCKET in socketpair replacement code
Avoid a double-close on one failing case of the socketpair replacement code

Fix for bug 9400, spotted by coverity. Bug introduced in revision 2cb4f7a4
(subversion revision r389).
Merge branch 'bug9400_024_squashed' into maint-0.2.4
use !cbt_disabled in place of LearnCBT to avoid needless circs

This would make us do testing circuits "even when cbt is disabled by
consensus, or when we're a directory authority, or when we've failed
to write cbt history to our state file lately." (Roger's words.)

This is a fix for 9671 and an improvement in our fix for 5049.
The original misbehavior was in 0.2.2.14-alpha; the incomplete
fix was in 0.2.3.17-beta.
Merge branch 'bug9671_023' into maint-0.2.3
Merge remote-tracking branch 'origin/maint-0.2.3' into maint-0.2.4

Conflicts:
	src/or/circuitbuild.c
Separate cpuworker queues by handshake type

Now we prioritize ntor create cells over tap create cells.

Starts to address ticket 9574.
refactor and give it unit tests
add info-level logs to help track onion queue sizes
check bounds on handshake_type more thoroughly
do a lopsided round-robin between the onion queues

that way tap won't starve entirely, but we'll still handle ntor requests
quicker.
let the NumNTorsPerTAP consensus param override our queue choice
Be more general in calculating expected onion queue processing time

Now we consider the TAP cells we'll process while draining the NTor
queue, and vice versa.
add a changes entry for ticket 9574
nickm wants us to prioritize tap in a currently-rare edge case
Merge branch 'maint-0.2.4' into release-0.2.4
fold in recent changes entries