Question

Can anyone list the pros and cons of using below two approaches for IO cancellation in wdf? 1) mark request cancellable with WdfRequestMarkCancelable (). Provide a cancel routine and synchronize the completion path. 2) keep on polling with WdfRequestIsCanceled() while processing IRP. Complete based on the returned value.

I understand that WdfRequestIsCanceled() is a polling approach whereas WdfRequestMarkCancelable () is asynchronous. But is WdfRequestMarkCancelable() worth the extra effort needed for synchronizing completion/cancel path?

Thanks for your inputs.

Was it helpful?

Solution

WdfRequestIsCanceled() is useful only when you happen to be processing a request anyhow. And, in Windows drivers, you tend to need to structure things very asynchronously, so it won't normally be the case that you just "happen" to be processing the request.

You should actually be asking yourself a different question: Do I want to use WdfRequestMarkCancelable or do I want to put the request back into a "manual" queue while you're doing work related to it. Putting it into a manual queue will make it cancelable. And if you need to do anything if it gets cancelled, you can put a cancel callback on the manual queue itself.

Each approach has pros and cons. I personally prefer handling cancellation directly, with WdfRequestMarkCancelable. Most others prefer to put requests in a manual queue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top