[AFD] ReceiveActivity: Don't return STATUS_FILE_CLOSED in case of FCB overread (#4972)

Based on patch by KRosUser. Remove the Overread member. The new test in ws2_32:recv confirms that this special behavior is never needed.
CORE-18328
This commit is contained in:
Thamatip Chitpong 2023-03-25 20:00:26 +07:00 committed by GitHub
parent a027eb7ccb
commit 9f9b81e396
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 15 deletions

View File

@ -751,9 +751,6 @@ AfdDisconnect(PDEVICE_OBJECT DeviceObject, PIRP Irp,
FCB->Recv.Content = 0;
FCB->Recv.BytesUsed = 0;
/* Mark us as overread to complete future reads with an error */
FCB->Overread = TRUE;
/* Set a successful receive status to indicate a shutdown on overread */
FCB->LastReceiveStatus = STATUS_SUCCESS;

View File

@ -175,23 +175,16 @@ static NTSTATUS ReceiveActivity( PAFD_FCB FCB, PIRP Irp ) {
TotalBytesCopied));
UnlockBuffers( RecvReq->BufferArray,
RecvReq->BufferCount, FALSE );
if (FCB->Overread && FCB->LastReceiveStatus == STATUS_SUCCESS)
{
/* Overread after a graceful disconnect so complete with an error */
Status = STATUS_FILE_CLOSED;
}
else
{
/* Unexpected disconnect by the remote host or initial read after a graceful disconnect */
Status = FCB->LastReceiveStatus;
}
/* Unexpected disconnect by the remote host or graceful disconnect */
Status = FCB->LastReceiveStatus;
NextIrp->IoStatus.Status = Status;
NextIrp->IoStatus.Information = 0;
if( NextIrp == Irp ) RetStatus = Status;
if( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) );
(void)IoSetCancelRoutine(NextIrp, NULL);
IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT );
FCB->Overread = TRUE;
}
} else {
/* Kick the user that receive would be possible now */

View File

@ -159,7 +159,7 @@ typedef struct _AFD_STORED_DATAGRAM {
} AFD_STORED_DATAGRAM, *PAFD_STORED_DATAGRAM;
typedef struct _AFD_FCB {
BOOLEAN Locked, Critical, Overread, NonBlocking, OobInline, TdiReceiveClosed, SendClosed;
BOOLEAN Locked, Critical, NonBlocking, OobInline, TdiReceiveClosed, SendClosed;
UINT State, Flags, GroupID, GroupType;
KIRQL OldIrql;
UINT LockCount;