[cpp-sp] branch master updated: CPPOST-68 - Add per-entity observability for metadata providers

Scott Cantor cantor.2 at osu.edu
Thu Jan 18 20:27:08 EST 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=144a012c58b16a3ad3cbcb353c87dfea7e4cee42

The following commit(s) were added to refs/heads/master by this push:
       new  144a012   CPPOST-68 - Add per-entity observability for metadata providers
144a012 is described below

commit 144a012c58b16a3ad3cbcb353c87dfea7e4cee42
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Jan 18 20:25:11 2018 -0500

    CPPOST-68 - Add per-entity observability for metadata providers
    
    https://issues.shibboleth.net/jira/browse/CPPOST-68
    
    Redesign attribute tag cache to be entityID-based and default off.
---
 .cproject                                          | 14 +++++---
 .project                                           |  2 ++
 .../resolver/impl/XMLAttributeExtractor.cpp        | 39 ++++++++++++++++------
 3 files changed, 40 insertions(+), 15 deletions(-)

diff --git a/.cproject b/.cproject
index c3c65ff..16ecb22 100644
--- a/.cproject
+++ b/.cproject
@@ -22,26 +22,28 @@
 					<folderInfo id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.1301536861." name="/" resourcePath="">
 						<toolChain id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.1860418070" name="GNU Autotools Toolchain" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolChain">
 							<targetPlatform id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.targetPlatform.540648186" isAbstract="false" name="GNU Autotools Target Platform" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.targetPlatform"/>
-							<builder id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder.863364880" keepEnvironmentInBuildfile="false" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder"/>
+							<builder id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder.863364880" keepEnvironmentInBuildfile="false" name="Autotools Makefile Generator" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder"/>
 							<tool id="org.eclipse.linuxtools.cdt.autotools.core.gnu.toolchain.tool.configure.1463797656" name="configure" superClass="org.eclipse.linuxtools.cdt.autotools.core.gnu.toolchain.tool.configure">
 								<option id="org.eclipse.linuxtools.cdt.autotools.core.option.configure.name.1490081656" name="Name" superClass="org.eclipse.linuxtools.cdt.autotools.core.option.configure.name" value="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.1301536861" valueType="string"/>
 							</tool>
 							<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen.2032266339" name="autogen.sh" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen"/>
 							<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc.1463032246" name="GCC C Compiler" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc">
-								<option id="gnu.c.compiler.option.include.paths.1713868061" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+								<option id="gnu.c.compiler.option.include.paths.1713868061" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
 									<listOptionValue builtIn="false" value=""${workspace_loc:/cpp-log4shib}""/>
 									<listOptionValue builtIn="false" value=""${workspace_loc:/cpp-opensaml}""/>
 									<listOptionValue builtIn="false" value=""${workspace_loc:/cpp-xmltooling}""/>
 									<listOptionValue builtIn="false" value="/opt/local/include"/>
+									<listOptionValue builtIn="false" value=""C:\Users\cantor.2\Shibboleth\boost_1_66_0""/>
 								</option>
 								<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1052808883" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
 							</tool>
 							<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp.2007465323" name="GCC C++ Compiler" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp">
-								<option id="gnu.cpp.compiler.option.include.paths.1885895501" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+								<option id="gnu.cpp.compiler.option.include.paths.1885895501" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
 									<listOptionValue builtIn="false" value=""${workspace_loc:/cpp-log4shib}""/>
 									<listOptionValue builtIn="false" value=""${workspace_loc:/cpp-opensaml}""/>
 									<listOptionValue builtIn="false" value=""${workspace_loc:/cpp-xmltooling}""/>
 									<listOptionValue builtIn="false" value="/opt/local/include"/>
+									<listOptionValue builtIn="false" value=""C:\Users\cantor.2\Shibboleth\boost_1_66_0""/>
 								</option>
 								<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1677006691" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
 							</tool>
@@ -56,7 +58,11 @@
 		<project id="cpp-sp.org.eclipse.linuxtools.cdt.autotools.core.projectType.1899903148" name="GNU Autotools" projectType="org.eclipse.linuxtools.cdt.autotools.core.projectType"/>
 	</storageModule>
 	<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
-	<storageModule moduleId="refreshScope"/>
+	<storageModule moduleId="refreshScope" versionNumber="2">
+		<configuration configurationName="Build (GNU)">
+			<resource resourceType="PROJECT" workspacePath="/cpp-sp"/>
+		</configuration>
+	</storageModule>
 	<storageModule moduleId="scannerConfiguration">
 		<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 		<scannerConfigBuildInfo instanceId="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.1301536861;org.eclipse.linuxtools.cdt.autotools.core.configuration.build.1301536861.;org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp.2007465323;cdt.managedbuild.tool.gnu.cpp.compiler.input.1677006691">
diff --git a/.project b/.project
index 325789d..44e0769 100644
--- a/.project
+++ b/.project
@@ -6,6 +6,8 @@
 		<project>cpp-log4shib</project>
 		<project>cpp-opensaml</project>
 		<project>cpp-xmltooling</project>
+		<project>xerces-trunk</project>
+		<project>xml-security-cpp</project>
 	</projects>
 	<buildSpec>
 		<buildCommand>
