Christian Hägele
2013-02-05 09:31:40 UTC
Hello,
I have a problem when using boost::asio::ssl with multiple-threads. My
application runs fine on a lot of servers without any problems when not
using SSL. So I suspect the code is pretty much thread-safe. All
I/O-Operations are guarded by strands.
But when using boost::asio::ssl with OpenSSL I run into occasional
crashes. I think I tracked down the problem to the following fact:
In boost/asio/ssl/detail/io.hpp the function operator() is called by 2
different threads at the same time. One thread is going through a explicit
strand in my user-code for that connection, the other one is the result of
a previous async_write or async_read started from that
io_op::operator()-function. That happens quite a lot. (Remark there is
only 1 connection during testing!)
Because of that boost::asio::ssl::detail::engine::perform is called by 2
different threads concurrently. I am not that familiar with OpenSSL, but I
suppose that this could be problematic.
Do I miss anything in my observation? Does somebody else has
boost::asio::ssl working in a multi threaded environment (meaning multiple
threads and one io_service) without problems? Does anybody has enough
knowledge of OpenSSL to say if that access could be problematic?
Reagrds,
Christian
I have a problem when using boost::asio::ssl with multiple-threads. My
application runs fine on a lot of servers without any problems when not
using SSL. So I suspect the code is pretty much thread-safe. All
I/O-Operations are guarded by strands.
But when using boost::asio::ssl with OpenSSL I run into occasional
crashes. I think I tracked down the problem to the following fact:
In boost/asio/ssl/detail/io.hpp the function operator() is called by 2
different threads at the same time. One thread is going through a explicit
strand in my user-code for that connection, the other one is the result of
a previous async_write or async_read started from that
io_op::operator()-function. That happens quite a lot. (Remark there is
only 1 connection during testing!)
Because of that boost::asio::ssl::detail::engine::perform is called by 2
different threads concurrently. I am not that familiar with OpenSSL, but I
suppose that this could be problematic.
Do I miss anything in my observation? Does somebody else has
boost::asio::ssl working in a multi threaded environment (meaning multiple
threads and one io_service) without problems? Does anybody has enough
knowledge of OpenSSL to say if that access could be problematic?
Reagrds,
Christian