- Merge aicom-network-fixes up to r35583

svn path=/trunk/; revision=35584
This commit is contained in:
Cameron Gutman 2008-08-24 01:53:58 +00:00
parent 978a879fe9
commit dbc052ab84
4 changed files with 50 additions and 25 deletions

View file

@ -70,6 +70,8 @@ AfdBindSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
TdiBuildConnectionInfo( &FCB->AddressFrom,
FCB->LocalAddress );
if( !FCB->AddressFrom ) return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp, 0, NULL );
AFD_DbgPrint(MID_TRACE,("Calling TdiReceiveDatagram\n"));
Status = TdiReceiveDatagram

View file

@ -33,7 +33,6 @@ NTSTATUS WarmSocketForConnection( PAFD_FCB FCB ) {
}
NTSTATUS MakeSocketIntoConnection( PAFD_FCB FCB ) {
NTSTATUS Status;
/* Allocate the receive area and start receiving */
FCB->Recv.Window =
@ -51,7 +50,7 @@ NTSTATUS MakeSocketIntoConnection( PAFD_FCB FCB ) {
FCB->State = SOCKET_STATE_CONNECTED;
Status = TdiReceive( &FCB->ReceiveIrp.InFlightRequest,
return TdiReceive( &FCB->ReceiveIrp.InFlightRequest,
FCB->Connection.Object,
TDI_RECEIVE_NORMAL,
FCB->Recv.Window,
@ -59,8 +58,6 @@ NTSTATUS MakeSocketIntoConnection( PAFD_FCB FCB ) {
&FCB->ReceiveIrp.Iosb,
ReceiveComplete,
FCB );
return Status;
}
static NTSTATUS NTAPI StreamSocketConnectComplete
@ -84,16 +81,16 @@ static NTSTATUS NTAPI StreamSocketConnectComplete
if( NT_SUCCESS(Irp->IoStatus.Status) ) {
FCB->PollState |= AFD_EVENT_CONNECT | AFD_EVENT_SEND;
FCB->State = SOCKET_STATE_CONNECTED;
AFD_DbgPrint(MID_TRACE,("Going to connected state %d\n", FCB->State));
PollReeval( FCB->DeviceExt, FCB->FileObject );
FCB->State = SOCKET_STATE_CONNECTED;
} else {
FCB->PollState |= AFD_EVENT_CONNECT_FAIL | AFD_EVENT_RECEIVE;
AFD_DbgPrint(MID_TRACE,("Going to bound state\n"));
FCB->State = SOCKET_STATE_BOUND;
PollReeval( FCB->DeviceExt, FCB->FileObject );
}
PollReeval( FCB->DeviceExt, FCB->FileObject );
/* Succeed pending irps on the FUNCTION_CONNECT list */
while( !IsListEmpty( &FCB->PendingIrpList[FUNCTION_CONNECT] ) ) {
NextIrpEntry = RemoveHeadList(&FCB->PendingIrpList[FUNCTION_CONNECT]);
@ -199,6 +196,11 @@ AfdStreamSocketConnect(PDEVICE_OBJECT DeviceObject, PIRP Irp,
FCB->RemoteAddress =
TaCopyTransportAddress( &ConnectReq->RemoteAddress );
if( !FCB->RemoteAddress ) {
Status = STATUS_NO_MEMORY;
break;
}
if( FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS )
{
Status = STATUS_SUCCESS;

View file

@ -61,6 +61,13 @@ static VOID SatisfyPreAccept( PIRP Irp, PAFD_TDI_OBJECT_QELT Qelt ) {
IPAddr = (PTA_IP_ADDRESS)&ListenReceive->Address;
if( !IPAddr ) {
if( Irp->MdlAddress ) UnlockRequest( Irp, IoGetCurrentIrpStackLocation( Irp ) );
Irp->IoStatus.Status = STATUS_NO_MEMORY;
Irp->IoStatus.Information = 0;
IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
}
AFD_DbgPrint(MID_TRACE,("IPAddr->TAAddressCount %d\n",
IPAddr->TAAddressCount));
AFD_DbgPrint(MID_TRACE,("IPAddr->Address[0].AddressType %d\n",
@ -172,7 +179,7 @@ NTSTATUS AfdListenSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
0, NULL );
if( FCB->State != SOCKET_STATE_BOUND ) {
Status = STATUS_UNSUCCESSFUL;
Status = STATUS_INVALID_PARAMETER;
AFD_DbgPrint(MID_TRACE,("Could not listen an unbound socket\n"));
return UnlockAndMaybeComplete( FCB, Status, Irp, 0, NULL );
}

View file

@ -130,8 +130,12 @@ PAFD_WSABUF LockBuffers( PAFD_WSABUF Buf, UINT Count,
if( LockFailed ) {
IoFreeMdl( MapBuf[i].Mdl );
MapBuf[i].Mdl = NULL;
LockFailed = FALSE;
ExFreePool( NewBuf );
return NULL;
}
} else {
ExFreePool( NewBuf );
return NULL;
}
}
}
@ -164,7 +168,7 @@ VOID UnlockBuffers( PAFD_WSABUF Buf, UINT Count, BOOL Address ) {
* pointers. This will allow the system to do proper alerting */
PAFD_HANDLE LockHandles( PAFD_HANDLE HandleArray, UINT HandleCount ) {
UINT i;
NTSTATUS Status;
NTSTATUS Status = STATUS_SUCCESS;
PAFD_HANDLE FileObjects = ExAllocatePool
( NonPagedPool, HandleCount * sizeof(AFD_HANDLE) );
@ -173,6 +177,8 @@ PAFD_HANDLE LockHandles( PAFD_HANDLE HandleArray, UINT HandleCount ) {
HandleArray[i].Status = 0;
HandleArray[i].Events = HandleArray[i].Events;
FileObjects[i].Handle = 0;
if( !HandleArray[i].Handle ) continue;
if( NT_SUCCESS(Status) ) {
Status = ObReferenceObjectByHandle
( (PVOID)HandleArray[i].Handle,
FILE_ALL_ACCESS,
@ -181,6 +187,12 @@ PAFD_HANDLE LockHandles( PAFD_HANDLE HandleArray, UINT HandleCount ) {
(PVOID*)&FileObjects[i].Handle,
NULL );
}
}
if( !NT_SUCCESS(Status) ) {
UnlockHandles( FileObjects, HandleCount );
return NULL;
}
return FileObjects;
}
@ -312,12 +324,14 @@ NTSTATUS LeaveIrpUntilLater( PAFD_FCB FCB, PIRP Irp, UINT Function ) {
}
VOID SocketCalloutEnter( PAFD_FCB FCB ) {
ASSERT(!FCB->Critical);
ASSERT(FCB->Locked);
FCB->Critical = TRUE;
SocketStateUnlock( FCB );
}
VOID SocketCalloutLeave( PAFD_FCB FCB ) {
ASSERT(FCB->Critical);
FCB->Critical = FALSE;
SocketAcquireStateLock( FCB );
}