Author: fireball Date: Wed Dec 29 11:12:17 2010 New Revision: 50210
URL: http://svn.reactos.org/svn/reactos?rev=50210&view=rev Log: [NTOS] - Greatly simplify and fix the incorrect and overcomplicated if condition in IoIsOperationSynchronous(), based on MSDN description. Bug spotted, fix tested by Pierre.
Modified: trunk/reactos/ntoskrnl/io/iomgr/irp.c
Modified: trunk/reactos/ntoskrnl/io/iomgr/irp.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/irp.c?rev... ============================================================================== --- trunk/reactos/ntoskrnl/io/iomgr/irp.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/iomgr/irp.c [iso-8859-1] Wed Dec 29 11:12:17 2010 @@ -1704,12 +1704,21 @@ NTAPI IoIsOperationSynchronous(IN PIRP Irp) { + BOOLEAN SynchIO; + BOOLEAN ForceAsync; + + /* If the IRP requests synchronous paging I/O, if the file object was opened + for synchronous I/O, if the IRP_SYNCHRONOUS_API flag is set in the IRP + the operation is synchronous */ + SynchIO = (IoGetCurrentIrpStackLocation(Irp)->FileObject->Flags & FO_SYNCHRONOUS_IO) || + (Irp->Flags & IRP_SYNCHRONOUS_API) || (Irp->Flags & IRP_SYNCHRONOUS_PAGING_IO); + + /* If the IRP requests asynchronous paging I/O, the operation is asynchronous, + even if one of the above conditions is true */ + ForceAsync = (Irp->Flags & IRP_PAGING_IO) && !(Irp->Flags & IRP_SYNCHRONOUS_PAGING_IO); + /* Check the flags */ - if (!(Irp->Flags & (IRP_PAGING_IO | IRP_SYNCHRONOUS_PAGING_IO)) && - ((Irp->Flags & IRP_SYNCHRONOUS_PAGING_IO) || - (Irp->Flags & IRP_SYNCHRONOUS_API) || - (IoGetCurrentIrpStackLocation(Irp)->FileObject->Flags & - FO_SYNCHRONOUS_IO))) + if (SynchIO && !ForceAsync) { /* Synch API or Paging I/O is OK, as is Sync File I/O */ return TRUE;