[shibboleth-sp2] 05/29: https://issues.shibboleth.net/jira/browse/SSPCPP-357

Ferenc Wágner wferi-guest at moszumanska.debian.org
Tue Jan 26 21:30:25 UTC 2016


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

wferi-guest pushed a commit to annotated tag 2.4.3
in repository shibboleth-sp2.

commit c1e9429ab80e42118f37fec113e57d1e064fe77a
Author: Scott Cantor <cantor.2 at osu.edu>
Date:   Mon Jun 6 19:19:39 2011 +0000

    https://issues.shibboleth.net/jira/browse/SSPCPP-357
---
 shibsp/SPConfig.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 69 insertions(+), 7 deletions(-)

diff --git a/shibsp/SPConfig.cpp b/shibsp/SPConfig.cpp
index 097704c..9d19d0c 100644
--- a/shibsp/SPConfig.cpp
+++ b/shibsp/SPConfig.cpp
@@ -96,7 +96,21 @@ DECL_XMLTOOLING_EXCEPTION_FACTORY(MetadataException,opensaml::saml2md);
 #endif
 
 namespace shibsp {
-   SPConfig g_config;
+    class SHIBSP_DLLLOCAL SPInternalConfig : public SPConfig
+    {
+    public:
+        SPInternalConfig();
+        ~SPInternalConfig();
+
+        bool init(const char* catalog_path=nullptr, const char* inst_prefix=nullptr);
+        void term();
+
+    private:
+        int m_initCount;
+        Mutex* m_lock;
+    };
+    
+    SPInternalConfig g_config;
 }
 
 SPConfig& SPConfig::getConfig()
@@ -156,9 +170,6 @@ const MessageDecoder::ArtifactResolver* SPConfig::getArtifactResolver() const
 
 bool SPConfig::init(const char* catalog_path, const char* inst_prefix)
 {
-#ifdef _DEBUG
-    NDC ndc("init");
-#endif
     if (!inst_prefix)
         inst_prefix = getenv("SHIBSP_PREFIX");
     if (!inst_prefix)
@@ -311,9 +322,6 @@ bool SPConfig::init(const char* catalog_path, const char* inst_prefix)
 
 void SPConfig::term()
 {
-#ifdef _DEBUG
-    NDC ndc("term");
-#endif
     Category& log=Category::getInstance(SHIBSP_LOGCAT".Config");
     log.info("%s library shutting down", PACKAGE_STRING);
 
@@ -425,6 +433,60 @@ bool SPConfig::instantiate(const char* config, bool rethrow)
     return false;
 }
 
+SPInternalConfig::SPInternalConfig() : m_initCount(0), m_lock(Mutex::create())
+{
+}
+
+SPInternalConfig::~SPInternalConfig()
+{
+    delete m_lock;
+}
+
+bool SPInternalConfig::init(const char* catalog_path, const char* inst_prefix)
+{
+#ifdef _DEBUG
+    xmltooling::NDC ndc("init");
+#endif
+
+    Lock initLock(m_lock);
+
+    if (m_initCount == LONG_MAX) {
+        Category::getInstance(SHIBSP_LOGCAT".Config").crit("library initialized too many times");
+        return false;
+    }
+
+    if (m_initCount >= 1) {
+        ++m_initCount;
+        return true;
+    }
+
+    if (!SPConfig::init(catalog_path, inst_prefix)) {
+        return false;
+    }
+
+    ++m_initCount;
+    return true;
+}
+
+void SPInternalConfig::term()
+{
+#ifdef _DEBUG
+    xmltooling::NDC ndc("term");
+#endif
+    
+    Lock initLock(m_lock);
+    if (m_initCount == 0) {
+        Category::getInstance(SHIBSP_LOGCAT".Config").crit("term without corresponding init");
+        return;
+    }
+    else if (--m_initCount > 0) {
+        return;
+    }
+
+    SPConfig::term();
+}
+
+
 TransactionLog::TransactionLog() : log(logging::Category::getInstance(SHIBSP_TX_LOGCAT)), m_lock(Mutex::create())
 {
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-shibboleth/shibboleth-sp2.git



More information about the Pkg-shibboleth-devel mailing list