chriskohlhoff / asio

Asio C++ Library
http://think-async.com/Asio
4.72k stars 1.19k forks source link

async_read on asio::serial_port does not return when io_context::stop() called #1481

Open nunojpg opened 1 month ago

nunojpg commented 1 month ago

Tested with master on Linux.

On program termination I call io_context::stop() to drain the event loop, and it works as expected for network stuff, but not for serial_port.

The callback with "asio::async_read(m_serial_port, asio::buffer(...), asio::transfer_at_least(0), ..." never returns.

More interestingly, as probably related, ::close or the destructor for the serial_port will block, but will unblock if a second call to io_context::stop() is made.

When using instead IO_URING backend, the callback issue persists, but the ::close issue does not happen.