Re: [asio-users] Problem with boost::asio::ssl when using multiple threads
Brought to you by:
chris_kohlhoff
From: Christian H. <ha...@te...> - 2013-02-07 08:32:46
|
Am 05.02.2013, 19:42 Uhr, schrieb Александр Бобров <bob...@gm...>: > You can read here about openssl (the same issue): > > http://stackoverflow.com/questions/14467630/clarifying-openssl-0-9-8l-concurrency-support-can-ssl-instances-be-used-by-mul > > It seems that you run concurrently async_read / async_write on the same > boost::asio::ssl::stream object (full duplex), so SSL_read and SSL_write > can run concurrently. > That Stackoverflow article is quite interesting. It seems that the boost::asio::ssl can't be used in a multithread environment unless you take special care not to async_send and async_receive at the same on the boost::asio::ssl_stream. It took me quite a long time to figure it out. The documentation could be better there. > Strands is only for IO operations completition handlers. async_read and > async_write are composed from other asynchronous operations, and all > intermediate handlers should be invoked using the same method as the > final > handler. > > You should implement your own asio_handler_invoke like it's done in asio > docs: > > http://www.boost.org/doc/libs/1_53_0/doc/html/boost_asio/reference/asio_handler_invoke.html > I don't understand how I could do this properly. Because I have one strand per object how can I set a different handler-invoker-hook for every async-operation? Actually I am thinking of a workaround to protect the OpenSSL-Object by inserting a mutex in boost::asio::ssl::detail::io_op::operator(). I have to test the code more, though. Regards, Christian |