[cpp-opensaml] branch master updated: Logging and doc nits.

Scott Cantor cantor.2 at osu.edu
Thu May 10 20:11:52 EDT 2018


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

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

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

The following commit(s) were added to refs/heads/master by this push:
       new  44dabcd   Logging and doc nits.
44dabcd is described below

commit 44dabcd48a62d295428bffe70d92a75f3a181a81
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu May 10 20:11:40 2018 -0400

    Logging and doc nits.
---
 .../metadata/AbstractDynamicMetadataProvider.h     |  8 ++++----
 .../impl/AbstractDynamicMetadataProvider.cpp       | 24 ++++++++--------------
 .../metadata/impl/LocalDynamicMetadataProvider.cpp | 13 ++++++------
 3 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/saml/saml2/metadata/AbstractDynamicMetadataProvider.h b/saml/saml2/metadata/AbstractDynamicMetadataProvider.h
index 30b0c86..66d043f 100644
--- a/saml/saml2/metadata/AbstractDynamicMetadataProvider.h
+++ b/saml/saml2/metadata/AbstractDynamicMetadataProvider.h
@@ -48,7 +48,7 @@ namespace opensaml {
             /**
              * Constructor.
              *
-             * @param defaultNegativeCache - if not specified in the element, do we we cache lookup failures?
+             * @param defaultNegativeCache - if not specified in the element, do we cache lookup failures?
              * @param e DOM to supply configuration for provider
              */
             AbstractDynamicMetadataProvider(bool defaultNegativeCache, const xercesc::DOMElement* e=nullptr);
@@ -99,14 +99,14 @@ namespace opensaml {
             time_t m_minCacheDuration, m_maxCacheDuration;
             typedef std::map<xmltooling::xstring,time_t> cachemap_t;
             mutable cachemap_t m_cacheMap;
-            const bool m_negativeCache;
+            bool m_negativeCache;
 
             // Used to manage background maintenance of cache.
             bool m_shutdown;
             long m_cleanupInterval;
             long m_cleanupTimeout;
-            xmltooling::CondWait* m_cleanup_wait;
-            xmltooling::Thread* m_cleanup_thread;
+            boost::scoped_ptr<xmltooling::CondWait> m_cleanup_wait;
+            boost::scoped_ptr<xmltooling::Thread> m_cleanup_thread;
             static void* cleanup_fn(void*);
         };
 
diff --git a/saml/saml2/metadata/impl/AbstractDynamicMetadataProvider.cpp b/saml/saml2/metadata/impl/AbstractDynamicMetadataProvider.cpp
index 0eae4a6..f6a642c 100644
--- a/saml/saml2/metadata/impl/AbstractDynamicMetadataProvider.cpp
+++ b/saml/saml2/metadata/impl/AbstractDynamicMetadataProvider.cpp
@@ -83,8 +83,7 @@ AbstractDynamicMetadataProvider::AbstractDynamicMetadataProvider(bool defaultNeg
         m_negativeCache(XMLHelper::getAttrBool(e, defaultNegativeCache, negativeCache)),
         m_shutdown(false),
         m_cleanupInterval(XMLHelper::getAttrInt(e, 1800, cleanupInterval)),
-        m_cleanupTimeout(XMLHelper::getAttrInt(e, 1800, cleanupTimeout)),
-        m_cleanup_wait(nullptr), m_cleanup_thread(nullptr)
+        m_cleanupTimeout(XMLHelper::getAttrInt(e, 1800, cleanupTimeout))
 {
     if (m_minCacheDuration > m_maxCacheDuration) {
         Category::getInstance(SAML_LOGCAT ".MetadataProvider.Dynamic").error(
@@ -108,8 +107,8 @@ AbstractDynamicMetadataProvider::AbstractDynamicMetadataProvider(bool defaultNeg
     if (m_cleanupInterval > 0) {
         if (m_cleanupTimeout < 0)
             m_cleanupTimeout = 0;
-        m_cleanup_wait = CondWait::create();
-        m_cleanup_thread = Thread::create(&cleanup_fn, this);
+        m_cleanup_wait.reset(CondWait::create());
+        m_cleanup_thread.reset(Thread::create(&cleanup_fn, this));
     }
 }
 
@@ -123,10 +122,6 @@ AbstractDynamicMetadataProvider::~AbstractDynamicMetadataProvider()
         m_shutdown = true;
         m_cleanup_wait->signal();
         m_cleanup_thread->join(nullptr);
-        delete m_cleanup_thread;
-        delete m_cleanup_wait;
-        m_cleanup_thread = nullptr;
-        m_cleanup_wait = nullptr;
     }
 }
 
@@ -298,7 +293,7 @@ pair<const EntityDescriptor*,const RoleDescriptor*> AbstractDynamicMetadataProvi
         try {
             SchemaValidators.validate(entity2.get());
         }
-        catch (exception& ex) {
+        catch (const exception& ex) {
             log.error("metadata instance failed manual validation checking: %s", ex.what());
             throw MetadataException("Metadata instance failed manual validation checking.");
         }
@@ -324,15 +319,14 @@ pair<const EntityDescriptor*,const RoleDescriptor*> AbstractDynamicMetadataProvi
         emitChangeEvent(*entity2);
 
         time_t cacheExp = cacheEntity(entity2.get(), true);
-
-        log.info("next refresh of metadata for (%s) no sooner than %u seconds", name.c_str(), cacheExp);
-
         entity2.release();
 
+        log.info("next refresh of metadata for (%s) no sooner than %lu seconds", name.c_str(), cacheExp);
+
         m_lastUpdate = now;
     }
-    catch (exception& e) {
-        log.error("error while resolving entityID (%s): %s", name.c_str(), e.what());
+    catch (const exception& e) {
+        log.error("error while resolving (%s): %s", name.c_str(), e.what());
         if (m_negativeCache) {
             // This will return entries that are beyond their cache period,
             // but not beyond their validity unless that criteria option was set.
@@ -365,7 +359,7 @@ pair<const EntityDescriptor*,const RoleDescriptor*> AbstractDynamicMetadataProvi
     return getEntityDescriptor(criteria);
 }
 
-time_t  AbstractDynamicMetadataProvider::cacheEntity(EntityDescriptor* entity, bool writeLocked) const
+time_t AbstractDynamicMetadataProvider::cacheEntity(EntityDescriptor* entity, bool writeLocked) const
 {
     time_t now = time(nullptr);
     if (!writeLocked) {
diff --git a/saml/saml2/metadata/impl/LocalDynamicMetadataProvider.cpp b/saml/saml2/metadata/impl/LocalDynamicMetadataProvider.cpp
index 016a258..b841f90 100644
--- a/saml/saml2/metadata/impl/LocalDynamicMetadataProvider.cpp
+++ b/saml/saml2/metadata/impl/LocalDynamicMetadataProvider.cpp
@@ -81,8 +81,9 @@ namespace opensaml {
 };
 
 LocalDynamicMetadataProvider::LocalDynamicMetadataProvider(const DOMElement* e)
-    : MetadataProvider(e), AbstractDynamicMetadataProvider(false, e), m_sourceDirectory(XMLHelper::getAttrString(e, nullptr, sourceDirectory)), 
-      m_log(Category::getInstance(SAML_LOGCAT ".MetadataProvider.LocalDynamic"))
+    : MetadataProvider(e), AbstractDynamicMetadataProvider(false, e),
+        m_sourceDirectory(XMLHelper::getAttrString(e, nullptr, sourceDirectory)),
+        m_log(Category::getInstance(SAML_LOGCAT ".MetadataProvider.LocalDynamic"))
 {
     if (m_sourceDirectory.empty())
         throw  MetadataException("LocalDynamicMetadataProvider: sourceDirectory=\"whatever\" must be present");
@@ -107,16 +108,16 @@ EntityDescriptor* LocalDynamicMetadataProvider::resolve(const Criteria& criteria
         from = name = criteria.artifact->getSource();
     }
     name = m_sourceDirectory + name + ".xml";
-    m_log.debug("transformed named from (%s) to (%s)", from.c_str(), name.c_str());
+    m_log.debug("transformed name from (%s) to (%s)", from.c_str(), name.c_str());
 
     ifstream source(name.c_str());
     if (!source) {
-        m_log.debug("file not found");
-        throw IOException("File Not Found");
+        m_log.debug("local metadata file (%s) not found for input (%s)", name.c_str(), from.c_str());
+        throw IOException("Local metadata file not found.");
     }
 
     EntityDescriptor* result = entityFromStream(source);
     if (!result)
-        throw MetadataException("No entity resolved from file");
+        throw MetadataException("No entity resolved from file."); // shouldn't happen
     return result;
 }

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


More information about the commits mailing list