Boost logo

Boost Users :

Subject: [Boost-users] [asio] Does ssl::stream allow multiple pending async operations?
From: Phil Sean (philsean_at_[hidden])
Date: 2017-11-05 14:00:57


The documentation for ssl::stream says:
"Shared objects: Unsafe. The application must also ensure that all asynchronous operations are performed within the same implicit or explicit strand."

Does this mean we have to wait for an async operation to finish before another is started (for read/read, read/write, and write/write)?
(Async operations refer to async_read_some() and async_write_some(), not the composed operations.)

If so, is the operation said to have finished when the handler is invoked or when the handler returns? That is:

void handler(
  const boost::system::error_code& error,
  std::size_t bytes_transferred
) {
  // Does the operation finish here
  ...
} // or here?

If not, what's the difference between the async operations of ip::tcp::socket and ssl::stream then (as strand just avoids concurrency for the thread-unsafe)?

I came across different views on this problem. This answer[1] suggests that simply using the same strand (ie. no concurrency) will suffice. Another one[2] says multiple pending asynchronous operations can be problematic for ssl::stream even if no concurrency occurs.

Thanks.

[1] https://stackoverflow.com/questions/27212123/executing-asynchronous-operations-within-the-same-strand#27214989
[2] https://stackoverflow.com/questions/15352472/using-boosts-ssl-asio-code-async-write-some-hangs#15367222


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net