diff --git a/include/rtRemoteObjectCache.h b/include/rtRemoteObjectCache.h index 07b747f..82e34a0 100644 --- a/include/rtRemoteObjectCache.h +++ b/include/rtRemoteObjectCache.h @@ -42,7 +42,7 @@ class rtRemoteObjectCache rtError touch(std::string const& id, std::chrono::steady_clock::time_point now); rtError erase(std::string const& id); rtError markUnevictable(std::string const& id, bool state); - rtError removeUnused(); + rtError removeUnused(bool expireAll = false); rtError clear(); private: diff --git a/src/rtRemoteObjectCache.cpp b/src/rtRemoteObjectCache.cpp index 3ca297d..ab1031a 100644 --- a/src/rtRemoteObjectCache.cpp +++ b/src/rtRemoteObjectCache.cpp @@ -197,7 +197,7 @@ rtRemoteObjectCache::erase(std::string const& id) } rtError -rtRemoteObjectCache::removeUnused() +rtRemoteObjectCache::removeUnused(bool expireAll) { auto now = std::chrono::steady_clock::now(); @@ -208,7 +208,7 @@ rtRemoteObjectCache::removeUnused() // std::chrono::duration_cast(now - itr->second.LastUsed).count(), // itr->second.MaxIdleTime.count(), itr->second.Unevictable); #if 0 - if (!itr->second.Unevictable && itr->second.isActive(now)) + if (!itr->second.Unevictable && (expireAll || itr->second.isActive(now))) { rtLogInfo("not removing:%s, should remove, but it's active", itr->first.c_str()); diff --git a/src/rtRemoteServer.cpp b/src/rtRemoteServer.cpp index 632b3fa..c0aaf1b 100644 --- a/src/rtRemoteServer.cpp +++ b/src/rtRemoteServer.cpp @@ -443,6 +443,8 @@ rtRemoteServer::onClientStateChanged(std::shared_ptr const& clie } } + m_env->ObjectCache->removeUnused(true); + return e; } diff --git a/src/rtRemoteStreamSelector.cpp b/src/rtRemoteStreamSelector.cpp index 0eac6f6..1c0d53b 100644 --- a/src/rtRemoteStreamSelector.cpp +++ b/src/rtRemoteStreamSelector.cpp @@ -71,7 +71,7 @@ rtRemoteStreamSelector::registerStream(std::shared_ptr const& s) rtError rtRemoteStreamSelector::shutdown() { - char buff[] = { "shudown" }; + char buff[] = { "shutdown" }; { std::unique_lock lock(m_mutex);