[NTOS:IO]
[reactos.git] / reactos / ntoskrnl / io / iomgr / irp.c
index f88e80f..f768c76 100644 (file)
@@ -265,8 +265,8 @@ IopCompleteRequest(IN PKAPC Apc,
             (Irp->IoStatus.Information == IO_REPARSE_TAG_MOUNT_POINT))
         {
             /* We should never get this yet */
-            DPRINT1("Reparse support not yet present!\n");
-            while (TRUE);
+            UNIMPLEMENTED_DBGBREAK("Reparse support not yet present!\n");
+            return;
         }
     }
 
@@ -591,18 +591,18 @@ IoAllocateIrp(IN CCHAR StackSize,
         /* Check if we should charge quota */
         if (ChargeQuota)
         {
-            /* Irp = ExAllocatePoolWithQuotaTag(NonPagedPool, Size, TAG_IRP); */
-            /* FIXME */
-            Irp = ExAllocatePoolWithTag(NonPagedPool, Size, TAG_IRP);
+            Irp = ExAllocatePoolWithQuotaTag(NonPagedPool | POOL_QUOTA_FAIL_INSTEAD_OF_RAISE,
+                                             Size,
+                                             TAG_IRP);
         }
         else
         {
-            /* Allocate the IRP With no Quota charge */
+            /* Allocate the IRP with no quota charge */
             Irp = ExAllocatePoolWithTag(NonPagedPool, Size, TAG_IRP);
         }
 
         /* Make sure it was sucessful */
-        if (!Irp) return(NULL);
+        if (!Irp) return NULL;
     }
     else
     {
@@ -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
  */
@@ -1372,8 +1406,7 @@ IofCompleteRequest(IN PIRP Irp,
                              PriorityBoost);
 #else
             /* Not implemented yet. */
-            DPRINT1("Not supported!\n");
-            while (TRUE);
+            UNIMPLEMENTED_DBGBREAK("Not supported!\n");
 #endif
         }