diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-08-27 02:51:16 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-08-27 02:51:16 +0200 |
commit | 59bec05e406a0cf55c52d13cecfe76dccf83cd19 (patch) | |
tree | 276b5d10e696148f9fd300f80ab8a7a0c6b0cd61 /src/Server | |
parent | c964aa2708ed2839ded3c35eed7338f3e81f568f (diff) | |
download | mad-59bec05e406a0cf55c52d13cecfe76dccf83cd19.tar mad-59bec05e406a0cf55c52d13cecfe76dccf83cd19.zip |
Net::Connection etc.: Einige Race Conditions gefixt
Keine sporadischen Abstürze mehr
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(); |