@@ -168,6 +168,7 @@ class wspp_callback_client : public websocket_client_callback_impl, public std::
168
168
sslContext->set_default_verify_paths ();
169
169
sslContext->set_options (boost::asio::ssl::context::default_workarounds);
170
170
sslContext->set_verify_mode (boost::asio::ssl::context::verify_peer);
171
+
171
172
#if defined(__APPLE__) || (defined(ANDROID) || defined(__ANDROID__)) || defined(_WIN32)
172
173
m_openssl_failed = false ;
173
174
#endif
@@ -191,6 +192,14 @@ class wspp_callback_client : public websocket_client_callback_impl, public std::
191
192
return rfc2818 (preverified, verifyCtx);
192
193
});
193
194
195
+ // OpenSSL stores some per thread state that never will be cleaned up until
196
+ // the dll is unloaded. If static linking, like we do, the state isn't cleaned up
197
+ // at all and will be reported as leaks.
198
+ // See http://www.openssl.org/support/faq.html#PROG13
199
+ // This is necessary here because it is called on the user's thread calling connect(...)
200
+ // eventually through websocketpp::client::get_connection(...)
201
+ ERR_remove_thread_state (nullptr );
202
+
194
203
return sslContext;
195
204
});
196
205
return connect_impl<websocketpp::config::asio_tls_client>();
@@ -306,6 +315,12 @@ class wspp_callback_client : public websocket_client_callback_impl, public std::
306
315
#if defined(__ANDROID__)
307
316
crossplat::JVM.load ()->DetachCurrentThread ();
308
317
#endif
318
+
319
+ // OpenSSL stores some per thread state that never will be cleaned up until
320
+ // the dll is unloaded. If static linking, like we do, the state isn't cleaned up
321
+ // at all and will be reported as leaks.
322
+ // See http://www.openssl.org/support/faq.html#PROG13
323
+ ERR_remove_thread_state (nullptr );
309
324
});
310
325
return pplx::create_task (m_connect_tce);
311
326
}
0 commit comments