aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/tls/openssl/TLSSocket_OpenSSL.cpp
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2013-05-12 14:09:17 +0000
committerVincent Richard <[email protected]>2013-05-12 14:09:17 +0000
commit64f6f5c594cd52b6e9e0418b4cfb5878fa297779 (patch)
tree59e1ffe05e067bbc3faa342b2cc361a14eedd3bb /src/net/tls/openssl/TLSSocket_OpenSSL.cpp
parentBetter random seed. (diff)
downloadvmime-64f6f5c594cd52b6e9e0418b4cfb5878fa297779.tar.gz
vmime-64f6f5c594cd52b6e9e0418b4cfb5878fa297779.zip
Fixed BIO_METHOD initialization for thread safety.
Diffstat (limited to 'src/net/tls/openssl/TLSSocket_OpenSSL.cpp')
-rw-r--r--src/net/tls/openssl/TLSSocket_OpenSSL.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/net/tls/openssl/TLSSocket_OpenSSL.cpp b/src/net/tls/openssl/TLSSocket_OpenSSL.cpp
index e62312d6..b8ac18e9 100644
--- a/src/net/tls/openssl/TLSSocket_OpenSSL.cpp
+++ b/src/net/tls/openssl/TLSSocket_OpenSSL.cpp
@@ -46,6 +46,21 @@ namespace tls {
// static
+BIO_METHOD TLSSocket_OpenSSL::sm_customBIOMethod =
+{
+ 100 | BIO_TYPE_SOURCE_SINK,
+ "vmime::socket glue",
+ TLSSocket_OpenSSL::bio_write,
+ TLSSocket_OpenSSL::bio_read,
+ TLSSocket_OpenSSL::bio_puts,
+ TLSSocket_OpenSSL::bio_gets,
+ TLSSocket_OpenSSL::bio_ctrl,
+ TLSSocket_OpenSSL::bio_create,
+ TLSSocket_OpenSSL::bio_destroy
+};
+
+
+// static
ref <TLSSocket> TLSSocket::wrap(ref <TLSSession> session, ref <socket> sok)
{
return vmime::create <TLSSocket_OpenSSL>
@@ -82,20 +97,7 @@ void TLSSocket_OpenSSL::createSSLHandle()
{
if (m_wrapped->isConnected())
{
- static BIO_METHOD customBIOMethod;
- ::memset(&customBIOMethod, 0, sizeof(customBIOMethod));
-
- customBIOMethod.type = 100 | BIO_TYPE_SOURCE_SINK;
- customBIOMethod.name = "vmime::socket glue";
- customBIOMethod.bwrite = bio_write;
- customBIOMethod.bread = bio_read;
- customBIOMethod.bputs = bio_puts;
- customBIOMethod.bgets = bio_gets;
- customBIOMethod.ctrl = bio_ctrl;
- customBIOMethod.create = bio_create;
- customBIOMethod.destroy = bio_destroy;
-
- BIO* sockBio = BIO_new(&customBIOMethod);
+ BIO* sockBio = BIO_new(&sm_customBIOMethod);
sockBio->ptr = this;
m_ssl = SSL_new(m_session->getContext());