[NTFS]
[reactos.git] / reactos / drivers / filesystems / ntfs / close.c
index 79ef82c..008f453 100644 (file)
@@ -101,8 +101,21 @@ NtfsClose(PNTFS_IRP_CONTEXT IrpContext)
     FileObject = IrpContext->FileObject;
     DeviceExtension = DeviceObject->DeviceExtension;
 
+    if (!ExAcquireResourceExclusiveLite(&DeviceExtension->DirResource,
+                                        BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT)))
+    {
+        return NtfsMarkIrpContextForQueue(IrpContext);
+    }
+
     Status = NtfsCloseFile(DeviceExtension, FileObject);
 
+    ExReleaseResourceLite(&DeviceExtension->DirResource);
+
+    if (Status == STATUS_PENDING)
+    {
+        return NtfsMarkIrpContextForQueue(IrpContext);
+    }
+
     IrpContext->Irp->IoStatus.Information = 0;
     return Status;
 }