diff --git a/shibsp/attribute/resolver/impl/XMLAttributeExtractor.cpp b/shibsp/attribute/resolver/impl/XMLAttributeExtractor.cpp
index 37e77dd..bd4949b 100644
--- a/shibsp/attribute/resolver/impl/XMLAttributeExtractor.cpp
+++ b/shibsp/attribute/resolver/impl/XMLAttributeExtractor.cpp
@@ -102,6 +102,19 @@ namespace shibsp {
             d.clear();
         }
 
+        void onEvent(const ObservableMetadataProvider& metadata, const EntityDescriptor& entity) const {
+            // Destroy attributes we cached from this provider and entity.
+            m_attrLock->wrlock();
+            SharedLock wrapper(m_attrLock, false);
+            decoded_t& d = m_decodedMap[&metadata];
+            decoded_t::iterator i = d.find(entity.getEntityID());
+            if (i != d.end()) {
+                for_each(i->second.begin(), i->second.end(), mem_fun_ref<DDF&, DDF>(&DDF::destroy));
+                d.erase(i);
+            }
+        }
+
+
         void extractAttributes(const Application&, const char*, const char*, const NameIdentifier&, ptr_vector<Attribute>&) const;
         void extractAttributes(const Application&, const char*, const char*, const NameID&, ptr_vector<Attribute>&) const;
         void extractAttributes(const Application&, const GenericRequest*, const char*, const char*, const saml1::Attribute&, ptr_vector<Attribute>&) const;
@@ -135,7 +148,7 @@ namespace shibsp {
 
         // manages caching of decoded Attributes
         scoped_ptr<RWLock> m_attrLock;
-        typedef map< const EntityAttributes*,vector<DDF> > decoded_t;
+        typedef map< xstring,vector<DDF> > decoded_t;
         mutable map<const ObservableMetadataProvider*,decoded_t> m_decodedMap;
     };
 
@@ -208,7 +221,7 @@ XMLExtractorImpl::XMLExtractorImpl(const DOMElement* e, Category& log)
         m_document(nullptr),
         m_policyId(XMLHelper::getAttrString(e, nullptr, metadataPolicyId)),
         m_entityAssertions(true),
-        m_metaAttrCaching(XMLHelper::getAttrBool(e, true, metadataAttributeCaching))
+        m_metaAttrCaching(XMLHelper::getAttrBool(e, false, metadataAttributeCaching))
 {
 #ifdef _DEBUG
     xmltooling::NDC ndc("XMLExtractorImpl");
@@ -581,17 +594,22 @@ void XMLExtractorImpl::extractAttributes(
     ptr_vector<Attribute>& attributes
     ) const
 {
+
+    const XMLCh* cacheID = nullptr;
+    if (observable && m_metaAttrCaching && dynamic_cast<const EntityDescriptor*>(ext.getParent())) {
+        cacheID = dynamic_cast<const EntityDescriptor*>(ext.getParent())->getEntityID();
+    }
+
     const vector<XMLObject*>& exts = ext.getUnknownXMLObjects();
     for (vector<XMLObject*>::const_iterator i = exts.begin(); i != exts.end(); ++i) {
         const EntityAttributes* container = dynamic_cast<const EntityAttributes*>(*i);
         if (!container)
             continue;
 
-        bool useCache = false;
         map<const ObservableMetadataProvider*,decoded_t>::iterator cacheEntry;
 
         // Check for cached result.
-        if (observable && m_metaAttrCaching) {
+        if (cacheID) {
             m_attrLock->rdlock();
             cacheEntry = m_decodedMap.find(observable);
             if (cacheEntry == m_decodedMap.end()) {
@@ -615,12 +633,11 @@ void XMLExtractorImpl::extractAttributes(
                     m_attrLock->rdlock();
                 }
             }
-            useCache = true;
         }
 
-        if (useCache) {
+        if (cacheID) {
             // We're holding the lock, so check the cache.
-            decoded_t::iterator d = cacheEntry->second.find(container);
+            decoded_t::iterator d = cacheEntry->second.find(cacheID);
             if (d != cacheEntry->second.end()) {
                 SharedLock locker(m_attrLock, false);   // pop the lock when we're done
                 for (vector<DDF>::iterator obj = d->second.begin(); obj != d->second.end(); ++obj) {
@@ -634,7 +651,7 @@ void XMLExtractorImpl::extractAttributes(
         }
 
         // Add a guard for the lock if we're caching.
-        SharedLock locker(useCache ? m_attrLock.get() : nullptr, false);
+        SharedLock locker(cacheID ? m_attrLock.get() : nullptr, false);
 
         // Use a holding area to support caching.
         ptr_vector<Attribute> holding;
@@ -811,14 +828,14 @@ void XMLExtractorImpl::extractAttributes(
         }
 
         if (!holding.empty()) {
-            if (useCache) {
+            if (cacheID) {
                 locker.release();   // unguard to upgrade lock
                 m_attrLock->unlock();
                 m_attrLock->wrlock();
                 SharedLock locker2(m_attrLock, false);   // pop the lock when we're done
-                if (cacheEntry->second.count(container) == 0) {
+                if (cacheEntry->second.count(cacheID) == 0) {
                     static void (vector<DDF>::* push_back)(DDF const &) = &vector<DDF>::push_back;
-                    vector<DDF>& marshalled = cacheEntry->second[container];
+                    vector<DDF>& marshalled = cacheEntry->second[cacheID];
                     for_each(
                         holding.begin(), holding.end(),
                         boost::bind(push_back, boost::ref(marshalled), boost::bind(&Attribute::marshall, _1))

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


More information about the commits mailing list