Author: cgutman
Date: Mon Jul 18 11:27:01 2011
New Revision: 52725
URL:
http://svn.reactos.org/svn/reactos?rev=52725&view=rev
Log:
[AFD]
- Fix typos from my previous commit
- Fix another bug with recv() on a datagram socket
- Fix cancellation bugs
Modified:
trunk/reactos/drivers/network/afd/afd/main.c
trunk/reactos/drivers/network/afd/afd/read.c
trunk/reactos/drivers/network/afd/include/afd.h
Modified: trunk/reactos/drivers/network/afd/afd/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/ma…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/main.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/main.c [iso-8859-1] Mon Jul 18 11:27:01 2011
@@ -945,6 +945,54 @@
return (Status);
}
+BOOLEAN CheckUnlockExtraBuffers(PAFD_FCB FCB, PIO_STACK_LOCATION IrpSp)
+{
+ if (FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS)
+ {
+ if (IrpSp->MajorFunction == IRP_MJ_READ || IrpSp->MajorFunction ==
IRP_MJ_WRITE)
+ {
+ /* read()/write() call - no extra buffers */
+ return FALSE;
+ }
+ else if (IrpSp->MajorFunction == IRP_MJ_DEVICE_CONTROL)
+ {
+ if (IrpSp->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_AFD_RECV_DATAGRAM)
+ {
+ /* recvfrom() call - extra buffers */
+ return TRUE;
+ }
+ else if (IrpSp->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_AFD_RECV)
+ {
+ /* recv() call - no extra buffers */
+ return FALSE;
+ }
+ else if (IrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_AFD_SEND
||
+ IrpSp->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_AFD_SEND_DATAGRAM)
+ {
+ /* send()/sendto() call - no extra buffers */
+ return FALSE;
+ }
+ else
+ {
+ /* Unknown IOCTL */
+ ASSERT(FALSE);
+ return FALSE;
+ }
+ }
+ else
+ {
+ /* Unknown IRP_MJ code */
+ ASSERT(FALSE);
+ return FALSE;
+ }
+ }
+ else
+ {
+ /* Connection-oriented never has extra buffers */
+ return FALSE;
+ }
+}
+
VOID
CleanupPendingIrp(PAFD_FCB FCB, PIRP Irp, PIO_STACK_LOCATION IrpSp, PAFD_ACTIVE_POLL
Poll)
{
@@ -956,14 +1004,13 @@
IrpSp->MajorFunction == IRP_MJ_READ)
{
RecvReq = GetLockedData(Irp, IrpSp);
- UnlockBuffers(RecvReq->BufferArray, RecvReq->BufferCount, FALSE);
+ UnlockBuffers(RecvReq->BufferArray, RecvReq->BufferCount,
CheckUnlockExtraBuffers(FCB, IrpSp));
}
else if ((IrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_AFD_SEND ||
- IrpSp->MajorFunction == IRP_MJ_WRITE) &&
- !(FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS))
+ IrpSp->MajorFunction == IRP_MJ_WRITE))
{
SendReq = GetLockedData(Irp, IrpSp);
- UnlockBuffers(SendReq->BufferArray, SendReq->BufferCount, FALSE);
+ UnlockBuffers(SendReq->BufferArray, SendReq->BufferCount,
CheckUnlockExtraBuffers(FCB, IrpSp));
}
else if (IrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_AFD_SELECT)
{
Modified: trunk/reactos/drivers/network/afd/afd/read.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/re…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/read.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/read.c [iso-8859-1] Mon Jul 18 11:27:01 2011
@@ -44,48 +44,6 @@
return !BytesAvailable &&
(FCB->PollState & (AFD_EVENT_CLOSE | AFD_EVENT_ABORT));
-}
-
-static BOOLEAN CheckUnlockExtraBuffers(PAFD_FCB FCB, PIO_STACK_LOCATION IrpSp)
-{
- if (FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS)
- {
- if (IrpSp->MajorFunction == IRP_MJ_READ)
- {
- /* read() call - no extra buffers */
- return FALSE;
- }
- else if (IrpSp->MajorFunction == IRP_MJ_DEVICE_CONTROL)
- {
- if (IrpSp->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_AFD_RECV_DATAGRAM)
- {
- /* recvfrom() call - extra buffers */
- return TRUE;
- }
- else if (IrpSp->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_AFD_RECV)
- {
- /* recv() call - no extra buffers */
- return FALSE;
- }
- else
- {
- /* Unknown IOCTL */
- ASSERT(FALSE);
- return FALSE;
- }
- }
- else
- {
- /* Unknown IRP_MJ code */
- ASSERT(FALSE);
- return FALSE;
- }
- }
- else
- {
- /* Connection-oriented never has extra buffers */
- return FALSE;
- }
}
static VOID RefillSocketBuffer( PAFD_FCB FCB ) {
@@ -343,10 +301,11 @@
GetLockedData(Irp, IrpSp);
UINT BytesToCopy = 0, BytesAvailable = DatagramRecv->Len, AddrLen = 0;
PAFD_MAPBUF Map;
+ BOOLEAN ExtraBuffers = CheckUnlockExtraBuffers(FCB, IrpSp);
Map = (PAFD_MAPBUF)(RecvReq->BufferArray +
RecvReq->BufferCount +
- EXTRA_LOCK_BUFFERS);
+ (ExtraBuffers ? EXTRA_LOCK_BUFFERS : 0));
BytesToCopy =
MIN( RecvReq->BufferArray[0].len, BytesAvailable );
@@ -356,7 +315,7 @@
if( Map[0].Mdl ) {
/* Copy the address */
- if( Map[1].Mdl && Map[2].Mdl ) {
+ if( ExtraBuffers && Map[1].Mdl && Map[2].Mdl ) {
AFD_DbgPrint(MID_TRACE,("Checking TAAddressCount\n"));
if( DatagramRecv->Address->TAAddressCount != 1 ) {
@@ -491,7 +450,7 @@
&DatagramRecv->ListEntry);
}
- if (IsListEmpty(&FCB->DatagramList))
+ if (!IsListEmpty(&FCB->DatagramList))
{
FCB->PollState |= AFD_EVENT_RECEIVE;
FCB->PollStatus[FD_READ_BIT] = STATUS_SUCCESS;
@@ -748,7 +707,7 @@
&DatagramRecv->ListEntry);
}
- if (IsListEmpty(&FCB->DatagramList))
+ if (!IsListEmpty(&FCB->DatagramList))
{
FCB->PollState |= AFD_EVENT_RECEIVE;
FCB->PollStatus[FD_READ_BIT] = STATUS_SUCCESS;
@@ -757,7 +716,7 @@
else
FCB->PollState &= ~AFD_EVENT_RECEIVE;
- UnlockBuffers(RecvReq->BufferArray, RecvReq->BufferCount, FALSE);
+ UnlockBuffers(RecvReq->BufferArray, RecvReq->BufferCount, TRUE);
return UnlockAndMaybeComplete(FCB, Status, Irp, Irp->IoStatus.Information);
}
@@ -766,7 +725,7 @@
AFD_DbgPrint(MID_TRACE,("Nonblocking\n"));
Status = STATUS_CANT_WAIT;
FCB->PollState &= ~AFD_EVENT_RECEIVE;
- UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, FALSE );
+ UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, TRUE );
return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
}
else
Modified: trunk/reactos/drivers/network/afd/include/afd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/includ…
==============================================================================
--- trunk/reactos/drivers/network/afd/include/afd.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/include/afd.h [iso-8859-1] Mon Jul 18 11:27:01 2011
@@ -316,6 +316,7 @@
VOID NTAPI AfdCancelHandler(PDEVICE_OBJECT DeviceObject,
PIRP Irp);
VOID RetryDisconnectCompletion(PAFD_FCB FCB);
+BOOLEAN CheckUnlockExtraBuffers(PAFD_FCB FCB, PIO_STACK_LOCATION IrpSp);
/* read.c */