lib/upnp/Discovery: protect "downloaders" accesses with mutex
This commit is contained in:
parent
0a4b866d8a
commit
3f4f7b0a53
@ -42,12 +42,14 @@ UPnPDeviceDirectory::Downloader::Downloader(UPnPDeviceDirectory &_parent,
|
||||
expires(std::chrono::seconds(UpnpDiscovery_get_Expires(&disco))),
|
||||
request(*parent.curl, url.c_str(), *this)
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(parent.mutex);
|
||||
parent.downloaders.push_back(*this);
|
||||
}
|
||||
|
||||
void
|
||||
UPnPDeviceDirectory::Downloader::Destroy() noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(parent.mutex);
|
||||
parent.downloaders.erase_and_dispose(parent.downloaders.iterator_to(*this),
|
||||
DeleteDisposer());
|
||||
}
|
||||
@ -265,6 +267,7 @@ UPnPDeviceDirectory::UPnPDeviceDirectory(EventLoop &event_loop,
|
||||
UPnPDeviceDirectory::~UPnPDeviceDirectory() noexcept
|
||||
{
|
||||
BlockingCall(GetEventLoop(), [this](){
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
downloaders.clear_and_dispose(DeleteDisposer());
|
||||
});
|
||||
}
|
||||
|
@ -137,9 +137,15 @@ class UPnPDeviceDirectory final : UpnpCallback {
|
||||
|
||||
Mutex mutex;
|
||||
|
||||
/**
|
||||
* Protected by #mutex.
|
||||
*/
|
||||
boost::intrusive::list<Downloader,
|
||||
boost::intrusive::constant_time_size<false>> downloaders;
|
||||
|
||||
/**
|
||||
* Protected by #mutex.
|
||||
*/
|
||||
std::list<ContentDirectoryDescriptor> directories;
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user