From 59bec05e406a0cf55c52d13cecfe76dccf83cd19 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 27 Aug 2009 02:51:16 +0200 Subject: =?UTF-8?q?Net::Connection=20etc.:=20Einige=20Race=20Conditions=20?= =?UTF-8?q?gefixt=20Keine=20sporadischen=20Abst=C3=BCrze=20mehr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Server/ConnectionManager.cpp | 16 ++++++++++------ src/Server/ConnectionManager.h | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src/Server') 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 con) { boost::shared_ptr connection(new ServerConnection(application, con)); - con->connectSignalDisconnected(boost::bind(&ConnectionManager::handleDisconnect, this, connection)); + con->connectSignalDisconnected(boost::bind(&ConnectionManager::handleDisconnect, this, boost::weak_ptr(connection))); connections.insert(connection); application->getRequestManager()->registerConnection(connection.get()); } -void ConnectionManager::handleDisconnect(boost::shared_ptr con) { - if(con->getHostInfo()) - updateState(con->getHostInfo(), Common::HostInfo::INACTIVE); +void ConnectionManager::handleDisconnect(boost::weak_ptr con) { + boost::shared_ptr 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 con); - void handleDisconnect(boost::shared_ptr con); + void handleDisconnect(boost::weak_ptr con); ConnectionManager(Application *application0); ~ConnectionManager(); -- cgit v1.2.3