> So, at first, I made two simple wrapper functions to replace plain > read/write functions. > > ------ snip ------ > int read_ssl( .. ) { > pthread_mutex_lock( &rw_lock ) ; > SSL_read( ... ) ; > pthread_mutex_unlock( &rw_lock ) ; > } > > int write_ssl( .. ) { > pthread_mutex_lock( rw_lock ) ; > SSL_write( ... ) ; > pthread_mutex_unlock( rw_lock ) ; > } > ------ snip ------ > > Of course, it did not work. The mutex was locked during waiting > messages at > SSL_read, could not send any messages.
You really only have two choices: 1) Use non-blocking I/O. You can move the I/O to a service thread if you like, so 'SSL_write' becomes 'push a message on the send queue and alert the service thread' and 'SSL_read' becomes 'block on the receive queue'. 2) Restructure your design so that you do all the writing you need to do before you call read again. (This may or may not be possible depending upon the protocol you are implementing. It is possible for a pure query/response protocol but not possible if the protocol is fundamentally asynchronous.) DS ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]