On Mon, 19 Apr 2021 at 20:39, Joost Kraaijeveld via Boost-users <boost-users@lists.boost.org> wrote:
Hi,

In short my program:
- creates an io_service
- calls acceptor::async_accept
- calls io_service.run
- handle several connections OK
- calls io_service.stop
- the acceptor goes out of scope (i.e. the destructor of the owning
object is ran)
- calls io_service.restart
- calls acceptor::async_accept which then throws "Operation cancelled"

Should it be possible to do this? When/under what circumstances does
async_accept throw this exception?

Difficult to comment without compiling up the code and trying it locally. Are you able to share a git repo that I can build? (cmake if possible)

Thanks.
 

Could it be connected with the fact that the acceptor's destructors
documents that is does some cleanup but actually does nothing, from the
source:

/// Destroys the acceptor.
  /**
   * This function destroys the acceptor, cancelling any outstanding
   * asynchronous operations associated with the acceptor as if by calling
   * @c cancel.
   */
  ~basic_socket_acceptor()
  {
  }

OS: Linux Debian Bullseye, Boost 1.74, gcc 10

TIA

Joost




_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
https://lists.boost.org/mailman/listinfo.cgi/boost-users