summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-04-24 16:58:52 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-04-24 16:58:52 (GMT)
commitd3ade7a21cf2cc5e394eccca302e20360052a164 (patch)
tree127f1a3c8965370893fdc786b36096dd0b55879b /Swiften/LinkLocal/LinkLocalServiceBrowser.cpp
parentc6f259526edd486961b798be2537f89f73b1cb81 (diff)
downloadswift-contrib-d3ade7a21cf2cc5e394eccca302e20360052a164.zip
swift-contrib-d3ade7a21cf2cc5e394eccca302e20360052a164.tar.bz2
Don't lookup duplicate discovered link-local services.
This fixes a segfault due to the old query being deleted when a duplicate query is started.
Diffstat (limited to 'Swiften/LinkLocal/LinkLocalServiceBrowser.cpp')
-rw-r--r--Swiften/LinkLocal/LinkLocalServiceBrowser.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp b/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp
index f865807..efd56e3 100644
--- a/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp
+++ b/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp
@@ -95,14 +95,16 @@ void LinkLocalServiceBrowser::handleServiceAdded(const DNSSDServiceID& service)
if (selfService && service == *selfService) {
return;
}
- boost::shared_ptr<DNSSDResolveServiceQuery> resolveQuery = querier->createResolveServiceQuery(service);
- resolveQuery->onServiceResolved.connect(
- boost::bind(&LinkLocalServiceBrowser::handleServiceResolved, this, service, _1));
- std::pair<ResolveQueryMap::iterator, bool> r = resolveQueries.insert(std::make_pair(service, resolveQuery));
- if (!r.second) {
+
+ std::pair<ResolveQueryMap::iterator, bool> r = resolveQueries.insert(std::make_pair(service, boost::shared_ptr<DNSSDResolveServiceQuery>()));
+ if (r.second) {
+ // There was no existing query yet. Start a new query.
+ boost::shared_ptr<DNSSDResolveServiceQuery> resolveQuery = querier->createResolveServiceQuery(service);
+ resolveQuery->onServiceResolved.connect(
+ boost::bind(&LinkLocalServiceBrowser::handleServiceResolved, this, service, _1));
r.first->second = resolveQuery;
+ resolveQuery->start();
}
- resolveQuery->start();
}
void LinkLocalServiceBrowser::handleServiceRemoved(const DNSSDServiceID& service) {