Author: pschweitzer
Date: Sun Jan 27 16:11:55 2013
New Revision: 58243
URL:
http://svn.reactos.org/svn/reactos?rev=58243&view=rev
Log:
[NTOSKRNL]
Implement IopAllocateIrpMustSucceed() which is designed to *normally* always return an
IRP.
Even in low memory situations (if you wait enough).
Modified:
trunk/reactos/ntoskrnl/include/internal/io.h
trunk/reactos/ntoskrnl/io/iomgr/irp.c
Modified: trunk/reactos/ntoskrnl/include/internal/io.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/io.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/io.h [iso-8859-1] Sun Jan 27 16:11:55 2013
@@ -903,6 +903,12 @@
IN PIRP Irp
);
+PIRP
+NTAPI
+IopAllocateIrpMustSucceed(
+ IN CCHAR StackSize
+);
+
//
// Shutdown routines
//
Modified: trunk/reactos/ntoskrnl/io/iomgr/irp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/irp.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/irp.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/irp.c [iso-8859-1] Sun Jan 27 16:11:55 2013
@@ -622,6 +622,40 @@
__FUNCTION__,
Irp,
Flags);
+ 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;
}