Fixed BIO_METHOD initialization for thread safety.
This commit is contained in:
parent
845b9ebf81
commit
64f6f5c594
@ -45,6 +45,21 @@ namespace net {
|
|||||||
namespace tls {
|
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
|
// static
|
||||||
ref <TLSSocket> TLSSocket::wrap(ref <TLSSession> session, ref <socket> sok)
|
ref <TLSSocket> TLSSocket::wrap(ref <TLSSession> session, ref <socket> sok)
|
||||||
{
|
{
|
||||||
@ -82,20 +97,7 @@ void TLSSocket_OpenSSL::createSSLHandle()
|
|||||||
{
|
{
|
||||||
if (m_wrapped->isConnected())
|
if (m_wrapped->isConnected())
|
||||||
{
|
{
|
||||||
static BIO_METHOD customBIOMethod;
|
BIO* sockBio = BIO_new(&sm_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);
|
|
||||||
sockBio->ptr = this;
|
sockBio->ptr = this;
|
||||||
|
|
||||||
m_ssl = SSL_new(m_session->getContext());
|
m_ssl = SSL_new(m_session->getContext());
|
||||||
|
@ -85,6 +85,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
static BIO_METHOD sm_customBIOMethod;
|
||||||
|
|
||||||
static int bio_write(BIO* bio, const char* buf, int len);
|
static int bio_write(BIO* bio, const char* buf, int len);
|
||||||
static int bio_read(BIO* bio, char* buf, int len);
|
static int bio_read(BIO* bio, char* buf, int len);
|
||||||
static int bio_puts(BIO* bio, const char* str);
|
static int bio_puts(BIO* bio, const char* str);
|
||||||
|
Loading…
Reference in New Issue
Block a user