mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
- 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. svn path=/trunk/; revision=38986
This commit is contained in:
parent
2e3d23a37d
commit
d5823b702a
5 changed files with 60 additions and 36 deletions
|
@ -420,10 +420,9 @@ NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject,
|
|||
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))
|
||||
|
|
|
@ -35,9 +35,17 @@ NpfsSetPipeInformation(PDEVICE_OBJECT DeviceObject,
|
|||
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 @@ NpfsQueryPipeInformation(PDEVICE_OBJECT DeviceObject,
|
|||
PULONG BufferLength)
|
||||
{
|
||||
PNPFS_FCB Fcb;
|
||||
ULONG ConnectionSideReadMode;
|
||||
DPRINT("NpfsQueryPipeInformation()\n");
|
||||
|
||||
/* Get the Pipe */
|
||||
|
@ -82,10 +91,14 @@ NpfsQueryPipeInformation(PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
/* 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);
|
||||
|
|
|
@ -432,28 +432,14 @@ NpfsPeekPipe(PIRP Irp,
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ typedef struct _NPFS_FCB
|
|||
LIST_ENTRY WaiterListHead;
|
||||
LIST_ENTRY EmptyBufferListHead;
|
||||
ULONG PipeType;
|
||||
ULONG ReadMode;
|
||||
ULONG WriteMode;
|
||||
ULONG ClientReadMode;
|
||||
ULONG ServerReadMode;
|
||||
ULONG CompletionMode;
|
||||
ULONG PipeConfiguration;
|
||||
ULONG MaximumInstances;
|
||||
|
|
|
@ -346,7 +346,7 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
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 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
|||
{
|
||||
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 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
|||
Context = (PNPFS_CONTEXT)&Irp->Tail.Overlay.DriverContext;
|
||||
|
||||
Context->WaitEvent = &Ccb->ReadEvent;
|
||||
|
||||
Status = NpfsAddWaitingReadWriteRequest(DeviceObject, Irp);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
|
@ -488,7 +492,7 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
|||
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 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
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 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
|||
}
|
||||
else
|
||||
{
|
||||
KIRQL oldIrql;
|
||||
|
||||
if (IsOriginalRequest)
|
||||
{
|
||||
IsOriginalRequest = FALSE;
|
||||
|
@ -679,8 +690,23 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
|||
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 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
|
|||
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 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
|
|||
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);
|
||||
|
|
Loading…
Reference in a new issue