[NTOSKRNL]

Implement IopAllocateIrpMustSucceed() which is designed to *normally* always return an IRP.
Even in low memory situations (if you wait enough). 

svn path=/trunk/; revision=58243
This commit is contained in:
Pierre Schweitzer 2013-01-27 16:11:55 +00:00
parent a12df33047
commit fc5c683b7b
2 changed files with 40 additions and 0 deletions

View file

@ -903,6 +903,12 @@ IopAbortInterruptedIrp(
IN PIRP Irp
);
PIRP
NTAPI
IopAllocateIrpMustSucceed(
IN CCHAR StackSize
);
//
// Shutdown routines
//

View file

@ -625,6 +625,40 @@ IoAllocateIrp(IN CCHAR StackSize,
return Irp;
}
/*
* @implemented
*/
PIRP
NTAPI
IopAllocateIrpMustSucceed(IN CCHAR StackSize)
{
LONG i;
PIRP Irp;
LARGE_INTEGER Sleep;
/* Try to get an IRP */
Irp = IoAllocateIrp(StackSize, FALSE);
if (Irp)
return Irp;
/* If we fail, start looping till we may get one */
i = LONG_MAX;
do {
i--;
/* First, sleep for 10ms */
Sleep.QuadPart = -10 * 1000 * 10;;
KeDelayExecutionThread(KernelMode, FALSE, &Sleep);
/* Then, retry allocation */
Irp = IoAllocateIrp(StackSize, FALSE);
if (Irp)
return Irp;
} while (i > 0);
return Irp;
}
/*
* @implemented
*/