[ros-diffs] [mjmartin] 40281: create.c: NpfsCleanup - Do not set the pipe's state to FILE_PIPE_DISCONNECTED_STATE, it is needed for determining broken pipes. Only set pipes otherside to NULL if it is not NULL already. fsctrl.c: NpfsDisconnectPipe - Set return status to STATUS_PIPE_DISCONNECTED if pipe is already disconnected. Add code to handle cases where PipeState is connected and pipes otherside has been set to NULL. rw.c: Set return status to STATUS_BROKEN_PIPE if the other side of pipe has been set to NULL, the data available in pipe is zero and pipe state is connected. Check that pipes otherside is valid before attempting to set the othersides read/write event.

mjmartin at svn.reactos.org mjmartin at svn.reactos.org
Sun Mar 29 13:15:11 CEST 2009


Author: mjmartin
Date: Sun Mar 29 15:15:10 2009
New Revision: 40281

URL: http://svn.reactos.org/svn/reactos?rev=40281&view=rev
Log:
create.c: NpfsCleanup - Do not set the pipe's state to FILE_PIPE_DISCONNECTED_STATE, it is needed for determining broken pipes.
Only set pipes otherside to NULL if it is not NULL already.
fsctrl.c: NpfsDisconnectPipe - Set return status to STATUS_PIPE_DISCONNECTED if pipe is already disconnected.
Add code to handle cases where PipeState is connected and pipes otherside has been set to NULL.
rw.c: Set return status to STATUS_BROKEN_PIPE if the other side of pipe has been set to NULL, the data available in pipe is zero and pipe state is connected.
Check that pipes otherside is valid before attempting to set the othersides read/write event.

Modified:
    trunk/reactos/drivers/filesystems/npfs/create.c
    trunk/reactos/drivers/filesystems/npfs/fsctrl.c
    trunk/reactos/drivers/filesystems/npfs/rw.c

Modified: trunk/reactos/drivers/filesystems/npfs/create.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/create.c?rev=40281&r1=40280&r2=40281&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/npfs/create.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/npfs/create.c [iso-8859-1] Sun Mar 29 15:15:10 2009
@@ -605,7 +605,7 @@
     {
         DPRINT("Client\n");
     }
-    if (Ccb->PipeState == FILE_PIPE_CONNECTED_STATE)
+    if ((Ccb->PipeState == FILE_PIPE_CONNECTED_STATE) && (Ccb->OtherSide))
     {
         OtherSide = Ccb->OtherSide;
         /* Lock the server first */
@@ -619,7 +619,7 @@
             ExAcquireFastMutex(&OtherSide->DataListLock);
             ExAcquireFastMutex(&Ccb->DataListLock);
         }
-        OtherSide->PipeState = FILE_PIPE_DISCONNECTED_STATE;
+        //OtherSide->PipeState = FILE_PIPE_DISCONNECTED_STATE;
         OtherSide->OtherSide = NULL;
         /*
         * Signaling the write event. If is possible that an other

Modified: trunk/reactos/drivers/filesystems/npfs/fsctrl.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/fsctrl.c?rev=40281&r1=40280&r2=40281&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/npfs/fsctrl.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/npfs/fsctrl.c [iso-8859-1] Sun Mar 29 15:15:10 2009
@@ -196,6 +196,13 @@
     if (Ccb->PipeState == FILE_PIPE_DISCONNECTED_STATE)
     {
         DPRINT("Pipe is already disconnected\n");
+        Status = STATUS_PIPE_DISCONNECTED;
+    }
+    else if ((!Ccb->OtherSide) && (Ccb->PipeState == FILE_PIPE_CONNECTED_STATE))
+    {
+        ExAcquireFastMutex(&Ccb->DataListLock);
+        Ccb->PipeState = FILE_PIPE_DISCONNECTED_STATE;
+        ExReleaseFastMutex(&Ccb->DataListLock);
         Status = STATUS_SUCCESS;
     }
     else if (Ccb->PipeState == FILE_PIPE_CONNECTED_STATE)

Modified: trunk/reactos/drivers/filesystems/npfs/rw.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/rw.c?rev=40281&r1=40280&r2=40281&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/npfs/rw.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/npfs/rw.c [iso-8859-1] Sun Mar 29 15:15:10 2009
@@ -331,10 +331,12 @@
 
     if ((Ccb->OtherSide == NULL) && (Ccb->ReadDataAvailable == 0))
     {
-        /* Its ok if the other side has been Disconnect, but if we have data still in the buffer
-                   , need to still be able to read it. Currently this is a HAXXXX */
-        DPRINT("Pipe no longer connected and no data exist in buffer. Ok to close pipe\n");
-        if (Ccb->PipeState == FILE_PIPE_LISTENING_STATE)
+        if (Ccb->PipeState == FILE_PIPE_CONNECTED_STATE)
+        {
+            DPRINT("File pipe broken\n");
+            Status = STATUS_PIPE_BROKEN;
+        }
+        else if (Ccb->PipeState == FILE_PIPE_LISTENING_STATE)
             Status = STATUS_PIPE_LISTENING;
         else if (Ccb->PipeState == FILE_PIPE_DISCONNECTED_STATE)
             Status = STATUS_PIPE_DISCONNECTED;
