Search code examples
windowsfile-iocancelio

What does CancelIo() do with bytes that have already been read?


What happens if I ReadFile() 10 bytes (in overlapped mode without a timeout) but invoke CancelIo() after 5 bytes have been read? The documentation for CancelIo() says that it cancels any pending I/O, but what happens to the 5 bytes already read? Are they lost? Are they re-enqueued so the next time I ReadFile() I'll get them again?

I'm looking for the specification to indicate one way or another. I don't want to rely on empirical evidence.


Solution

  • According to http://groups.google.ca/group/microsoft.public.win32.programmer.kernel/browse_thread/thread/4fded0ac7e4ecfb4?hl=en

    It depends on how the driver writer implemented the device. The exact semantics of cancel on an operation are not defined to that level.