X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltooling%2FXMLToolingConfig.cpp;h=4a686fe7de8dd57bfb79fce935ef1995905baa8f;hb=085daff2d0c1d078f006f23808b4092130110eb9;hp=55bcfd59cb356254f863f9c596a2406a65850dc7;hpb=f1c188c00803aaf973f9f49baa581e7422bb4d18;p=shibboleth%2Fcpp-xmltooling.git diff --git a/xmltooling/XMLToolingConfig.cpp b/xmltooling/XMLToolingConfig.cpp index 55bcfd5..4a686fe 100644 --- a/xmltooling/XMLToolingConfig.cpp +++ b/xmltooling/XMLToolingConfig.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2006 Internet2 + * Copyright 2001-2007 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ #include "impl/UnknownElement.h" #include "security/TrustEngine.h" #include "security/OpenSSLCryptoX509CRL.h" -#include "signature/CredentialResolver.h" +#include "security/CredentialResolver.h" #include "soap/SOAP.h" #include "soap/SOAPTransport.h" #include "util/NDC.h" @@ -42,6 +42,7 @@ #endif #include +#include #include #include #include @@ -75,7 +76,23 @@ DECL_XMLTOOLING_EXCEPTION_FACTORY(IOException,xmltooling); #endif namespace xmltooling { - XMLToolingInternalConfig g_config; + static XMLToolingInternalConfig g_config; + static vector g_openssl_locks; + + extern "C" void openssl_locking_callback(int mode,int n,const char *file,int line) + { + if (mode & CRYPTO_LOCK) + g_openssl_locks[n]->lock(); + else + g_openssl_locks[n]->unlock(); + } + + #ifndef WIN32 + extern "C" unsigned long openssl_thread_id(void) + { + return (unsigned long)(pthread_self()); + } + #endif } XMLToolingConfig& XMLToolingConfig::getConfig() @@ -168,6 +185,12 @@ bool XMLToolingInternalConfig::init() try { log.debug("library initialization started"); + if (curl_global_init(CURL_GLOBAL_ALL)) { + log.fatal("failed to initialize libcurl, OpenSSL, or Winsock"); + return false; + } + log.debug("libcurl %s initialization complete", LIBCURL_VERSION); + xercesc::XMLPlatformUtils::Initialize(); log.debug("Xerces initialization complete"); @@ -232,15 +255,28 @@ bool XMLToolingInternalConfig::init() } catch (const xercesc::XMLException&) { log.fatal("caught exception while initializing Xerces"); + curl_global_cleanup(); return false; } + // Set up OpenSSL locking. + for (int i=0; i()); + g_openssl_locks.clear(); + SchemaValidators.destroyValidators(); XMLObjectBuilder::destroyBuilders(); XMLToolingException::deregisterFactories(); @@ -293,6 +329,8 @@ void XMLToolingInternalConfig::term() m_lock=NULL; xercesc::XMLPlatformUtils::Terminate(); + curl_global_cleanup(); + #ifdef _DEBUG xmltooling::NDC ndc("term"); #endif