Author: mjmartin
Date: Wed Jan 21 01:52:45 2009
New Revision: 38986
URL:
http://svn.reactos.org/svn/reactos?rev=38986&view=rev
Log:
- npfs.h: The member named WriteMode is meaningless for pipes, as the write mode is the
PipeType for both client and server. Change names to something more
descriptive,ServerReadMode and ClientReadMode, for the members new use.
- create.c: Use new members.
- finfo.c: Check whether the pipe side is server or client and change/return appropriate
ReadMode.
- fsctrl.c: Opps. Previous implementation was pretty much correct.
- rw.c: Silence debug message and use new members.
Add multiple checks on whether pipe side is server or client and use appropriate
ReadMode.
If handling the next Irp in NpfsRead, remove the cancel routine before continuing the
loop. Fixes BugCheck when running ntdll_winetest for file. Thank Christoph von Wittich for
pointing this out.
Modified:
trunk/reactos/drivers/filesystems/npfs/create.c
trunk/reactos/drivers/filesystems/npfs/finfo.c
trunk/reactos/drivers/filesystems/npfs/fsctrl.c
trunk/reactos/drivers/filesystems/npfs/npfs.h
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/c…
==============================================================================
--- trunk/reactos/drivers/filesystems/npfs/create.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/npfs/create.c [iso-8859-1] Wed Jan 21 01:52:45 2009
@@ -420,10 +420,9 @@
KeInitializeMutex(&Fcb->CcbListLock, 0);
Fcb->PipeType = Buffer->NamedPipeType;
- /* FIXME: Verify which is correct */
- Fcb->WriteMode = Buffer->ReadMode;//Buffer->NamedPipeType;
+ Fcb->ServerReadMode = Buffer->ReadMode;
/* MSDN documentation reads that clients always start off in byte mode */
- Fcb->ReadMode = FILE_PIPE_BYTE_STREAM_MODE;
+ Fcb->ClientReadMode = FILE_PIPE_BYTE_STREAM_MODE;
Fcb->CompletionMode = Buffer->CompletionMode;
switch (IoStack->Parameters.CreatePipe.ShareAccess &
(FILE_SHARE_READ|FILE_SHARE_WRITE))
Modified: trunk/reactos/drivers/filesystems/npfs/finfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/f…
==============================================================================
--- trunk/reactos/drivers/filesystems/npfs/finfo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/npfs/finfo.c [iso-8859-1] Wed Jan 21 01:52:45 2009
@@ -35,9 +35,17 @@
DPRINT("Cannot change readmode to message type on a byte type pipe!\n");
return STATUS_ACCESS_DENIED;
}
-
+
/* Set Pipe Data */
- Fcb->ReadMode = Request->ReadMode;
+ if (Ccb->PipeEnd == FILE_PIPE_CLIENT_END)
+ {
+ Fcb->ClientReadMode = Request->ReadMode;
+ }
+ else
+ {
+ Fcb->ServerReadMode = Request->ReadMode;
+ }
+
Fcb->CompletionMode = Request->CompletionMode;
/* Return Success */
@@ -75,6 +83,7 @@
PULONG BufferLength)
{
PNPFS_FCB Fcb;
+ ULONG ConnectionSideReadMode;
DPRINT("NpfsQueryPipeInformation()\n");
/* Get the Pipe */
@@ -82,10 +91,14 @@
/* Clear Info */
RtlZeroMemory(Info, sizeof(FILE_PIPE_INFORMATION));
+
+
+ if (Ccb->PipeEnd == FILE_PIPE_CLIENT_END)
ConnectionSideReadMode=Ccb->Fcb->ClientReadMode;
+ else ConnectionSideReadMode = Ccb->Fcb->ServerReadMode;
/* Return Info */
Info->CompletionMode = Fcb->CompletionMode;
- Info->ReadMode = Fcb->ReadMode;
+ Info->ReadMode = ConnectionSideReadMode;
/* Return success */
*BufferLength -= sizeof(FILE_PIPE_INFORMATION);
Modified: trunk/reactos/drivers/filesystems/npfs/fsctrl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/f…
==============================================================================
--- trunk/reactos/drivers/filesystems/npfs/fsctrl.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/npfs/fsctrl.c [iso-8859-1] Wed Jan 21 01:52:45 2009
@@ -432,28 +432,14 @@
ReadDataAvailable -= MessageLength;
MessageCount++;
- if (Ccb->Fcb->ReadMode == FILE_PIPE_BYTE_STREAM_MODE)
- {
+ /* If its the first message, copy the Message if the size of buffer is large enough
*/
+ if (MessageCount==1)
+ {
if ((Reply->Data[0])
- && (OutputBufferLength >= (MessageLength + ReturnLength +
FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0]))))
- {
- memcpy((PVOID)((ULONG_PTR)&Reply->Data[0] + ReturnLength),
- (PVOID)((ULONG)BufferPtr + sizeof(MessageLength)),
- MessageLength);
- ReturnLength += MessageLength;
- }
- }
- else
- {
- /* If its the first message, copy the Message if the size of buffer is large enough
*/
- if (MessageCount==1)
- {
- if ((Reply->Data[0])
- && (OutputBufferLength >= (MessageLength +
FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0]))))
- {
- memcpy(&Reply->Data[0], (PVOID)((ULONG)BufferPtr + sizeof(MessageLength)),
MessageLength);
- ReturnLength = MessageLength;
- }
+ && (OutputBufferLength >= (MessageLength +
FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0]))))
+ {
+ memcpy(&Reply->Data[0], (PVOID)((ULONG)BufferPtr + sizeof(MessageLength)),
MessageLength);
+ ReturnLength = MessageLength;
}
}
Modified: trunk/reactos/drivers/filesystems/npfs/npfs.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/n…
==============================================================================
--- trunk/reactos/drivers/filesystems/npfs/npfs.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/npfs/npfs.h [iso-8859-1] Wed Jan 21 01:52:45 2009
@@ -26,8 +26,8 @@
LIST_ENTRY WaiterListHead;
LIST_ENTRY EmptyBufferListHead;
ULONG PipeType;
- ULONG ReadMode;
- ULONG WriteMode;
+ ULONG ClientReadMode;
+ ULONG ServerReadMode;
ULONG CompletionMode;
ULONG PipeConfiguration;
ULONG MaximumInstances;
Modified: trunk/reactos/drivers/filesystems/npfs/rw.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/r…
==============================================================================
--- trunk/reactos/drivers/filesystems/npfs/rw.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/npfs/rw.c [iso-8859-1] Wed Jan 21 01:52:45 2009
@@ -346,7 +346,7 @@
if (Ccb->Data == NULL)
{
- DPRINT1("Pipe is NOT readable!\n");
+ DPRINT("Pipe is NOT readable!\n");
Status = STATUS_UNSUCCESSFUL;
Irp->IoStatus.Information = 0;
goto done;
@@ -426,13 +426,18 @@
{
if (Ccb->ReadDataAvailable == 0)
{
+ ULONG ConnectionSideReadMode;
+
+ 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);
KeSetEvent(&Ccb->OtherSide->WriteEvent, IO_NO_INCREMENT, FALSE);
}
if (Information > 0 &&
- (Ccb->Fcb->ReadMode != FILE_PIPE_BYTE_STREAM_MODE ||
+ (ConnectionSideReadMode != FILE_PIPE_BYTE_STREAM_MODE ||
Ccb->PipeState != FILE_PIPE_CONNECTED_STATE))
{
break;
@@ -473,7 +478,6 @@
Context = (PNPFS_CONTEXT)&Irp->Tail.Overlay.DriverContext;
Context->WaitEvent = &Ccb->ReadEvent;
-
Status = NpfsAddWaitingReadWriteRequest(DeviceObject, Irp);
if (NT_SUCCESS(Status))
@@ -488,7 +492,7 @@
ASSERT(IoGetCurrentIrpStackLocation(Irp)->FileObject != NULL);
/* If the pipe type and read mode are both byte stream */
- if ((Ccb->Fcb->PipeType == FILE_PIPE_BYTE_STREAM_TYPE) &&
(Ccb->Fcb->ReadMode == FILE_PIPE_BYTE_STREAM_MODE))
+ if (Ccb->Fcb->PipeType == FILE_PIPE_BYTE_STREAM_TYPE)
{
DPRINT("Byte stream mode: Ccb->Data %x\n", Ccb->Data);
/* Byte stream mode */
@@ -613,7 +617,12 @@
if (Information > 0)
{
- if ((Ccb->Fcb->ReadMode == FILE_PIPE_BYTE_STREAM_MODE) &&
(Ccb->ReadDataAvailable) && (Length > CopyLength))
+ ULONG ConnectionSideReadMode;
+
+ if (Ccb->PipeEnd == FILE_PIPE_CLIENT_END)
ConnectionSideReadMode=Ccb->Fcb->ClientReadMode;
+ else ConnectionSideReadMode = Ccb->Fcb->ServerReadMode;
+
+ if ((ConnectionSideReadMode == FILE_PIPE_BYTE_STREAM_MODE) &&
(Ccb->ReadDataAvailable) && (Length > CopyLength))
{
Buffer = (PVOID)((ULONG_PTR)Buffer + CopyLength);
Length -= CopyLength;
@@ -660,6 +669,8 @@
}
else
{
+ KIRQL oldIrql;
+
if (IsOriginalRequest)
{
IsOriginalRequest = FALSE;
@@ -679,8 +690,23 @@
DPRINT("NpfsRead done (Status %lx)\n", OriginalStatus);
return OriginalStatus;
}
+
+ IoAcquireCancelSpinLock(&oldIrql);
Context = CONTAINING_RECORD(Ccb->ReadRequestListHead.Flink, NPFS_CONTEXT,
ListEntry);
+
Irp = CONTAINING_RECORD(Context, IRP, Tail.Overlay.DriverContext);
+ /* Verify the Irp wasnt cancelled */
+ if (Irp->Cancel)
+ {
+ IoReleaseCancelSpinLock(oldIrql);
+ RemoveEntryList(&Context->ListEntry);
+ ExReleaseFastMutex(&Ccb->DataListLock);
+ Status = STATUS_CANCELLED;
+ goto done;
+ }
+ /* The Irp will now be handled, so remove the CancelRoutine */
+ (void)IoSetCancelRoutine(Irp, NULL);
+ IoReleaseCancelSpinLock(oldIrql);
}
}
@@ -810,7 +836,7 @@
ExAcquireFastMutex(&ReaderCcb->DataListLock);
}
- if ((Ccb->Fcb->PipeType == FILE_PIPE_BYTE_STREAM_TYPE) &&
(Ccb->Fcb->WriteMode == FILE_PIPE_BYTE_STREAM_MODE))
+ if (Ccb->Fcb->PipeType == FILE_PIPE_BYTE_STREAM_TYPE)
{
DPRINT("Byte stream mode: Ccb->Data %x, Ccb->WritePtr %x\n",
ReaderCcb->Data, ReaderCcb->WritePtr);
@@ -853,7 +879,7 @@
break;
}
}
- else if ((Ccb->Fcb->PipeType == FILE_PIPE_MESSAGE_TYPE) &&
(Ccb->Fcb->WriteMode == FILE_PIPE_MESSAGE_MODE))
+ else if (Ccb->Fcb->PipeType == FILE_PIPE_MESSAGE_TYPE)
{
/* For Message Type Pipe, the Pipes memory will be used to store the size of each
message */
DPRINT("Message mode: Ccb->Data %x, Ccb->WritePtr
%x\n",ReaderCcb->Data, ReaderCcb->WritePtr);