diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-09-10 15:02:18 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-09-11 21:53:46 (GMT) |
commit | 5fa9ecb3dff1a5918c202b72a5db313c0b7b879a (patch) | |
tree | efd7abfd306e5e2f773bdc62c7bf1ed491c5c410 /Swiften | |
parent | bc6a510af449b6e383a11fc20c9859b8bcac247c (diff) | |
download | swift-5fa9ecb3dff1a5918c202b72a5db313c0b7b879a.zip swift-5fa9ecb3dff1a5918c202b72a5db313c0b7b879a.tar.bz2 |
Fixed some memory leaks.
Diffstat (limited to 'Swiften')
-rw-r--r-- | Swiften/Client/ClientSession.cpp | 12 | ||||
-rw-r--r-- | Swiften/Client/ClientSession.h | 4 | ||||
-rw-r--r-- | Swiften/Client/UnitTest/ClientSessionTest.cpp | 8 | ||||
-rw-r--r-- | Swiften/Disco/UnitTest/CapsManagerTest.cpp | 1 | ||||
-rw-r--r-- | Swiften/Network/Connector.cpp | 9 | ||||
-rw-r--r-- | Swiften/Network/Connector.h | 1 |
6 files changed, 30 insertions, 5 deletions
diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp index daffbc6..17b3931 100644 --- a/Swiften/Client/ClientSession.cpp +++ b/Swiften/Client/ClientSession.cpp @@ -56,10 +56,10 @@ ClientSession::~ClientSession() { } void ClientSession::start() { - stream->onStreamStartReceived.connect(boost::bind(&ClientSession::handleStreamStart, shared_from_this(), _1)); - stream->onElementReceived.connect(boost::bind(&ClientSession::handleElement, shared_from_this(), _1)); - stream->onError.connect(boost::bind(&ClientSession::handleStreamError, shared_from_this(), _1)); - stream->onTLSEncrypted.connect(boost::bind(&ClientSession::handleTLSEncrypted, shared_from_this())); + streamOnStreamStartReceivedConnection = stream->onStreamStartReceived.connect(boost::bind(&ClientSession::handleStreamStart, shared_from_this(), _1)); + streamOnElementReceivedConnection = stream->onElementReceived.connect(boost::bind(&ClientSession::handleElement, shared_from_this(), _1)); + streamOnErrorConnection = stream->onError.connect(boost::bind(&ClientSession::handleStreamError, shared_from_this(), _1)); + streamOnTLSEncryptedConnection = stream->onTLSEncrypted.connect(boost::bind(&ClientSession::handleTLSEncrypted, shared_from_this())); assert(state == Initial); state = WaitingForStreamStart; @@ -347,6 +347,10 @@ void ClientSession::finishSession(Error::Type error) { void ClientSession::finishSession(boost::shared_ptr<Swift::Error> error) { state = Finished; stream->setWhitespacePingEnabled(false); + streamOnStreamStartReceivedConnection.disconnect(); + streamOnElementReceivedConnection.disconnect(); + streamOnErrorConnection.disconnect(); + streamOnTLSEncryptedConnection.disconnect(); onFinished(error); } diff --git a/Swiften/Client/ClientSession.h b/Swiften/Client/ClientSession.h index 359d7c8..cd364fe 100644 --- a/Swiften/Client/ClientSession.h +++ b/Swiften/Client/ClientSession.h @@ -123,5 +123,9 @@ namespace Swift { ClientAuthenticator* authenticator; boost::shared_ptr<StanzaAckRequester> stanzaAckRequester_; boost::shared_ptr<StanzaAckResponder> stanzaAckResponder_; + boost::bsignals::connection streamOnStreamStartReceivedConnection; + boost::bsignals::connection streamOnElementReceivedConnection; + boost::bsignals::connection streamOnErrorConnection; + boost::bsignals::connection streamOnTLSEncryptedConnection; }; } diff --git a/Swiften/Client/UnitTest/ClientSessionTest.cpp b/Swiften/Client/UnitTest/ClientSessionTest.cpp index 2762188..2cd9fd2 100644 --- a/Swiften/Client/UnitTest/ClientSessionTest.cpp +++ b/Swiften/Client/UnitTest/ClientSessionTest.cpp @@ -82,6 +82,8 @@ class ClientSessionTest : public CppUnit::TestFixture { server->onTLSEncrypted(); server->receiveStreamStart(); server->sendStreamStart(); + + session->finish(); } void testStartTLS_ServerError() { @@ -126,6 +128,8 @@ class ClientSessionTest : public CppUnit::TestFixture { server->receiveAuthRequest("PLAIN"); server->sendAuthSuccess(); server->receiveStreamStart(); + + session->finish(); } void testAuthenticate_Unauthorized() { @@ -190,6 +194,8 @@ class ClientSessionTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(session->getStreamManagementEnabled()); // TODO: Test if the requesters & responders do their work CPPUNIT_ASSERT_EQUAL(ClientSession::Initialized, session->getState()); + + session->finish(); } void testStreamManagement_Failed() { @@ -211,6 +217,8 @@ class ClientSessionTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(!session->getStreamManagementEnabled()); CPPUNIT_ASSERT_EQUAL(ClientSession::Initialized, session->getState()); + + session->finish(); } diff --git a/Swiften/Disco/UnitTest/CapsManagerTest.cpp b/Swiften/Disco/UnitTest/CapsManagerTest.cpp index 2156c3e..7925ae7 100644 --- a/Swiften/Disco/UnitTest/CapsManagerTest.cpp +++ b/Swiften/Disco/UnitTest/CapsManagerTest.cpp @@ -57,6 +57,7 @@ class CapsManagerTest : public CppUnit::TestFixture { } void tearDown() { + delete storage; delete iqRouter; delete stanzaChannel; } diff --git a/Swiften/Network/Connector.cpp b/Swiften/Network/Connector.cpp index 34fdf0b..d9a4c5d 100644 --- a/Swiften/Network/Connector.cpp +++ b/Swiften/Network/Connector.cpp @@ -112,7 +112,7 @@ void Connector::tryConnect(const HostAddressPort& target) { assert(!currentConnection); //std::cout << "Connector::tryConnect() " << target.getAddress().toString() << " " << target.getPort() << std::endl; currentConnection = connectionFactory->createConnection(); - currentConnection->onConnectFinished.connect(boost::bind(&Connector::handleConnectionConnectFinished, shared_from_this(), _1)); + connectFinishedConnection = currentConnection->onConnectFinished.connect(boost::bind(&Connector::handleConnectionConnectFinished, shared_from_this(), _1)); currentConnection->connect(target); } @@ -140,6 +140,13 @@ void Connector::finish(boost::shared_ptr<Connection> connection) { timer->stop(); timer.reset(); } + if (serviceQuery) { + serviceQuery.reset(); + } + if (addressQuery) { + addressQuery.reset(); + } + connectFinishedConnection.disconnect(); onConnectFinished(connection); } diff --git a/Swiften/Network/Connector.h b/Swiften/Network/Connector.h index 6442a8f..36026de 100644 --- a/Swiften/Network/Connector.h +++ b/Swiften/Network/Connector.h @@ -65,5 +65,6 @@ namespace Swift { std::deque<HostAddress> addressQueryResults; bool queriedAllServices; boost::shared_ptr<Connection> currentConnection; + boost::bsignals::connection connectFinishedConnection; }; }; |