diff options
author | Max Kellermann <max@musicpd.org> | 2018-01-02 14:55:57 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-01-02 14:55:57 +0100 |
commit | 3f4f7b0a53c00df5768f07fef5e444b60ad1a217 (patch) | |
tree | 54b4e2e3a31351bb5eeb40af85c4d60e32bb7616 | |
parent | 0a4b866d8a191949a2b85a121418457d713342cf (diff) |
lib/upnp/Discovery: protect "downloaders" accesses with mutex
-rw-r--r-- | src/lib/upnp/Discovery.cxx | 3 | ||||
-rw-r--r-- | src/lib/upnp/Discovery.hxx | 6 |
2 files changed, 9 insertions, 0 deletions
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<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()); }); } 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<Downloader, boost::intrusive::constant_time_size<false>> downloaders; + /** + * Protected by #mutex. + */ std::list<ContentDirectoryDescriptor> directories; /** |