diff --git a/src/lib/upnp/Discovery.cxx b/src/lib/upnp/Discovery.cxx index 039f3a905..9a4b52712 100644 --- a/src/lib/upnp/Discovery.cxx +++ b/src/lib/upnp/Discovery.cxx @@ -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 protect(parent.mutex); parent.downloaders.push_back(*this); } void UPnPDeviceDirectory::Downloader::Destroy() noexcept { + const std::lock_guard 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 protect(mutex); downloaders.clear_and_dispose(DeleteDisposer()); }); } diff --git a/src/lib/upnp/Discovery.hxx b/src/lib/upnp/Discovery.hxx index 623b5d8dc..0750caf47 100644 --- a/src/lib/upnp/Discovery.hxx +++ b/src/lib/upnp/Discovery.hxx @@ -137,9 +137,15 @@ class UPnPDeviceDirectory final : UpnpCallback { Mutex mutex; + /** + * Protected by #mutex. + */ boost::intrusive::list> downloaders; + /** + * Protected by #mutex. + */ std::list directories; /**