Opened 13 years ago
Closed 13 years ago
#3254 closed Bugs (invalid)
Cannot cancel async_write to a serial port
Reported by: | Owned by: | chris_kohlhoff | |
---|---|---|---|
Milestone: | Boost 1.40.0 | Component: | asio |
Version: | Boost 1.39.0 | Severity: | Problem |
Keywords: | Cc: |
Description
Attached is a test program that demonstrates some curious behavior I see while using serial port on a Linux system (epoll reactor).
The order of operations is: create serial_port, call async_write to send some data over the port, call cancel to cancel the write operation, enter io_service.
I would expect the write completion handler to be called with the error_code argument set. Instead, no error_code is set and some bytes are transferred.
Attachments (1)
Change History (3)
by , 13 years ago
Attachment: | serial_test.cpp added |
---|
comment:1 by , 13 years ago
I think I've traced the problem to the speculative write code path in the reactor service. The write is sent to the file descriptor ahead of queueing a work operation. So there is no way for the cancel operation to find the pending write operation. So I would think the speculative write path would need to at least provide some mechanism for the cancel operation to find the write operation and deliver the error code to the handler.
comment:2 by , 13 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
This is expected behaviour. The async operation can complete any time from when you call async_write to when your handler runs. In this case it completes immediately, is no longer pending, and so there is nothing to cancel.
Async write cancel test