ConnectionPool::peerConnect called Peer::connect while holding the
ConnectionPool::mPeerLock. But Peer::connect could call Peer::detach which
calls ConnectionPool::peerClosed which tries to acquire the
ConnectionPool::mPeerLock mutex. Said mutex was not recursive. Belt and
suspenders fix -- make the mutex recursive and make
ConnectionPool::peerConnection call Peer::connect without holding the
ConnectionPool::mPeerLock mutex. (This was intended to be a fast, internal
mutex and calls to external 'heavy' functions should not be made while
holding it.)
Most of these fixes involve calls to BOOST_FOREACH to iterate over a map or unordered_map where the
iterator type didn't perfectly match the internal type, so a reference into the map couldn't be created
and a new value/content pair had to be created for each iteration.