[PATCH] omniorb: initialize openssl only if not yet done
Teemu Torma <[email protected]> Fri, 26 Oct 2007 00:17:47 +0200
| Newsgroups | gmane.comp.corba.omniorb.devel |
|---|---|
| Message-ID | <[email protected]> |
--Boundary-00=_MYRIHCqnSqANk9T
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
The following patch initializes openssl only if it has not been done
before. We have multiple independent needs for openssl within
application and have to avoid useless multiple initializations.
Teemu
--Boundary-00=_MYRIHCqnSqANk9T
Content-Type: text/x-diff; charset="us-ascii"; name="omniorb-ssl-init.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="omniorb-ssl-init.patch"
diff --git a/include/omniORB4/sslContext.h b/include/omniORB4/sslContext.h
--- a/include/omniORB4/sslContext.h
+++ b/include/omniORB4/sslContext.h
@@ -156,6 +156,7 @@ class sslContext {
const char* pd_password;
SSL_CTX* pd_ctx;
omni_tracedmutex* pd_locks;
+ bool pd_ssl_owner;
};
#undef _core_attr
diff --git a/src/lib/omniORB/orbcore/ssl/sslContext.cc b/src/lib/omniORB/orbcore/ssl/sslContext.cc
--- a/src/lib/omniORB/orbcore/ssl/sslContext.cc
+++ b/src/lib/omniORB/orbcore/ssl/sslContext.cc
@@ -121,12 +121,13 @@ sslContext::sslContext(const char* cafil
const char* keyfile,
const char* password) :
pd_cafile(cafile), pd_keyfile(keyfile), pd_password(password), pd_ctx(0),
- pd_locks(0) {}
+ pd_locks(0), pd_ssl_owner(false) {}
/////////////////////////////////////////////////////////////////////////
sslContext::sslContext() :
- pd_cafile(0), pd_keyfile(0), pd_password(0), pd_ctx(0), pd_locks(0) {
+ pd_cafile(0), pd_keyfile(0), pd_password(0), pd_ctx(0),
+ pd_locks(0), pd_ssl_owner(false) {
}
/////////////////////////////////////////////////////////////////////////
@@ -135,9 +136,14 @@ sslContext::internal_initialise() {
if (pd_ctx) return;
- SSL_library_init();
- set_cipher();
- SSL_load_error_strings();
+ // Assume we own the ssl if no locking callback yet.
+ pd_ssl_owner = CRYPTO_get_locking_callback() == 0;
+
+ if (pd_ssl_owner) {
+ SSL_library_init();
+ set_cipher();
+ SSL_load_error_strings();
+ }
pd_ctx = SSL_CTX_new(set_method());
if (!pd_ctx) {
@@ -154,7 +160,8 @@ sslContext::internal_initialise() {
set_ephemeralRSA();
// Allow the user to overwrite the SSL verification types.
SSL_CTX_set_verify(pd_ctx,set_verify_mode(),NULL);
- thread_setup();
+ if (pd_ssl_owner)
+ thread_setup();
}
/////////////////////////////////////////////////////////////////////////
@@ -162,7 +169,8 @@ sslContext::~sslContext() {
if (pd_ctx) {
SSL_CTX_free(pd_ctx);
}
- thread_cleanup();
+ if (pd_ssl_owner)
+ thread_cleanup();
}
/////////////////////////////////////////////////////////////////////////
--Boundary-00=_MYRIHCqnSqANk9T
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
omniORB-dev mailing list
[email protected]
http://www.omniorb-support.com/mailman/listinfo/omniorb-dev
--Boundary-00=_MYRIHCqnSqANk9T--