lib/upnp/Discovery: remove locking from ExpireDevices()
This commit is contained in:
@@ -212,7 +212,6 @@ UPnPDeviceDirectory::Invoke(Upnp_EventType et, void *evp)
|
|||||||
bool
|
bool
|
||||||
UPnPDeviceDirectory::ExpireDevices(Error &error)
|
UPnPDeviceDirectory::ExpireDevices(Error &error)
|
||||||
{
|
{
|
||||||
const ScopeLock protect(mutex);
|
|
||||||
const unsigned now = MonotonicClockS();
|
const unsigned now = MonotonicClockS();
|
||||||
bool didsomething = false;
|
bool didsomething = false;
|
||||||
|
|
||||||
@@ -291,12 +290,11 @@ bool
|
|||||||
UPnPDeviceDirectory::GetDirectories(std::vector<ContentDirectoryService> &out,
|
UPnPDeviceDirectory::GetDirectories(std::vector<ContentDirectoryService> &out,
|
||||||
Error &error)
|
Error &error)
|
||||||
{
|
{
|
||||||
// Has locking, do it before our own lock
|
const ScopeLock protect(mutex);
|
||||||
|
|
||||||
if (!ExpireDevices(error))
|
if (!ExpireDevices(error))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const ScopeLock protect(mutex);
|
|
||||||
|
|
||||||
for (auto dit = directories.begin();
|
for (auto dit = directories.begin();
|
||||||
dit != directories.end(); dit++) {
|
dit != directories.end(); dit++) {
|
||||||
for (const auto &service : dit->device.services) {
|
for (const auto &service : dit->device.services) {
|
||||||
@@ -314,12 +312,11 @@ UPnPDeviceDirectory::GetServer(const char *friendly_name,
|
|||||||
ContentDirectoryService &server,
|
ContentDirectoryService &server,
|
||||||
Error &error)
|
Error &error)
|
||||||
{
|
{
|
||||||
// Has locking, do it before our own lock
|
const ScopeLock protect(mutex);
|
||||||
|
|
||||||
if (!ExpireDevices(error))
|
if (!ExpireDevices(error))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const ScopeLock protect(mutex);
|
|
||||||
|
|
||||||
for (const auto &i : directories) {
|
for (const auto &i : directories) {
|
||||||
const auto &device = i.device;
|
const auto &device = i.device;
|
||||||
|
|
||||||
|
@@ -138,6 +138,8 @@ private:
|
|||||||
* Look at the devices and get rid of those which have not
|
* Look at the devices and get rid of those which have not
|
||||||
* been seen for too long. We do this when listing the top
|
* been seen for too long. We do this when listing the top
|
||||||
* directory.
|
* directory.
|
||||||
|
*
|
||||||
|
* Caller must lock #mutex.
|
||||||
*/
|
*/
|
||||||
bool ExpireDevices(Error &error);
|
bool ExpireDevices(Error &error);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user