From fab6cbed7554ad83df3d70cf24a94a178fe406ff Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 18 Jan 2014 16:28:12 +0100 Subject: [PATCH] db/upnp/Discovery: eliminate attribute "last_seen" --- src/db/upnp/Discovery.cxx | 2 +- src/db/upnp/Discovery.hxx | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/db/upnp/Discovery.cxx b/src/db/upnp/Discovery.cxx index f07751956..085e5c336 100644 --- a/src/db/upnp/Discovery.cxx +++ b/src/db/upnp/Discovery.cxx @@ -170,7 +170,7 @@ UPnPDeviceDirectory::expireDevices(Error &error) for (auto it = directories.begin(); it != directories.end();) { - if (now - it->second.last_seen > it->second.expires) { + if (now > it->second.expires) { it = directories.erase(it); didsomething = true; } else { diff --git a/src/db/upnp/Discovery.hxx b/src/db/upnp/Discovery.hxx index cda78cff5..a45163e9b 100644 --- a/src/db/upnp/Discovery.hxx +++ b/src/db/upnp/Discovery.hxx @@ -67,16 +67,14 @@ class UPnPDeviceDirectory { /** * The MonotonicClockS() time stamp when this device - * was last seen alive. + * expires. */ - unsigned last_seen; - - unsigned expires; // seconds valid + unsigned expires; ContentDirectoryDescriptor() = default; ContentDirectoryDescriptor(unsigned last, int exp) - :last_seen(last), expires(exp+20) {} + :expires(last + exp + 20) {} bool Parse(const std::string &url, const char *description, Error &_error) {