Skip to content

Conversation

@shigui1990
Copy link
Contributor

@shigui1990 shigui1990 commented Nov 27, 2025

  • At openssl level, SSL_write() and SSL_read() on same SSL object, e.g. one SSL socket, are not thread-safe
  • At [boost] asio level, when enabling SSL, asio::async_write() and asio::async_read() on same asio::ssl::stream object are not thread-safe
  • When streaming mode is enabled, concurrent async_write()/async_read() calls on same ssl stream object is possible
  • In order to guarantee thread safe, when SSL and streaming mode are both enabled, one choice is to use asio::strand to serialize async_write() and async_read() calls on same ssl stream object.

class aa {
public:
template<typename BB, typename FF>
template<typename BB, typename FF, typename Strand = void*>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Strand = void will be better. Both work (void* vs void** in case when nullptr is passed) though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Fix done. Force push the pr.

…d() on same asio::ssl::stream object when ssl and steaming mode are both enabled
@shigui1990 shigui1990 force-pushed the branch_fix_ssl_streaming_mode branch from 8b13512 to 6e0c944 Compare December 2, 2025 00:10
@shigui1990 shigui1990 changed the title Use asio::strand to serialize asio::async_write() and asio::async_read() on same asio::ssl::stream object when ssl and steaming mode are both enabled Use asio::strand to serialize asio::async_write() and asio::async_read() on same asio::ssl::stream object when ssl and steaming mode are both enabled Dec 2, 2025
@shigui1990 shigui1990 changed the title Use asio::strand to serialize asio::async_write() and asio::async_read() on same asio::ssl::stream object when ssl and steaming mode are both enabled Use asio::strand to serialize asio::async_write() and asio::async_read() on same asio::ssl::stream object when ssl and steaming mode are both enabled Dec 2, 2025
Copy link
Contributor

@greensky00 greensky00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@greensky00 greensky00 merged commit 4fd06b2 into eBay:master Dec 2, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants