zaphoyd/websocketpp — Issue #68: Policy Refactor: Thread Pool + SSL = Problem
Author: megabyte1024
Created: 2012-02-14 14:37:21+00:00
State: open

If a program uses library's TLS connections together with a thread pool similar to the ASIO's HTTP Server 3 and, then the program crashes. It happens because all the OpenSSL functions are called from multiple threads simultaneously and the OpenSSL requires that a connection should not be used concurrently by multiple threads (http://www.openssl.org/support/faq.html#PROG1) . To prevent the crash is necessary to use the boost::asio::io_service::strand class. The HTTP Server 3 shows how to do that. I implemented a strand instance inside of the endpoint_base class and "wrapped" all async socket calls. The crash is fixed.

I don't know if this "threads pool" scenario is suitable for the developers. If yes, then it would be nice to use the strand class inside of the library.