
Now there's still a bug! When trying to call cancel() on a serial_port when BOOST_ASIO_ENABLE_CANCELIO is not defined, it should fail with asio::error::operation_not_supported as the doc says, but it doens't. It just silently tries to go on with reading from the serial port.
The problem is that when BOOST_ASIO_ENABLE_CANCELIO is not defined, asio\detail\win_iocp_handle_service.hpp makes it so impl.safe_cancellation_thread_id_ is equal to 0 and then when cancelling the following code is executed: else if (impl.safe_cancellation_thread_id_ == 0) { // No operations have been started, so there's nothing to cancel. ec = boost::system::error_code(); } Thus cancel() thinks there's nothing to cancel, and asio::error::operation_not_supported isn't triggered. Philippe