Skip to content
Snippets Groups Projects
Commit a2589498 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

pupnp: don't block on futures on connectivity change

Change-Id: I4e05d780481c340e288fcbb56898f30fb40bf90c
parent 24bbdc57
Branches
No related tags found
No related merge requests found
......@@ -171,8 +171,8 @@ PUPnP::PUPnP()
}
lk.lock();
// Move back failed items to end of list
dwnldlXmlList_.splice(dwnldlXmlList_.end(), xmlList);
// Move back timed-out items to list
dwnldlXmlList_.splice(dwnldlXmlList_.begin(), xmlList);
// Handle successful downloads
for (auto& item : finished) {
auto result = item.get();
......@@ -181,6 +181,13 @@ PUPnP::PUPnP()
}
}
}
for (auto it = cancelXmlList_.begin(); it != cancelXmlList_.end();) {
if (it->wait_for(std::chrono::seconds(0)) == std::future_status::ready) {
it = cancelXmlList_.erase(it);
} else {
++it;
}
}
}
}
......@@ -201,6 +208,7 @@ PUPnP::~PUPnP()
validIgdList_.clear();
cpDeviceList_.clear();
dwnldlXmlList_.clear();
cancelXmlList_.clear();
}
// Notify thread to terminate. UpnpFinish function will get called.
......@@ -217,7 +225,7 @@ PUPnP::clearIgds()
std::lock_guard<std::mutex> lk(validIgdMutex_);
// Clear all internal lists.
dwnldlXmlList_.clear();
cancelXmlList_.splice(cancelXmlList_.end(), dwnldlXmlList_);
validIgdList_.clear();
cpDeviceList_.clear();
}
......
......@@ -147,7 +147,8 @@ private:
std::map<std::string, std::shared_ptr<IGD>> validIgdList_; // Map of valid IGDs with their UDN (universal Id).
std::set<std::string> cpDeviceList_; // Control point device list containing the device ID and device subscription event url.
std::list<std::future<pIGDInfo>> dwnldlXmlList_; // List of shared_futures for blocking xml download function calls.
std::list<std::future<pIGDInfo>> dwnldlXmlList_; // List of futures for blocking xml download function calls.
std::list<std::future<pIGDInfo>> cancelXmlList_; // List of abandoned documents
std::mutex ctrlptMutex_; // Mutex for client handle protection.
UpnpClient_Handle ctrlptHandle_ {-1}; // Control point handle.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment