Hi, On Thu, Nov 5, 2009 at 4:07 PM, faturita <rram...@gmail.com> wrote: > 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 ?
This is not a direct answer to your question. I'm writting a multithreaded server with non-blocking file descriptors with a kind of producer-consumer point of view. I will be pleased if you feed me with some data about that "issue" on multithreading. How I implement this "server"? well, it's on development but I use mutexes between the SSL_read() function and the SSL_get_error() function, as both uses same resource. The "consumer" (sender) will wait for a signal from the "producer" (reader) and will block the shared buffer queue. This is, the "producer" gains exclusive access to the ssl structure of the client for SSL_read() and SSL_get_error() checking the SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE, when he fetches some data, he then gain exclusive access to the buffer queue, puts data on it, singals the "consumer" and goes on to another read. The "consumer" when signaled, obtains information on the buffer and lock the ssl structure of the client he wants to send. This is the main idea that I have implemented and I'm testing out. Basically, the "consumer" is something like this: http://pastebin.ca/1658628 The code is only with a buffer and not with a queue. I'm thinking on using a queue more ahead. Please, if you have some information about threading issues I'll be pleased to read it. Thanks, -- If you want freedom, compile the source. Get gentoo. Sebastián Treu http://labombiya.com.ar ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org