Author: cmihail
Date: Fri Jun 24 14:57:29 2011
New Revision: 52443
URL:
http://svn.reactos.org/svn/reactos?rev=52443&view=rev
Log:
[MSAFD]
- merge r52438
- Fail SIO_GET_EXTENSION_FUNCTION_POINTER
- Fixes the crash during ws2_32_winetest sock
[AFD]
- merge r52441
- Queue the user-mode connect IRP before calling TdiConnect to avoid a race if the
TDI_CONNECT IRP is completed before we get a chance to queue the user-mode IRP to accept
the connection
- Change the non-blocking TDI helper functions to always return STATUS_PENDING if the
completion function will be called to avoid duplicate handling of IRPs
Modified:
branches/GSoC_2011/TcpIpDriver/dll/win32/msafd/misc/dllmain.c
branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/connect.c
branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/lock.c
branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/tdi.c
branches/GSoC_2011/TcpIpDriver/drivers/network/afd/include/afd.h
Modified: branches/GSoC_2011/TcpIpDriver/dll/win32/msafd/misc/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/dll/win32…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/dll/win32/msafd/misc/dllmain.c [iso-8859-1] (original)
+++ branches/GSoC_2011/TcpIpDriver/dll/win32/msafd/misc/dllmain.c [iso-8859-1] Fri Jun 24
14:57:29 2011
@@ -1986,6 +1986,9 @@
*lpcbBytesReturned = sizeof(ULONG);
return NO_ERROR;
}
+ case SIO_GET_EXTENSION_FUNCTION_POINTER:
+ *lpErrno = WSAEINVAL;
+ return SOCKET_ERROR;
default:
*lpErrno = Socket->HelperData->WSHIoctl(Socket->HelperContext,
Handle,
Modified: branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/connect.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/drivers/n…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/connect.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/connect.c [iso-8859-1] Fri Jun
24 14:57:29 2011
@@ -520,24 +520,32 @@
TargetAddress->Options = FCB->ConnectOptions;
TargetAddress->OptionsLength = FCB->ConnectOptionsSize;
- Status = TdiConnect( &FCB->ConnectIrp.InFlightRequest,
- FCB->Connection.Object,
- TargetAddress,
- FCB->ConnectInfo,
- &FCB->ConnectIrp.Iosb,
- StreamSocketConnectComplete,
- FCB );
-
- ExFreePool(TargetAddress);
-
AFD_DbgPrint(MID_TRACE,("Queueing IRP %x\n", Irp));
DbgPrint("[AFD, AfdStreamSocketConnect] Queueing IRP %x\n",
Irp);
-
- if (Status == STATUS_PENDING)
+
+ FCB->State = SOCKET_STATE_CONNECTING;
+
+ AFD_DbgPrint(MID_TRACE,("Queueing IRP %x\n", Irp));
+ Status = QueueUserModeIrp( FCB, Irp, FUNCTION_CONNECT );
+ if (Status == STATUS_PENDING)
{
- FCB->State = SOCKET_STATE_CONNECTING;
- return LeaveIrpUntilLater(FCB, Irp, FUNCTION_CONNECT);
+ Status = TdiConnect( &FCB->ConnectIrp.InFlightRequest,
+ FCB->Connection.Object,
+ TargetAddress,
+ FCB->ConnectInfo,
+ &FCB->ConnectIrp.Iosb,
+ StreamSocketConnectComplete,
+ FCB );
}
+
+ if (Status != STATUS_PENDING)
+ FCB->State = SOCKET_STATE_BOUND;
+
+ ExFreePool(TargetAddress);
+
+ SocketStateUnlock(FCB);
+
+ return Status;
}
break;
Modified: branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/lock.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/drivers/n…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/lock.c [iso-8859-1] (original)
+++ branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/lock.c [iso-8859-1] Fri Jun 24
14:57:29 2011
@@ -358,13 +358,13 @@
return Status;
}
-NTSTATUS LeaveIrpUntilLater(PAFD_FCB FCB, PIRP Irp, UINT Function)
+NTSTATUS QueueUserModeIrp(PAFD_FCB FCB, PIRP Irp, UINT Function)
{
NTSTATUS Status;
/* Add the IRP to the queue in all cases (so AfdCancelHandler will work properly) */
InsertTailList( &FCB->PendingIrpList[Function],
- &Irp->Tail.Overlay.ListEntry );
+ &Irp->Tail.Overlay.ListEntry );
/* Acquire the cancel spin lock and check the cancel bit */
IoAcquireCancelSpinLock(&Irp->CancelIrql);
@@ -389,8 +389,17 @@
AfdCancelHandler(IoGetCurrentIrpStackLocation(Irp)->DeviceObject, Irp);
Status = STATUS_CANCELLED;
}
-
- SocketStateUnlock(FCB);
return Status;
}
+
+NTSTATUS LeaveIrpUntilLater(PAFD_FCB FCB, PIRP Irp, UINT Function)
+{
+ NTSTATUS Status;
+
+ Status = QueueUserModeIrp(FCB, Irp, Function);
+
+ SocketStateUnlock( FCB );
+
+ return Status;
+}
Modified: branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/tdi.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/drivers/n…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/tdi.c [iso-8859-1] (original)
+++ branches/GSoC_2011/TcpIpDriver/drivers/network/afd/afd/tdi.c [iso-8859-1] Fri Jun 24
14:57:29 2011
@@ -331,7 +331,6 @@
*/
{
PDEVICE_OBJECT DeviceObject;
- NTSTATUS Status;
AFD_DbgPrint(MAX_TRACE, ("Called\n"));
@@ -368,9 +367,9 @@
ConnectionCallInfo, /* Request connection information */
ConnectionReturnInfo); /* Return connection information */
- Status = TdiCall(*Irp, DeviceObject, NULL, Iosb);
-
- return Status;
+ TdiCall(*Irp, DeviceObject, NULL, Iosb);
+
+ return STATUS_PENDING;
}
@@ -388,7 +387,6 @@
{
PDEVICE_OBJECT DeviceObject;
IO_STATUS_BLOCK Iosb;
- NTSTATUS Status;
KEVENT Event;
PIRP Irp;
@@ -425,9 +423,7 @@
NULL,
AddressHandle);
- Status = TdiCall(Irp, DeviceObject, &Event, &Iosb);
-
- return Status;
+ return TdiCall(Irp, DeviceObject, &Event, &Iosb);
}
NTSTATUS TdiDisassociateAddressFile(
@@ -442,7 +438,6 @@
{
PDEVICE_OBJECT DeviceObject;
IO_STATUS_BLOCK Iosb;
- NTSTATUS Status;
KEVENT Event;
PIRP Irp;
@@ -475,9 +470,7 @@
NULL,
NULL);
- Status = TdiCall(Irp, DeviceObject, &Event, &Iosb);
-
- return Status;
+ return TdiCall(Irp, DeviceObject, &Event, &Iosb);
}
NTSTATUS TdiListen
@@ -499,7 +492,6 @@
*/
{
PDEVICE_OBJECT DeviceObject;
- NTSTATUS Status;
AFD_DbgPrint(MAX_TRACE, ("[AFD, TDIListen] Called\n"));
DbgPrint("[AFD, TDIListen] Called\n");
@@ -536,11 +528,9 @@
*RequestConnectionInfo, /* Request connection information */
*ReturnConnectionInfo); /* Return connection information */
- Status = TdiCall(*Irp, DeviceObject, NULL /* Don't wait for completion */, Iosb);
-
- DbgPrint("[AFD, TDIListen] Done. Status = 0x%x\n", Status);
-
- return Status;
+ TdiCall(*Irp, DeviceObject, NULL /* Don't wait for completion */, Iosb);
+
+ return STATUS_PENDING;
}
@@ -564,7 +554,6 @@
{
PDEVICE_OBJECT DeviceObject;
IO_STATUS_BLOCK Iosb;
- NTSTATUS Status;
KEVENT Event;
PIRP Irp;
@@ -602,9 +591,7 @@
Handler,
Context);
- Status = TdiCall(Irp, DeviceObject, &Event, &Iosb);
-
- return Status;
+ return TdiCall(Irp, DeviceObject, &Event, &Iosb);
}
@@ -685,7 +672,6 @@
{
PDEVICE_OBJECT DeviceObject;
IO_STATUS_BLOCK Iosb;
- NTSTATUS Status;
KEVENT Event;
PIRP Irp;
@@ -720,9 +706,7 @@
QueryType,
MdlBuffer);
- Status = TdiCall(Irp, DeviceObject, &Event, &Iosb);
-
- return Status;
+ return TdiCall(Irp, DeviceObject, &Event, &Iosb);
}
NTSTATUS TdiQueryInformationEx(
@@ -912,7 +896,6 @@
PVOID CompletionContext )
{
PDEVICE_OBJECT DeviceObject;
- NTSTATUS Status = STATUS_SUCCESS;
PMDL Mdl;
ASSERT(*Irp == NULL);
@@ -975,11 +958,11 @@
Flags, /* Flags */
BufferLength); /* Length of data */
- Status = TdiCall(*Irp, DeviceObject, NULL, Iosb);
+ TdiCall(*Irp, DeviceObject, NULL, Iosb);
/* Does not block... The MDL is deleted in the receive completion
routine. */
- return Status;
+ return STATUS_PENDING;
}
NTSTATUS TdiReceive(
@@ -992,7 +975,6 @@
PIO_COMPLETION_ROUTINE CompletionRoutine,
PVOID CompletionContext)
{
- NTSTATUS Status = STATUS_SUCCESS;
PDEVICE_OBJECT DeviceObject;
PMDL Mdl;
@@ -1043,7 +1025,7 @@
AFD_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n"));
IoFreeMdl(Mdl);
IoCompleteRequest(*Irp, IO_NO_INCREMENT);
- *Irp = NULL;
+ *Irp = NULL;
_SEH2_YIELD(return STATUS_INSUFFICIENT_RESOURCES);
} _SEH2_END;
@@ -1059,14 +1041,11 @@
BufferLength); /* Length of data */
- Status = TdiCall(*Irp, DeviceObject, NULL, Iosb);
+ TdiCall(*Irp, DeviceObject, NULL, Iosb);
/* Does not block... The MDL is deleted in the receive completion
routine. */
- AFD_DbgPrint(MID_TRACE,("Status %x Information %d\n",
- Status, Iosb->Information));
-
- return Status;
+ return STATUS_PENDING;
}
@@ -1093,7 +1072,6 @@
*/
{
PDEVICE_OBJECT DeviceObject;
- NTSTATUS Status;
PMDL Mdl;
ASSERT(*Irp == NULL);
@@ -1159,11 +1137,11 @@
Addr,
Flags); /* Length of data */
- Status = TdiCall(*Irp, DeviceObject, NULL, Iosb);
+ TdiCall(*Irp, DeviceObject, NULL, Iosb);
/* Does not block... The MDL is deleted in the receive completion
routine. */
- return Status;
+ return STATUS_PENDING;
}
@@ -1189,7 +1167,6 @@
*/
{
PDEVICE_OBJECT DeviceObject;
- NTSTATUS Status;
PMDL Mdl;
ASSERT(*Irp == NULL);
@@ -1256,11 +1233,11 @@
BufferLength, /* Bytes to send */
Addr); /* Address */
- Status = TdiCall(*Irp, DeviceObject, NULL, Iosb);
+ TdiCall(*Irp, DeviceObject, NULL, Iosb);
/* Does not block... The MDL is deleted in the send completion
routine. */
- return Status;
+ return STATUS_PENDING;
}
NTSTATUS TdiDisconnect(
@@ -1273,7 +1250,6 @@
PTDI_CONNECTION_INFORMATION RequestConnectionInfo,
PTDI_CONNECTION_INFORMATION ReturnConnectionInfo) {
PDEVICE_OBJECT DeviceObject;
- NTSTATUS Status;
KEVENT Event;
PIRP Irp;
@@ -1315,9 +1291,7 @@
RequestConnectionInfo, /* Indication of who to disconnect */
ReturnConnectionInfo); /* Indication of who disconnected */
- Status = TdiCall(Irp, DeviceObject, &Event, Iosb);
-
- return Status;
+ return TdiCall(Irp, DeviceObject, &Event, Iosb);
}
/* EOF */
Modified: branches/GSoC_2011/TcpIpDriver/drivers/network/afd/include/afd.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/drivers/n…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/drivers/network/afd/include/afd.h [iso-8859-1]
(original)
+++ branches/GSoC_2011/TcpIpDriver/drivers/network/afd/include/afd.h [iso-8859-1] Fri Jun
24 14:57:29 2011
@@ -302,10 +302,14 @@
PVOID LockRequest( PIRP Irp, PIO_STACK_LOCATION IrpSp );
VOID UnlockRequest( PIRP Irp, PIO_STACK_LOCATION IrpSp );
PVOID GetLockedData( PIRP Irp, PIO_STACK_LOCATION IrpSp );
+NTSTATUS LeaveIrpUntilLater( PAFD_FCB FCB, PIRP Irp, UINT Function );
+NTSTATUS QueueUserModeIrp(PAFD_FCB FCB, PIRP Irp, UINT Function);
+
+NTSTATUS LeaveIrpUntilLater(PAFD_FCB FCB, PIRP Irp, UINT Function);
+NTSTATUS QueueUserModeIrp(PAFD_FCB FCB, PIRP Irp, UINT Function);
/* main.c */
-NTSTATUS LeaveIrpUntilLater( PAFD_FCB FCB, PIRP Irp, UINT Function );
VOID DestroySocket( PAFD_FCB FCB );
VOID NTAPI AfdCancelHandler(PDEVICE_OBJECT DeviceObject,
PIRP Irp);