diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-04-24 16:58:52 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-04-24 16:58:52 (GMT) |
commit | d3ade7a21cf2cc5e394eccca302e20360052a164 (patch) | |
tree | 127f1a3c8965370893fdc786b36096dd0b55879b /Swiften/LinkLocal/LinkLocalServiceBrowser.cpp | |
parent | c6f259526edd486961b798be2537f89f73b1cb81 (diff) | |
download | swift-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.cpp | 14 |
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) { |