Fix a crash bug reported by Jon Montroll.

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.)
This commit is contained in:
JoelKatz
2013-02-21 02:43:20 -08:00
parent 0d928f8471
commit a2a52ad88b
2 changed files with 20 additions and 32 deletions

View File

@@ -16,8 +16,8 @@
class ConnectionPool
{
private:
boost::mutex mPeerLock;
uint64 mLastPeer;
boost::recursive_mutex mPeerLock;
uint64 mLastPeer;
typedef std::pair<RippleAddress, Peer::pointer> naPeer;
typedef std::pair<ipPort, Peer::pointer> pipPeer;