Alex Ionescu wrote:
Hartmut Birr wrote:
If the driver has returned STATUS_PENDING and completes the irp later with an error, both events must be signaled, because two different threads may waiting on this events. The IOSB must be also set. The apc must be also deliver (I've tested this with the apc sample and some modifications on windows). There is no difference between completing the irp with and without an error if the driver has returned STATUS_PENDING.
Your code now says " if (NT_SUCCESS(Irp->IoStatus.Status) || Irp->PendingReturned)". Not only is this incorrect because the flag must be checked, but my code had a path which handled this being FALSE. Currently ros does not have this path anymore after your changes. So if IoStatus.Status is a failure and PendingReturned is not set, nothing will be done. In my version of the code (which is what NT does), the events were still signaled in a specific case (see old code).
If a driver returns immediately with an error status, it isn't necessary to signal any event. The caller does only wait on the event, if the driver returns STATUS_PENDING (Some user mode functions may only check for an error). If the driver returns STATUS_PENDING, the driver has called IoMarkIrpPending , which sets Irp->PendingReturned. The error path without STATUS_PENDING must not do anything.
- Hartmut