mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Fix the deadlock. We were destroying the WSConnection while holding the
MapLock causing a deadlock between the MapLock and MonitorLock.
This commit is contained in:
@@ -91,10 +91,17 @@ public:
|
||||
}
|
||||
|
||||
void on_close(connection_ptr cpClient)
|
||||
{
|
||||
boost::mutex::scoped_lock sl(mMapLock);
|
||||
|
||||
mMap.erase(cpClient);
|
||||
{ // we cannot destroy the connection while holding the map lock or we deadlock with pubLedger
|
||||
typedef boost::shared_ptr< WSConnection<endpoint_type> > wsc_ptr;
|
||||
wsc_ptr ptr;
|
||||
{
|
||||
boost::mutex::scoped_lock sl(mMapLock);
|
||||
typename boost::unordered_map<connection_ptr, wsc_ptr>::iterator it = mMap.find(cpClient);
|
||||
if (it == mMap.end())
|
||||
return;
|
||||
ptr = it->second; // prevent the WSConnection from being destroyed until we release the lock
|
||||
mMap.erase(cpClient);
|
||||
}
|
||||
}
|
||||
|
||||
void on_message(connection_ptr cpClient, message_ptr mpMessage)
|
||||
|
||||
Reference in New Issue
Block a user