Hello everyone, Good morning/afternoon/evening !

Win32, Windows XP Professional.
Openssl0.9.8k  compiled with multithreading support.

I am using a blocking BIO to read and write to an SSL socket using two
threads (because it is in blocking mode).

There is the Reading thread:

while (true)
     BIO_read( m_pBio, pBuffer, i_iLength );

and concurrently, the writing thread that do something like this:

     BIO_write(  m_pBio,  i_rStream.operator unsigned char *(),
i_rStream.GetLength()  );

The SSL_ctx and SSL_session are created from within the Writing thread and
to stop the connection, the writing thread do:

     BIO_reset()

and the Reading thread stops by getting an invalid return value from the
BIO_read function.

This is all very basic, and it is working but I am aware of the "OpenSSL
multithreading (or not so) things" and I would like to know if this basic
stuff needs some form of synchronization (using THREAD_setup() and
THREAD_cleanup()).  At the same time if I use some form of synchronization
with blocking BIO how can I be free to use BIO_write and send info async if
the Reading thread is blocked in BIO_read and holding the mutex ?  I guess
that  SSL wisely will use the functions callbacks to access the internal
structures thread-safely, but isn't there any possible way to end up in a
deadlock ?

Thank you a lot for your answers !!!!!
R.

Reply via email to