From: cantor Date: Mon, 6 Aug 2007 15:55:58 +0000 (+0000) Subject: Adjust default cache timeout based on cache subclass. X-Git-Tag: 2.4~814 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fsp.git;a=commitdiff_plain;h=5e4c33be9e6ebfee484692c0590a5124434d2a99 Adjust default cache timeout based on cache subclass. Add a default in-proc cache element to config. git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@2389 cb58f699-b61c-0410-a6fe-9272a202ed29 --- diff --git a/configs/shibboleth2.xml.in b/configs/shibboleth2.xml.in index 78ffb03..884d4c0 100644 --- a/configs/shibboleth2.xml.in +++ b/configs/shibboleth2.xml.in @@ -47,6 +47,8 @@ + + diff --git a/shibsp/SessionCache.cpp b/shibsp/SessionCache.cpp index 6f05c85..8ff5c00 100644 --- a/shibsp/SessionCache.cpp +++ b/shibsp/SessionCache.cpp @@ -48,14 +48,14 @@ void SHIBSP_API shibsp::registerSessionCaches() #endif } -SessionCache::SessionCache(const DOMElement* e) : m_cacheTimeout(60*60*8) +SessionCache::SessionCache(const DOMElement* e, unsigned long defaultTimeout) : m_cacheTimeout(defaultTimeout) { if (e) { const XMLCh* tag=e->getAttributeNS(NULL,cacheTimeout); if (tag && *tag) { m_cacheTimeout = XMLString::parseInt(tag); if (!m_cacheTimeout) - m_cacheTimeout=60*60*8; + m_cacheTimeout=defaultTimeout; } } } diff --git a/shibsp/SessionCache.h b/shibsp/SessionCache.h index 91de942..5e22bf1 100644 --- a/shibsp/SessionCache.h +++ b/shibsp/SessionCache.h @@ -183,11 +183,12 @@ namespace shibsp { *
attribute containing maximum lifetime in seconds for unused sessions to remain in cache
* * - * @param e root of DOM tree to configure the cache + * @param e root of DOM tree to configure the cache + * @param defaultTimeout default cacheTimeout setting to use if none specified in DOM */ - SessionCache(const xercesc::DOMElement* e); + SessionCache(const xercesc::DOMElement* e, unsigned long defaultTimeout=3600); - /** maximum lifetime in seconds for unused sessions to be cached */ + /** Maximum lifetime in seconds for unused sessions to be cached. */ unsigned long m_cacheTimeout; public: diff --git a/shibsp/impl/RemotedSessionCache.cpp b/shibsp/impl/RemotedSessionCache.cpp index 48266ff..6f2d8cc 100644 --- a/shibsp/impl/RemotedSessionCache.cpp +++ b/shibsp/impl/RemotedSessionCache.cpp @@ -261,7 +261,7 @@ void RemotedSession::validate(const Application& application, const char* client } RemotedCache::RemotedCache(const DOMElement* e) - : SessionCache(e), m_log(Category::getInstance(SHIBSP_LOGCAT".SessionCache")), m_root(e), m_lock(NULL), shutdown(false) + : SessionCache(e, 900), m_log(Category::getInstance(SHIBSP_LOGCAT".SessionCache")), m_root(e), m_lock(NULL), shutdown(false) { if (!SPConfig::getConfig().getServiceProvider()->getListenerService()) throw ConfigurationException("RemotedCacheService requires a ListenerService, but none available."); diff --git a/shibsp/impl/StorageServiceSessionCache.cpp b/shibsp/impl/StorageServiceSessionCache.cpp index f310a55..ae2135e 100644 --- a/shibsp/impl/StorageServiceSessionCache.cpp +++ b/shibsp/impl/StorageServiceSessionCache.cpp @@ -112,16 +112,16 @@ namespace shibsp { return m_attributes; } const multimap& getIndexedAttributes() const { - if (m_attributeIndex.empty()) { - if (m_attributes.empty()) - unmarshallAttributes(); - for (vector::const_iterator a = m_attributes.begin(); a != m_attributes.end(); ++a) { - const vector& aliases = (*a)->getAliases(); - for (vector::const_iterator alias = aliases.begin(); alias != aliases.end(); ++alias) - m_attributeIndex.insert(make_pair(*alias, *a)); - } - } - return m_attributeIndex; + if (m_attributeIndex.empty()) { + if (m_attributes.empty()) + unmarshallAttributes(); + for (vector::const_iterator a = m_attributes.begin(); a != m_attributes.end(); ++a) { + const vector& aliases = (*a)->getAliases(); + for (vector::const_iterator alias = aliases.begin(); alias != aliases.end(); ++alias) + m_attributeIndex.insert(make_pair(*alias, *a)); + } + } + return m_attributeIndex; } const vector& getAssertionIDs() const { if (m_ids.empty()) { @@ -450,7 +450,7 @@ void StoredSession::addAssertion(Assertion* assertion) } SSCache::SSCache(const DOMElement* e) - : SessionCache(e), m_log(Category::getInstance(SHIBSP_LOGCAT".SessionCache")), m_storage(NULL) + : SessionCache(e, 3600), m_log(Category::getInstance(SHIBSP_LOGCAT".SessionCache")), m_storage(NULL) { SPConfig& conf = SPConfig::getConfig(); const XMLCh* tag = e ? e->getAttributeNS(NULL,_StorageService) : NULL;