@@ -431,9 +433,8 @@
                 if (Ccb->PipeEnd == FILE_PIPE_CLIENT_END) ConnectionSideReadMode=Ccb->Fcb->ClientReadMode;
                 else ConnectionSideReadMode = Ccb->Fcb->ServerReadMode;
 
-                if (Ccb->PipeState == FILE_PIPE_CONNECTED_STATE)
-                {
-                    ASSERT(Ccb->OtherSide != NULL);
+                if ((Ccb->PipeState == FILE_PIPE_CONNECTED_STATE) && (Ccb->OtherSide))
+                {
                     KeSetEvent(&Ccb->OtherSide->WriteEvent, IO_NO_INCREMENT, FALSE);
                 }
                 if (Information > 0 &&
@@ -526,7 +527,7 @@
 
                 if ((Length == 0) || (Ccb->ReadDataAvailable == 0))
                 {
-                    if (Ccb->PipeState == FILE_PIPE_CONNECTED_STATE)
+                    if ((Ccb->PipeState == FILE_PIPE_CONNECTED_STATE) && (Ccb->OtherSide))
                     {
                         KeSetEvent(&Ccb->OtherSide->WriteEvent, IO_NO_INCREMENT, FALSE);
                     }
@@ -545,6 +546,8 @@
                     memcpy(Ccb->Data, Ccb->ReadPtr, (ULONG_PTR)Ccb->WritePtr - (ULONG_PTR)Ccb->ReadPtr);
                     Ccb->WritePtr = (PVOID)((ULONG_PTR)Ccb->WritePtr - ((ULONG_PTR)Ccb->ReadPtr - (ULONG_PTR)Ccb->Data));
                     Ccb->ReadPtr = Ccb->Data;
+                    ASSERT((ULONG_PTR)Ccb->WritePtr < ((ULONG_PTR)Ccb->Data + Ccb->MaxDataLength));
+                    ASSERT(Ccb->WritePtr >= Ccb->Data);
                 }
 
                 /* For Message mode, the Message length is stored in the buffer preceeding the Message. */
@@ -631,7 +634,7 @@
                     {
                         KeResetEvent(&Ccb->ReadEvent);
 
-                        if ((Ccb->PipeState == FILE_PIPE_CONNECTED_STATE) && (Ccb->WriteQuotaAvailable > 0))
+                        if ((Ccb->PipeState == FILE_PIPE_CONNECTED_STATE) && (Ccb->WriteQuotaAvailable > 0) && (Ccb->OtherSide))
                         {
                             KeSetEvent(&Ccb->OtherSide->WriteEvent, IO_NO_INCREMENT, FALSE);
                         }
@@ -817,7 +820,7 @@
             if ((Status == STATUS_USER_APC) || (Status == STATUS_KERNEL_APC))
             {
                 Status = STATUS_CANCELLED;
-                break;
+                goto done;
             }
             if (!NT_SUCCESS(Status))
             {



More information about the Ros-diffs mailing list