aboutsummaryrefslogtreecommitdiffstats
path: root/src/db/upnp/Discovery.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/upnp/Discovery.cxx')
-rw-r--r--src/db/upnp/Discovery.cxx22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/db/upnp/Discovery.cxx b/src/db/upnp/Discovery.cxx
index f47741240..371f87244 100644
--- a/src/db/upnp/Discovery.cxx
+++ b/src/db/upnp/Discovery.cxx
@@ -262,14 +262,24 @@ UPnPDeviceDirectory::getServer(const char *friendlyName,
ContentDirectoryService &server,
Error &error)
{
- std::vector<ContentDirectoryService> ds;
- if (!getDirServices(ds, error))
+ // Has locking, do it before our own lock
+ if (!expireDevices(error))
return false;
- for (const auto &i : ds) {
- if (strcmp(friendlyName, i.getFriendlyName()) == 0) {
- server = i;
- return true;
+ const ScopeLock protect(mutex);
+
+ for (const auto &i : directories) {
+ const auto &device = i.second.device;
+
+ if (device.friendlyName != friendlyName)
+ continue;
+
+ for (const auto &service : device.services) {
+ if (isCDService(service.serviceType.c_str())) {
+ server = ContentDirectoryService(device,
+ service);
+ return true;
+ }
}
}