mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 20:56:26 +00:00
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. svn path=/trunk/; revision=40281
This commit is contained in:
parent
ad25b56ea8
commit
4ea62038a8
3 changed files with 21 additions and 11 deletions
|
@ -605,7 +605,7 @@ NpfsCleanup(PDEVICE_OBJECT DeviceObject,
|
|||
{
|
||||
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 @@ NpfsCleanup(PDEVICE_OBJECT DeviceObject,
|
|||
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
|
||||
|
|
|
@ -196,6 +196,13 @@ NpfsDisconnectPipe(PNPFS_CCB Ccb)
|
|||
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)
|
||||
|
|
|
@ -331,10 +331,12 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
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 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
|||
if (Ccb->PipeEnd == FILE_PIPE_CLIENT_END) ConnectionSideReadMode=Ccb->Fcb->ClientReadMode;
|
||||
else ConnectionSideReadMode = Ccb->Fcb->ServerReadMode;
|
||||
|
||||
if (Ccb->PipeState == FILE_PIPE_CONNECTED_STATE)
|
||||
if ((Ccb->PipeState == FILE_PIPE_CONNECTED_STATE) && (Ccb->OtherSide))
|
||||
{
|
||||
ASSERT(Ccb->OtherSide != NULL);
|
||||
KeSetEvent(&Ccb->OtherSide->WriteEvent, IO_NO_INCREMENT, FALSE);
|
||||
}
|
||||
if (Information > 0 &&
|
||||
|
@ -526,7 +527,7 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
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 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
|||
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 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
|
|||
{
|
||||
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 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
|
|||
if ((Status == STATUS_USER_APC) || (Status == STATUS_KERNEL_APC))
|
||||
{
|
||||
Status = STATUS_CANCELLED;
|
||||
break;
|
||||
goto done;
|
||||
}
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue