summaryrefslogtreecommitdiffstats
path: root/src/Server/ConnectionManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Server/ConnectionManager.cpp')
-rw-r--r--src/Server/ConnectionManager.cpp16
1 files changed, 10 insertions, 6 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),