Moved dereferencing of file objects to IoSecondStageCompletion.
authorHartmut Birr <osexpert@googlemail.com>
Sat, 27 Apr 2002 19:21:32 +0000 (19:21 +0000)
committerHartmut Birr <osexpert@googlemail.com>
Sat, 27 Apr 2002 19:21:32 +0000 (19:21 +0000)
svn path=/trunk/; revision=2883

reactos/ntoskrnl/io/cleanup.c
reactos/ntoskrnl/io/file.c

index 63f80fa..9d73c3d 100644 (file)
@@ -39,6 +39,7 @@ IopCompleteRequest1(struct _KAPC* Apc,
    PriorityBoost = (CCHAR)(LONG)(*SystemArgument2);
    
    IoStack = &Irp->Stack[(ULONG)Irp->CurrentLocation];
+   FileObject = IoStack->FileObject;
    
    (*SystemArgument1) = (PVOID)Irp->UserIosb;
    (*SystemArgument2) = (PVOID)Irp->IoStatus.Information;
@@ -50,11 +51,11 @@ IopCompleteRequest1(struct _KAPC* Apc,
    if (Irp->UserEvent!=NULL)
      {
        KeSetEvent(Irp->UserEvent,PriorityBoost,FALSE);
-       ObDereferenceObject( Irp->UserEvent );
+       // if the event is not the one in the file object, it needs dereferenced
+       if( FileObject && Irp->UserEvent != &FileObject->Event )
+         ObDereferenceObject( Irp->UserEvent );
      }
 
-   FileObject = IoStack->FileObject;
-   
    if (FileObject != NULL && IoStack->MajorFunction != IRP_MJ_CLOSE)
      {
        ObDereferenceObject(FileObject);
@@ -249,10 +250,6 @@ VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost)
      }
 
    if (FileObject != NULL && IoStack->MajorFunction != IRP_MJ_CLOSE)
-     {
-       //ObDereferenceObject(FileObject);
-     }
-   if (FileObject != NULL && (IoStack->MajorFunction == IRP_MJ_READ || IoStack->MajorFunction == IRP_MJ_WRITE || IoStack->MajorFunction ==IRP_MJ_CLEANUP || IoStack->MajorFunction ==IRP_MJ_CREATE || IoStack->MajorFunction==IRP_MJ_DIRECTORY_CONTROL))
      {
        ObDereferenceObject(FileObject);
      }
index 31bc89a..9b0ac55 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: file.c,v 1.16 2002/04/07 18:36:13 phreak Exp $
+/* $Id: file.c,v 1.17 2002/04/27 19:21:32 hbirr Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -125,7 +125,6 @@ NtQueryInformationFile(HANDLE FileHandle,
     }
    
    ExFreePool(SystemBuffer);
-   ObDereferenceObject(FileObject);
    
    return(Status);
 }
@@ -201,7 +200,6 @@ IoQueryFileInformation(IN PFILE_OBJECT FileObject,
        *ReturnedLength = IoStatusBlock.Information;
      }
    
-   ObDereferenceObject(FileObject);
    
    return Status;
 }
@@ -308,8 +306,7 @@ NtSetInformationFile(HANDLE FileHandle,
        *IoStatusBlock = IoSB;
      }
    ExFreePool(SystemBuffer);
-   ObDereferenceObject(FileObject);
-   
    return Status;
 }