A surprisingly simple fix to the InfoSub/websocketpp deadlock.

This commit is contained in:
JoelKatz
2013-01-10 09:55:48 -08:00
parent c29fdacc41
commit 3a96e7c1b6
2 changed files with 13 additions and 0 deletions

View File

@@ -54,8 +54,17 @@ public:
mPingTimer(theApp->getAuxService()), mPinged(false)
{ setPingTimer(); }
void preDestroy()
{ // sever connection
mConnection.reset();
}
virtual ~WSConnection() { ; }
static void destroy(boost::shared_ptr< WSConnection<endpoint_type> >)
{ // Just discards the reference
}
// Implement overridden functions from base class:
void send(const Json::Value& jvObj)
{

View File

@@ -153,6 +153,10 @@ public:
ptr = it->second; // prevent the WSConnection from being destroyed until we release the lock
mMap.erase(it);
}
ptr->preDestroy(); // Must be done before we return
// Must be done without holding the websocket send lock
theApp->getAuxService().post(boost::bind(&WSConnection<endpoint_type>::destroy, ptr));
}
void on_message(connection_ptr cpClient, message_ptr mpMessage)