diff options
Diffstat (limited to 'src/Server')
-rw-r--r-- | src/Server/ConnectionManager.cpp | 16 | ||||
-rw-r--r-- | src/Server/ConnectionManager.h | 2 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/Server/ConnectionManager.cpp b/src/Server/ConnectionManager.cpp index b9490bc..27b65c2 100644 --- a/src/Server/ConnectionManager.cpp +++ b/src/Server/ConnectionManager.cpp @@ -194,19 +194,23 @@ void ConnectionManager::configFinished() { void ConnectionManager::handleNewConnection(boost::shared_ptr<Net::Connection> con) { boost::shared_ptr<ServerConnection> connection(new ServerConnection(application, con)); - con->connectSignalDisconnected(boost::bind(&ConnectionManager::handleDisconnect, this, connection)); + con->connectSignalDisconnected(boost::bind(&ConnectionManager::handleDisconnect, this, boost::weak_ptr<ServerConnection>(connection))); connections.insert(connection); application->getRequestManager()->registerConnection(connection.get()); } -void ConnectionManager::handleDisconnect(boost::shared_ptr<ServerConnection> con) { - if(con->getHostInfo()) - updateState(con->getHostInfo(), Common::HostInfo::INACTIVE); +void ConnectionManager::handleDisconnect(boost::weak_ptr<ServerConnection> con) { + boost::shared_ptr<ServerConnection> connection = con.lock(); + if(!connection) + return; + + if(connection->getHostInfo()) + updateState(connection->getHostInfo(), Common::HostInfo::INACTIVE); - connections.erase(con); + connections.erase(connection); - application->getRequestManager()->unregisterConnection(con.get()); + application->getRequestManager()->unregisterConnection(connection.get()); } ConnectionManager::ConnectionManager(Application *application0) : application(application0), diff --git a/src/Server/ConnectionManager.h b/src/Server/ConnectionManager.h index 9638f38..057e73e 100644 --- a/src/Server/ConnectionManager.h +++ b/src/Server/ConnectionManager.h @@ -127,7 +127,7 @@ class MAD_SERVER_EXPORT ConnectionManager : public Core::Configurable, private b void updateState(Common::HostInfo *hostInfo, Common::HostInfo::State state); void handleNewConnection(boost::shared_ptr<Net::Connection> con); - void handleDisconnect(boost::shared_ptr<ServerConnection> con); + void handleDisconnect(boost::weak_ptr<ServerConnection> con); ConnectionManager(Application *application0); ~ConnectionManager(); |