From f73d8199f715beec7bfb78e460fea723a107dd7c Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 27 May 2010 23:52:32 +0000 Subject: [PATCH] [NPFS] - Partially revert r47370 and apply a better patch - Change ReadEvent and WriteEvent to notification events because we reset those events manually when we run out of buffer space svn path=/trunk/; revision=47375 --- reactos/drivers/filesystems/npfs/create.c | 10 ++++------ reactos/drivers/filesystems/npfs/rw.c | 20 ++++++-------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/reactos/drivers/filesystems/npfs/create.c b/reactos/drivers/filesystems/npfs/create.c index 86209bdb8ab..2eb0aad9c0e 100644 --- a/reactos/drivers/filesystems/npfs/create.c +++ b/reactos/drivers/filesystems/npfs/create.c @@ -205,8 +205,8 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject, ClientCcb->MaxDataLength = Fcb->OutboundQuota; ExInitializeFastMutex(&ClientCcb->DataListLock); KeInitializeEvent(&ClientCcb->ConnectEvent, SynchronizationEvent, FALSE); - KeInitializeEvent(&ClientCcb->ReadEvent, SynchronizationEvent, FALSE); - KeInitializeEvent(&ClientCcb->WriteEvent, SynchronizationEvent, FALSE); + KeInitializeEvent(&ClientCcb->ReadEvent, NotificationEvent, FALSE); + KeInitializeEvent(&ClientCcb->WriteEvent, NotificationEvent, FALSE); /* @@ -540,8 +540,8 @@ NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject, DPRINT("CCB: %p\n", Ccb); KeInitializeEvent(&Ccb->ConnectEvent, SynchronizationEvent, FALSE); - KeInitializeEvent(&Ccb->ReadEvent, SynchronizationEvent, FALSE); - KeInitializeEvent(&Ccb->WriteEvent, SynchronizationEvent, FALSE); + KeInitializeEvent(&Ccb->ReadEvent, NotificationEvent, FALSE); + KeInitializeEvent(&Ccb->WriteEvent, NotificationEvent, FALSE); KeLockMutex(&Fcb->CcbListLock); InsertTailList(&Fcb->ServerCcbListHead, &Ccb->CcbListEntry); @@ -619,7 +619,6 @@ NpfsCleanup(PDEVICE_OBJECT DeviceObject, ExAcquireFastMutex(&OtherSide->DataListLock); ExAcquireFastMutex(&Ccb->DataListLock); } - OtherSide->PipeState = FILE_PIPE_CLOSING_STATE; OtherSide->OtherSide = NULL; /* * Signaling the write event. If is possible that an other @@ -745,7 +744,6 @@ NpfsClose(PDEVICE_OBJECT DeviceObject, /* Disconnect the pipes */ if (Ccb->OtherSide) { - Ccb->OtherSide->PipeState = FILE_PIPE_CLOSING_STATE; Ccb->OtherSide->OtherSide = NULL; Ccb->OtherSide = NULL; } diff --git a/reactos/drivers/filesystems/npfs/rw.c b/reactos/drivers/filesystems/npfs/rw.c index 4c83f5cec53..f3f02bdd315 100644 --- a/reactos/drivers/filesystems/npfs/rw.c +++ b/reactos/drivers/filesystems/npfs/rw.c @@ -331,11 +331,8 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject, if ((Ccb->OtherSide == NULL) && (Ccb->ReadDataAvailable == 0)) { - if (Ccb->PipeState == FILE_PIPE_CLOSING_STATE) - { - DPRINT("File pipe broken\n"); + if (Ccb->PipeState == FILE_PIPE_CONNECTED_STATE) Status = STATUS_PIPE_BROKEN; - } else if (Ccb->PipeState == FILE_PIPE_LISTENING_STATE) Status = STATUS_PIPE_LISTENING; else if (Ccb->PipeState == FILE_PIPE_DISCONNECTED_STATE) @@ -443,7 +440,7 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject, { break; } - if ((Ccb->PipeState != FILE_PIPE_CONNECTED_STATE) && (Ccb->ReadDataAvailable == 0)) + if (((Ccb->PipeState != FILE_PIPE_CONNECTED_STATE) || (!Ccb->OtherSide)) && (Ccb->ReadDataAvailable == 0)) { DPRINT("PipeState: %x\n", Ccb->PipeState); Status = STATUS_PIPE_BROKEN; @@ -800,13 +797,13 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject, { if ((ReaderCcb->WriteQuotaAvailable == 0)) { - KeSetEvent(&ReaderCcb->ReadEvent, IO_NO_INCREMENT, FALSE); - if (Ccb->PipeState != FILE_PIPE_CONNECTED_STATE) + if (Ccb->PipeState != FILE_PIPE_CONNECTED_STATE || !Ccb->OtherSide) { Status = STATUS_PIPE_BROKEN; ExReleaseFastMutex(&ReaderCcb->DataListLock); goto done; } + KeSetEvent(&ReaderCcb->ReadEvent, IO_NO_INCREMENT, FALSE); ExReleaseFastMutex(&ReaderCcb->DataListLock); DPRINT("Write Waiting for buffer space (%S)\n", Fcb->PipeName.Buffer); @@ -830,20 +827,15 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject, * It's possible that the event was signaled because the * other side of pipe was closed. */ - if (Ccb->PipeState != FILE_PIPE_CONNECTED_STATE) + if (Ccb->PipeState != FILE_PIPE_CONNECTED_STATE || !Ccb->OtherSide) { DPRINT("PipeState: %x\n", Ccb->PipeState); Status = STATUS_PIPE_BROKEN; goto done; } /* Check that the pipe has not been closed */ - if (ReaderCcb->PipeState != FILE_PIPE_CONNECTED_STATE) + if (ReaderCcb->PipeState != FILE_PIPE_CONNECTED_STATE || !ReaderCcb->OtherSide) { - /* If the other side is valid, fire event */ - if (Ccb) - { - KeResetEvent(&Ccb->WriteEvent); - } Status = STATUS_PIPE_BROKEN; goto done; } -- 2.17.1