Bug#123252: aio_cancel does not cancel a blocked aio_read
tags 123252 + upstream
tags 123252 - fixed-upstream moreinfo
# difficult, apparently.
severity 123252 wishlist
> The following code demonstrates what I believe is the same issue as
> was originally reported, but does so reading from stdin. Once the
> aio_read has begun and blocked, aio_cancel is unable to interrupt
> it until some data does arrive to be read.
Open group Base Issue 7 says concerning aio_cancel:
Which operations are cancelable is implementation-defined.
Ulrich Drepper says:
aio is designed for file I/O. Not everything works as you might
like it for other types of devices. We're not complicating the
implementation dramatically to handle these cases especially
since the standard explicitly does not require it. If you want
a better implementation, get sufficient support in the kernel.
As far as I can tell, aio_read is currently implemented using
pread in another thread, and aio_cancel does not interrupt a pending
read. Meanwhile Linux has had its own syscalls to support POSIX AIO
for a long time. One can link with -laio to use them; does that
improve things? If not, there's something to work on; if so, there's
an answer to Ulrich. :)
Some of the articles under "Asynchronous I/O" at
http://lwn.net/Kernel/Index/ might also be relevant.