[cpp-sp] branch master updated: SSPCPP-731 - orphaned DiscoveryFeed cache files accumulate

Scott Cantor cantor.2 at osu.edu
Tue Apr 3 13:02:54 EDT 2018


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch master
in repository cpp-sp.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=d2e6d7126e27e3e42153d228cddd523e2c2d331b

The following commit(s) were added to refs/heads/master by this push:
       new  d2e6d71   SSPCPP-731 - orphaned DiscoveryFeed cache files accumulate
d2e6d71 is described below

commit d2e6d7126e27e3e42153d228cddd523e2c2d331b
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Apr 3 13:01:54 2018 -0400

    SSPCPP-731 - orphaned DiscoveryFeed cache files accumulate
    
    https://issues.shibboleth.net/jira/browse/SSPCPP-731
    
    Fix regressions caused by fix to SSPCPP-669.
---
 shibsp/handler/impl/DiscoveryFeed.cpp | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/shibsp/handler/impl/DiscoveryFeed.cpp b/shibsp/handler/impl/DiscoveryFeed.cpp
index 739d60d..0f60ec1 100644
--- a/shibsp/handler/impl/DiscoveryFeed.cpp
+++ b/shibsp/handler/impl/DiscoveryFeed.cpp
@@ -88,10 +88,11 @@ namespace shibsp {
         bool m_cacheToClient;
 #ifndef SHIBSP_LITE
         // Application-specific queues of feed files, linked to the last time of "access".
+        // The key to the map is the application's "hash" code, not the ID itself.
         // Each filename is also a cache tag.
         typedef queue< pair<string, time_t> > feedqueue_t;
         mutable map<string,feedqueue_t> m_feedQueues;
-        scoped_ptr<Mutex> m_feedLock;
+        auto_ptr<Mutex> m_feedLock;
 #endif
     };
 
@@ -134,13 +135,12 @@ DiscoveryFeed::DiscoveryFeed(const DOMElement* e, const char* appId)
 DiscoveryFeed::~DiscoveryFeed()
 {
 #ifndef SHIBSP_LITE
-    if (m_feedLock) {
+    if (m_feedLock.get()) {
         // Remove any files unused for more than a couple of minutes.
-        // Anything left will be orphaned, but that shouldn't happen too often.
         time_t now = time(nullptr);
         for (map<string, feedqueue_t>::iterator i = m_feedQueues.begin(); i != m_feedQueues.end(); ++i) {
-            while (!i->second.empty() && now - i->second.front().second > 120) {
-                string fname = m_dir + '/' + i->second.front().first + ".json";
+            while (!i->second.empty() && now - i->second.front().second > 60) {
+                string fname = m_dir + '/' + i->first + '_' + i->second.front().first + ".json";
                 remove(fname.c_str());
                 i->second.pop();
             }
@@ -292,9 +292,9 @@ void DiscoveryFeed::feedToFile(const Application& application, string& cacheTag)
     Lock lock(m_feedLock);
     time_t now = time(nullptr);
 
-    // Clean up any old files.
-    feedqueue_t q = m_feedQueues[application.getId()];
-    while (q.size() > 1 && (now - q.front().second > 120)) {
+    // Clean up as many old files as it's safe to do.
+    feedqueue_t& q = m_feedQueues[application.getHash()];
+    while (q.size() > 1 && (now - q.front().second > 60)) {
         string fname = m_dir + '/' + application.getHash() + '_' + q.front().first + ".json";
         remove(fname.c_str());
         q.pop();

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list