summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-04-24 21:42:44 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-04-24 21:42:44 (GMT)
commit045fb30399e3c9d74ceb4ebe3dbddc9416c3ce28 (patch)
tree04049c68e984b596e582cbe4fb91bbd3c1fb57dd /Swiften/LinkLocal
parent973ca2197c0f893b3350c48678dba2055d1dee48 (diff)
downloadswift-045fb30399e3c9d74ceb4ebe3dbddc9416c3ce28.zip
swift-045fb30399e3c9d74ceb4ebe3dbddc9416c3ce28.tar.bz2
Fix leaks in LinkLocalConnector.
Diffstat (limited to 'Swiften/LinkLocal')
-rw-r--r--Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h4
-rw-r--r--Swiften/LinkLocal/LinkLocalConnector.cpp13
-rw-r--r--Swiften/LinkLocal/LinkLocalConnector.h2
-rw-r--r--Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp1
-rw-r--r--Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp1
5 files changed, 17 insertions, 4 deletions
diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h
index ef7af02..f08ab68 100644
--- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h
+++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h
@@ -34,6 +34,10 @@ namespace Swift {
void start() {}
void stop() {}
+ void clearAllQueriesEverRun() {
+ allQueriesEverRun.clear();
+ }
+
boost::shared_ptr<DNSSDBrowseQuery> createBrowseQuery();
boost::shared_ptr<DNSSDRegisterQuery> createRegisterQuery(
const String& name, int port, const ByteArray& info);
diff --git a/Swiften/LinkLocal/LinkLocalConnector.cpp b/Swiften/LinkLocal/LinkLocalConnector.cpp
index 12347c9..42366e8 100644
--- a/Swiften/LinkLocal/LinkLocalConnector.cpp
+++ b/Swiften/LinkLocal/LinkLocalConnector.cpp
@@ -34,7 +34,7 @@ void LinkLocalConnector::connect() {
resolveQuery = querier->createResolveHostnameQuery(
service.getHostname(),
service.getID().getNetworkInterfaceID());
- resolveQuery->onHostnameResolved.connect(boost::bind(
+ resolveQueryHostNameResolvedConnection = resolveQuery->onHostnameResolved.connect(boost::bind(
&LinkLocalConnector::handleHostnameResolved,
boost::dynamic_pointer_cast<LinkLocalConnector>(shared_from_this()),
_1));
@@ -44,17 +44,20 @@ void LinkLocalConnector::connect() {
void LinkLocalConnector::cancel() {
if (resolveQuery) {
resolveQuery->finish();
+ resolveQueryHostNameResolvedConnection.disconnect();
+ resolveQuery.reset();
}
- resolveQuery.reset();
+ connectionConnectFinishedConnection.disconnect();
connection->disconnect();
}
void LinkLocalConnector::handleHostnameResolved(const boost::optional<HostAddress>& address) {
resolveQuery->finish();
+ resolveQueryHostNameResolvedConnection.disconnect();
resolveQuery.reset();
if (address) {
- connection->onConnectFinished.connect(
- boost::bind(boost::ref(onConnectFinished), _1));
+ connectionConnectFinishedConnection = connection->onConnectFinished.connect(
+ boost::bind(&LinkLocalConnector::handleConnected, shared_from_this(), _1));
connection->connect(HostAddressPort(*address, service.getPort()));
}
else {
@@ -64,6 +67,8 @@ void LinkLocalConnector::handleHostnameResolved(const boost::optional<HostAddres
void LinkLocalConnector::handleConnected(bool error) {
onConnectFinished(error);
+ assert(connectionConnectFinishedConnection.connected());
+ connectionConnectFinishedConnection.disconnect();
}
void LinkLocalConnector::queueElement(boost::shared_ptr<Element> element) {
diff --git a/Swiften/LinkLocal/LinkLocalConnector.h b/Swiften/LinkLocal/LinkLocalConnector.h
index 2a4f168..964eebf 100644
--- a/Swiften/LinkLocal/LinkLocalConnector.h
+++ b/Swiften/LinkLocal/LinkLocalConnector.h
@@ -57,7 +57,9 @@ namespace Swift {
LinkLocalService service;
boost::shared_ptr<DNSSDQuerier> querier;
boost::shared_ptr<DNSSDResolveHostnameQuery> resolveQuery;
+ boost::bsignals::connection resolveQueryHostNameResolvedConnection;
boost::shared_ptr<Connection> connection;
+ boost::bsignals::connection connectionConnectFinishedConnection;
std::vector<boost::shared_ptr<Element> > queuedElements;
};
}
diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp
index 4bd7852..f6fc131 100644
--- a/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp
+++ b/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp
@@ -36,6 +36,7 @@ class LinkLocalConnectorTest : public CppUnit::TestFixture {
}
void tearDown() {
+ querier->clearAllQueriesEverRun();
delete eventLoop;
}
diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp
index 4f53931..f4b0034 100644
--- a/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp
+++ b/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp
@@ -55,6 +55,7 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture {
}
void tearDown() {
+ querier->clearAllQueriesEverRun();
addedServices.clear();
removedServices.clear();
changedServices.clear();