Author: arty
Date: Tue Aug 19 01:06:43 2008
New Revision: 35447
URL:
http://svn.reactos.org/svn/reactos?rev=35447&view=rev
Log:
Merge aicom-network-fixes up to 35446.
I (arty) modified the new printing in msafd to be conditional, so as not to
be accused of causing unnecessary spew.
Modified:
trunk/reactos/dll/win32/msafd/misc/dllmain.c
trunk/reactos/drivers/network/afd/afd/connect.c
trunk/reactos/drivers/network/afd/afd/info.c
trunk/reactos/drivers/network/afd/afd/listen.c
trunk/reactos/drivers/network/afd/afd/lock.c
trunk/reactos/drivers/network/afd/afd/read.c
trunk/reactos/drivers/network/afd/afd/select.c
trunk/reactos/drivers/network/afd/afd/tdi.c
trunk/reactos/include/ddk/tdikrnl.h
trunk/reactos/lib/drivers/ip/transport/datagram/datagram.c
Modified: trunk/reactos/dll/win32/msafd/misc/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/dllma…
==============================================================================
--- trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] Tue Aug 19 01:06:43 2008
@@ -285,10 +285,12 @@
if( ReturnedBytes ) *ReturnedBytes = Received; break;
case STATUS_END_OF_FILE: *Errno = WSAESHUTDOWN; break;
case STATUS_PENDING: *Errno = WSA_IO_PENDING; break;
- case STATUS_BUFFER_OVERFLOW: *Errno = WSAEMSGSIZE; break;
- case STATUS_INSUFFICIENT_RESOURCES: *Errno = WSA_NOT_ENOUGH_MEMORY; break;
- case STATUS_INVALID_CONNECTION: *Errno = WSAEAFNOSUPPORT; break;
- case STATUS_REMOTE_NOT_LISTENING: *Errno = WSAECONNRESET; break;
+ case STATUS_BUFFER_OVERFLOW: AFD_DbgPrint(MID_TRACE,("MSAFD:
STATUS_BUFFER_TOO_SMALL/STATUS_BUFFER_OVERFLOW\n")); *Errno = WSAEMSGSIZE; break;
+ case STATUS_NO_MEMORY: /* Fall through to STATUS_INSUFFICIENT_RESOURCES */
+ case STATUS_INSUFFICIENT_RESOURCES: AFD_DbgPrint(MID_TRACE,("MSAFD:
STATUS_NO_MEMORY/STATUS_INSUFFICIENT_RESOURCES\n")); *Errno = WSA_NOT_ENOUGH_MEMORY;
break;
+ case STATUS_INVALID_CONNECTION: AFD_DbgPrint(MID_TRACE,("MSAFD:
STATUS_INVALID_CONNECTION\n")); *Errno = WSAEAFNOSUPPORT; break;
+ case STATUS_REMOTE_NOT_LISTENING: AFD_DbgPrint(MID_TRACE, ("MSAFD:
STATUS_REMOTE_NOT_LISTENING\n")); *Errno = WSAECONNRESET; break;
+ case STATUS_FILE_CLOSED: AFD_DbgPrint(MID_TRACE, ("MSAFD:
STATUS_FILE_CLOSED\n")); *Errno = WSAENOTSOCK; break;
default:
DbgPrint("MSAFD: Error %x is unknown\n", Status);
*Errno = WSAEINVAL; break;
Modified: trunk/reactos/drivers/network/afd/afd/connect.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/co…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/connect.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/connect.c [iso-8859-1] Tue Aug 19 01:06:43 2008
@@ -77,7 +77,7 @@
/* I was wrong about this before as we can have pending writes to a not
* yet connected socket */
- if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
+ if( !SocketAcquireStateLock( FCB ) ) return STATUS_FILE_CLOSED;
AFD_DbgPrint(MID_TRACE,("Irp->IoStatus.Status = %x\n",
Irp->IoStatus.Status));
@@ -108,7 +108,10 @@
if( NT_SUCCESS(Status) ) {
Status = MakeSocketIntoConnection( FCB );
- if( !NT_SUCCESS(Status) ) return Status;
+ if( !NT_SUCCESS(Status) ) {
+ SocketStateUnlock( FCB );
+ return Status;
+ }
if( !IsListEmpty( &FCB->PendingIrpList[FUNCTION_SEND] ) ) {
NextIrpEntry = RemoveHeadList(&FCB->PendingIrpList[FUNCTION_SEND]);
Modified: trunk/reactos/drivers/network/afd/afd/info.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/in…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/info.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/info.c [iso-8859-1] Tue Aug 19 01:06:43 2008
@@ -125,12 +125,20 @@
}
if( SysMdl ) {
- MmBuildMdlForNonPagedPool( SysMdl );
+ _SEH_TRY {
+ MmProbeAndLockPages( SysMdl, Irp->RequestorMode,
IoModifyAccess );
+ } _SEH_HANDLE {
+ AFD_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n"));
+ Status = _SEH_GetExceptionCode();
+ } _SEH_END;
+ } else Status = STATUS_NO_MEMORY;
+
+ if( NT_SUCCESS(Status) ) {
Status = TdiQueryInformation
( FCB->AddressFile.Object,
TDI_QUERY_CONNECTION_INFO,
SysMdl );
- } else Status = STATUS_NO_MEMORY;
+ }
if( NT_SUCCESS(Status) ) {
TransAddr =
@@ -142,14 +150,15 @@
RtlCopyMemory( TransAddr, ConnInfo->RemoteAddress,
TaLengthOfTransportAddress
( ConnInfo->RemoteAddress ) );
+ else Status = STATUS_INSUFFICIENT_RESOURCES;
if( ConnInfo ) ExFreePool( ConnInfo );
if( SysMdl ) IoFreeMdl( SysMdl );
if( TransAddr ) MmUnmapLockedPages( TransAddr, Mdl );
+ MmUnlockPages( Mdl );
+ IoFreeMdl( Mdl );
}
- /* MmUnlockPages( Mdl ); */
}
- /* IoFreeMdl( Mdl ); */
} else {
Status = STATUS_INSUFFICIENT_RESOURCES;
}
Modified: trunk/reactos/drivers/network/afd/afd/listen.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/li…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/listen.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/listen.c [iso-8859-1] Tue Aug 19 01:06:43 2008
@@ -83,19 +83,18 @@
( PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PVOID Context ) {
- NTSTATUS Status = STATUS_UNSUCCESSFUL;
+ NTSTATUS Status = STATUS_FILE_CLOSED;
PAFD_FCB FCB = (PAFD_FCB)Context;
PAFD_TDI_OBJECT_QELT Qelt;
- if ( Irp->Cancel ) {
- /* FIXME: is this anything else we need to do? */
- FCB->ListenIrp.InFlightRequest = NULL;
+ if( !SocketAcquireStateLock( FCB ) ) return Status;
+
+ FCB->ListenIrp.InFlightRequest = NULL;
+
+ if( Irp->Cancel ) {
+ SocketStateUnlock( FCB );
return STATUS_SUCCESS;
}
-
- if( !SocketAcquireStateLock( FCB ) ) return Status;
-
- FCB->ListenIrp.InFlightRequest = NULL;
if( FCB->State == SOCKET_STATE_CLOSED ) {
SocketStateUnlock( FCB );
Modified: trunk/reactos/drivers/network/afd/afd/lock.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/lo…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/lock.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/lock.c [iso-8859-1] Tue Aug 19 01:06:43 2008
@@ -262,7 +262,7 @@
NTSTATUS LostSocket( PIRP Irp ) {
- NTSTATUS Status = STATUS_INVALID_PARAMETER;
+ NTSTATUS Status = STATUS_FILE_CLOSED;
AFD_DbgPrint(MIN_TRACE,("Called.\n"));
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = Status;
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] Tue Aug 19 01:06:43 2008
@@ -449,7 +449,7 @@
AFD_DbgPrint(MID_TRACE,("Called on %x\n", FCB));
- if( !SocketAcquireStateLock( FCB ) ) return STATUS_UNSUCCESSFUL;
+ if( !SocketAcquireStateLock( FCB ) ) return STATUS_FILE_CLOSED;
FCB->ReceiveIrp.InFlightRequest = NULL;
Modified: trunk/reactos/drivers/network/afd/afd/select.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/se…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/select.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/select.c [iso-8859-1] Tue Aug 19 01:06:43 2008
@@ -277,6 +277,10 @@
(PAFD_EVENT_SELECT_INFO)LockRequest( Irp, IrpSp );
PAFD_FCB FCB = FileObject->FsContext;
+ if( !SocketAcquireStateLock( FCB ) ) {
+ return LostSocket( Irp );
+ }
+
if ( !EventSelectInfo ) {
return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp,
0, NULL );
@@ -284,10 +288,6 @@
AFD_DbgPrint(MID_TRACE,("Called (Event %x Triggers %x)\n",
EventSelectInfo->EventObject,
EventSelectInfo->Events));
-
- if( !SocketAcquireStateLock( FCB ) ) {
- return LostSocket( Irp );
- }
FCB->EventSelectTriggers = FCB->EventsFired = 0;
if( FCB->EventSelect ) ObDereferenceObject( FCB->EventSelect );
@@ -325,13 +325,13 @@
AFD_DbgPrint(MID_TRACE,("Called (FCB %x)\n", FCB));
+ if( !SocketAcquireStateLock( FCB ) ) {
+ return LostSocket( Irp );
+ }
+
if ( !EnumReq ) {
return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp,
0, NULL );
- }
-
- if( !SocketAcquireStateLock( FCB ) ) {
- return LostSocket( Irp );
}
EnumReq->PollEvents = FCB->PollState;
Modified: trunk/reactos/drivers/network/afd/afd/tdi.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/td…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/tdi.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/tdi.c [iso-8859-1] Tue Aug 19 01:06:43 2008
@@ -608,7 +608,7 @@
KeInitializeEvent(&Event, NotificationEvent, FALSE);
- Irp = TdiBuildInternalDeviceControlIrp(IOCTL_TCP_QUERY_INFORMATION, /* Sub function
*/
+ Irp = TdiBuildInternalDeviceControlIrp(TDI_QUERY_INFORMATION, /* Sub function
*/
DeviceObject, /* Device object
*/
ConnectionObject, /* File object
*/
&Event, /* Event */
Modified: trunk/reactos/include/ddk/tdikrnl.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/tdikrnl.h?rev=…
==============================================================================
--- trunk/reactos/include/ddk/tdikrnl.h [iso-8859-1] (original)
+++ trunk/reactos/include/ddk/tdikrnl.h [iso-8859-1] Tue Aug 19 01:06:43 2008
@@ -577,7 +577,7 @@
IrpSubFunction, DeviceObject, \
FileObject, Event, IoStatusBlock) \
IoBuildDeviceIoControlRequest( \
- 0x00000003, DeviceObject, \
+ IrpSubFunction, DeviceObject, \
NULL, 0, NULL, 0, \
TRUE, Event, IoStatusBlock)
Modified: trunk/reactos/lib/drivers/ip/transport/datagram/datagram.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/d…
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/datagram/datagram.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/transport/datagram/datagram.c [iso-8859-1] Tue Aug 19
01:06:43 2008
@@ -177,6 +177,7 @@
}
else
{
+ TcpipReleaseSpinLock(&AddrFile->Lock, OldIrql);
TI_DbgPrint(MAX_TRACE, ("Discarding datagram.\n"));
}