summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-08-02 14:07:00 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-08-02 14:07:40 (GMT)
commit66fd05d46a6ead4d780bdb4da1ede43058c272da (patch)
tree04dc651f7ae91fdf072454978a46cfc996948576 /Slimber
parent8c60e86c8fc2cf60825c0ffbd882693dccf0b33c (diff)
downloadswift-contrib-66fd05d46a6ead4d780bdb4da1ede43058c272da.zip
swift-contrib-66fd05d46a6ead4d780bdb4da1ede43058c272da.tar.bz2
Slimber: Handle ConnectionServer disconnects more cleanly.
Diffstat (limited to 'Slimber')
-rw-r--r--Slimber/Server.cpp32
-rw-r--r--Slimber/Server.h2
2 files changed, 22 insertions, 12 deletions
diff --git a/Slimber/Server.cpp b/Slimber/Server.cpp
index 28e0659..a944ab9 100644
--- a/Slimber/Server.cpp
+++ b/Slimber/Server.cpp
@@ -53,19 +53,23 @@ void Server::start() {
serverFromClientConnectionServer =
boost::shared_ptr<BoostConnectionServer>(new BoostConnectionServer(
clientConnectionPort, &boostIOServiceThread.getIOService()));
- serverFromClientConnectionServer->onNewConnection.connect(
- boost::bind(&Server::handleNewClientConnection, this, _1));
- serverFromClientConnectionServer->onStopped.connect(
- boost::bind(&Server::handleClientConnectionServerStopped, this, _1));
+ serverFromClientConnectionServerSignalConnections.push_back(
+ serverFromClientConnectionServer->onNewConnection.connect(
+ boost::bind(&Server::handleNewClientConnection, this, _1)));
+ serverFromClientConnectionServerSignalConnections.push_back(
+ serverFromClientConnectionServer->onStopped.connect(
+ boost::bind(&Server::handleClientConnectionServerStopped, this, _1)));
assert(!serverFromNetworkConnectionServer);
serverFromNetworkConnectionServer =
boost::shared_ptr<BoostConnectionServer>(new BoostConnectionServer(
linkLocalConnectionPort, &boostIOServiceThread.getIOService()));
- serverFromNetworkConnectionServer->onNewConnection.connect(
- boost::bind(&Server::handleNewLinkLocalConnection, this, _1));
- serverFromNetworkConnectionServer->onStopped.connect(
- boost::bind(&Server::handleLinkLocalConnectionServerStopped, this, _1));
+ serverFromNetworkConnectionServerSignalConnections.push_back(
+ serverFromNetworkConnectionServer->onNewConnection.connect(
+ boost::bind(&Server::handleNewLinkLocalConnection, this, _1)));
+ serverFromNetworkConnectionServerSignalConnections.push_back(
+ serverFromNetworkConnectionServer->onStopped.connect(
+ boost::bind(&Server::handleLinkLocalConnectionServerStopped, this, _1)));
assert(!presenceManager);
presenceManager = new LinkLocalPresenceManager(linkLocalServiceBrowser);
@@ -108,12 +112,18 @@ void Server::stop(boost::optional<ServerError> e) {
if (serverFromNetworkConnectionServer) {
serverFromNetworkConnectionServer->stop();
- serverFromNetworkConnectionServer->cancelAllEvents();
+ foreach(boost::bsignals::connection& connection, serverFromNetworkConnectionServerSignalConnections) {
+ connection.disconnect();
+ }
+ serverFromNetworkConnectionServerSignalConnections.clear();
serverFromNetworkConnectionServer.reset();
}
if (serverFromClientConnectionServer) {
serverFromClientConnectionServer->stop();
- serverFromClientConnectionServer->cancelAllEvents();
+ foreach(boost::bsignals::connection& connection, serverFromClientConnectionServerSignalConnections) {
+ connection.disconnect();
+ }
+ serverFromClientConnectionServerSignalConnections.clear();
serverFromClientConnectionServer.reset();
}
@@ -350,7 +360,6 @@ void Server::handlePresenceChanged(boost::shared_ptr<Presence> presence) {
}
void Server::handleClientConnectionServerStopped(boost::optional<BoostConnectionServer::Error> e) {
- std::cout << "Client server stoppedd " << (bool) e << std::endl;
if (e) {
if (*e == BoostConnectionServer::Conflict) {
stop(ServerError(ServerError::C2SPortConflict));
@@ -365,7 +374,6 @@ void Server::handleClientConnectionServerStopped(boost::optional<BoostConnection
}
void Server::handleLinkLocalConnectionServerStopped(boost::optional<BoostConnectionServer::Error> e) {
- std::cout << "LL server stoppedd " << (bool) e << std::endl;
if (e) {
if (*e == BoostConnectionServer::Conflict) {
stop(ServerError(ServerError::LinkLocalPortConflict));
diff --git a/Slimber/Server.h b/Slimber/Server.h
index ff3f70d..372a3d3 100644
--- a/Slimber/Server.h
+++ b/Slimber/Server.h
@@ -91,10 +91,12 @@ namespace Swift {
LinkLocalPresenceManager* presenceManager;
bool stopping;
boost::shared_ptr<BoostConnectionServer> serverFromClientConnectionServer;
+ std::vector<boost::bsignals::connection> serverFromClientConnectionServerSignalConnections;
boost::shared_ptr<ServerFromClientSession> serverFromClientSession;
boost::shared_ptr<Presence> lastPresence;
JID selfJID;
boost::shared_ptr<BoostConnectionServer> serverFromNetworkConnectionServer;
+ std::vector<boost::bsignals::connection> serverFromNetworkConnectionServerSignalConnections;
std::vector< boost::shared_ptr<Session> > linkLocalSessions;
std::vector< boost::shared_ptr<LinkLocalConnector> > connectors;
std::vector< boost::shared_ptr<SessionTracer> > tracers;