mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
- Merge aicom-network-fixes up to r35583
svn path=/trunk/; revision=35584
This commit is contained in:
parent
978a879fe9
commit
dbc052ab84
4 changed files with 50 additions and 25 deletions
|
@ -70,6 +70,8 @@ AfdBindSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
TdiBuildConnectionInfo( &FCB->AddressFrom,
|
TdiBuildConnectionInfo( &FCB->AddressFrom,
|
||||||
FCB->LocalAddress );
|
FCB->LocalAddress );
|
||||||
|
|
||||||
|
if( !FCB->AddressFrom ) return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp, 0, NULL );
|
||||||
|
|
||||||
AFD_DbgPrint(MID_TRACE,("Calling TdiReceiveDatagram\n"));
|
AFD_DbgPrint(MID_TRACE,("Calling TdiReceiveDatagram\n"));
|
||||||
|
|
||||||
Status = TdiReceiveDatagram
|
Status = TdiReceiveDatagram
|
||||||
|
|
|
@ -33,7 +33,6 @@ NTSTATUS WarmSocketForConnection( PAFD_FCB FCB ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS MakeSocketIntoConnection( PAFD_FCB FCB ) {
|
NTSTATUS MakeSocketIntoConnection( PAFD_FCB FCB ) {
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
/* Allocate the receive area and start receiving */
|
/* Allocate the receive area and start receiving */
|
||||||
FCB->Recv.Window =
|
FCB->Recv.Window =
|
||||||
|
@ -51,16 +50,14 @@ NTSTATUS MakeSocketIntoConnection( PAFD_FCB FCB ) {
|
||||||
|
|
||||||
FCB->State = SOCKET_STATE_CONNECTED;
|
FCB->State = SOCKET_STATE_CONNECTED;
|
||||||
|
|
||||||
Status = TdiReceive( &FCB->ReceiveIrp.InFlightRequest,
|
return TdiReceive( &FCB->ReceiveIrp.InFlightRequest,
|
||||||
FCB->Connection.Object,
|
FCB->Connection.Object,
|
||||||
TDI_RECEIVE_NORMAL,
|
TDI_RECEIVE_NORMAL,
|
||||||
FCB->Recv.Window,
|
FCB->Recv.Window,
|
||||||
FCB->Recv.Size,
|
FCB->Recv.Size,
|
||||||
&FCB->ReceiveIrp.Iosb,
|
&FCB->ReceiveIrp.Iosb,
|
||||||
ReceiveComplete,
|
ReceiveComplete,
|
||||||
FCB );
|
FCB );
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS NTAPI StreamSocketConnectComplete
|
static NTSTATUS NTAPI StreamSocketConnectComplete
|
||||||
|
@ -84,16 +81,16 @@ static NTSTATUS NTAPI StreamSocketConnectComplete
|
||||||
|
|
||||||
if( NT_SUCCESS(Irp->IoStatus.Status) ) {
|
if( NT_SUCCESS(Irp->IoStatus.Status) ) {
|
||||||
FCB->PollState |= AFD_EVENT_CONNECT | AFD_EVENT_SEND;
|
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));
|
AFD_DbgPrint(MID_TRACE,("Going to connected state %d\n", FCB->State));
|
||||||
PollReeval( FCB->DeviceExt, FCB->FileObject );
|
FCB->State = SOCKET_STATE_CONNECTED;
|
||||||
} else {
|
} else {
|
||||||
FCB->PollState |= AFD_EVENT_CONNECT_FAIL | AFD_EVENT_RECEIVE;
|
FCB->PollState |= AFD_EVENT_CONNECT_FAIL | AFD_EVENT_RECEIVE;
|
||||||
AFD_DbgPrint(MID_TRACE,("Going to bound state\n"));
|
AFD_DbgPrint(MID_TRACE,("Going to bound state\n"));
|
||||||
FCB->State = SOCKET_STATE_BOUND;
|
FCB->State = SOCKET_STATE_BOUND;
|
||||||
PollReeval( FCB->DeviceExt, FCB->FileObject );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PollReeval( FCB->DeviceExt, FCB->FileObject );
|
||||||
|
|
||||||
/* Succeed pending irps on the FUNCTION_CONNECT list */
|
/* Succeed pending irps on the FUNCTION_CONNECT list */
|
||||||
while( !IsListEmpty( &FCB->PendingIrpList[FUNCTION_CONNECT] ) ) {
|
while( !IsListEmpty( &FCB->PendingIrpList[FUNCTION_CONNECT] ) ) {
|
||||||
NextIrpEntry = RemoveHeadList(&FCB->PendingIrpList[FUNCTION_CONNECT]);
|
NextIrpEntry = RemoveHeadList(&FCB->PendingIrpList[FUNCTION_CONNECT]);
|
||||||
|
@ -199,6 +196,11 @@ AfdStreamSocketConnect(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
FCB->RemoteAddress =
|
FCB->RemoteAddress =
|
||||||
TaCopyTransportAddress( &ConnectReq->RemoteAddress );
|
TaCopyTransportAddress( &ConnectReq->RemoteAddress );
|
||||||
|
|
||||||
|
if( !FCB->RemoteAddress ) {
|
||||||
|
Status = STATUS_NO_MEMORY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if( FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS )
|
if( FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS )
|
||||||
{
|
{
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
|
|
|
@ -61,6 +61,13 @@ static VOID SatisfyPreAccept( PIRP Irp, PAFD_TDI_OBJECT_QELT Qelt ) {
|
||||||
|
|
||||||
IPAddr = (PTA_IP_ADDRESS)&ListenReceive->Address;
|
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",
|
AFD_DbgPrint(MID_TRACE,("IPAddr->TAAddressCount %d\n",
|
||||||
IPAddr->TAAddressCount));
|
IPAddr->TAAddressCount));
|
||||||
AFD_DbgPrint(MID_TRACE,("IPAddr->Address[0].AddressType %d\n",
|
AFD_DbgPrint(MID_TRACE,("IPAddr->Address[0].AddressType %d\n",
|
||||||
|
@ -172,7 +179,7 @@ NTSTATUS AfdListenSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
0, NULL );
|
0, NULL );
|
||||||
|
|
||||||
if( FCB->State != SOCKET_STATE_BOUND ) {
|
if( FCB->State != SOCKET_STATE_BOUND ) {
|
||||||
Status = STATUS_UNSUCCESSFUL;
|
Status = STATUS_INVALID_PARAMETER;
|
||||||
AFD_DbgPrint(MID_TRACE,("Could not listen an unbound socket\n"));
|
AFD_DbgPrint(MID_TRACE,("Could not listen an unbound socket\n"));
|
||||||
return UnlockAndMaybeComplete( FCB, Status, Irp, 0, NULL );
|
return UnlockAndMaybeComplete( FCB, Status, Irp, 0, NULL );
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,9 +130,13 @@ PAFD_WSABUF LockBuffers( PAFD_WSABUF Buf, UINT Count,
|
||||||
if( LockFailed ) {
|
if( LockFailed ) {
|
||||||
IoFreeMdl( MapBuf[i].Mdl );
|
IoFreeMdl( MapBuf[i].Mdl );
|
||||||
MapBuf[i].Mdl = NULL;
|
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 */
|
* pointers. This will allow the system to do proper alerting */
|
||||||
PAFD_HANDLE LockHandles( PAFD_HANDLE HandleArray, UINT HandleCount ) {
|
PAFD_HANDLE LockHandles( PAFD_HANDLE HandleArray, UINT HandleCount ) {
|
||||||
UINT i;
|
UINT i;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
PAFD_HANDLE FileObjects = ExAllocatePool
|
PAFD_HANDLE FileObjects = ExAllocatePool
|
||||||
( NonPagedPool, HandleCount * sizeof(AFD_HANDLE) );
|
( NonPagedPool, HandleCount * sizeof(AFD_HANDLE) );
|
||||||
|
@ -173,13 +177,21 @@ PAFD_HANDLE LockHandles( PAFD_HANDLE HandleArray, UINT HandleCount ) {
|
||||||
HandleArray[i].Status = 0;
|
HandleArray[i].Status = 0;
|
||||||
HandleArray[i].Events = HandleArray[i].Events;
|
HandleArray[i].Events = HandleArray[i].Events;
|
||||||
FileObjects[i].Handle = 0;
|
FileObjects[i].Handle = 0;
|
||||||
Status = ObReferenceObjectByHandle
|
if( !HandleArray[i].Handle ) continue;
|
||||||
( (PVOID)HandleArray[i].Handle,
|
if( NT_SUCCESS(Status) ) {
|
||||||
FILE_ALL_ACCESS,
|
Status = ObReferenceObjectByHandle
|
||||||
NULL,
|
( (PVOID)HandleArray[i].Handle,
|
||||||
KernelMode,
|
FILE_ALL_ACCESS,
|
||||||
(PVOID*)&FileObjects[i].Handle,
|
NULL,
|
||||||
NULL );
|
KernelMode,
|
||||||
|
(PVOID*)&FileObjects[i].Handle,
|
||||||
|
NULL );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !NT_SUCCESS(Status) ) {
|
||||||
|
UnlockHandles( FileObjects, HandleCount );
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FileObjects;
|
return FileObjects;
|
||||||
|
@ -312,12 +324,14 @@ NTSTATUS LeaveIrpUntilLater( PAFD_FCB FCB, PIRP Irp, UINT Function ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID SocketCalloutEnter( PAFD_FCB FCB ) {
|
VOID SocketCalloutEnter( PAFD_FCB FCB ) {
|
||||||
|
ASSERT(!FCB->Critical);
|
||||||
ASSERT(FCB->Locked);
|
ASSERT(FCB->Locked);
|
||||||
FCB->Critical = TRUE;
|
FCB->Critical = TRUE;
|
||||||
SocketStateUnlock( FCB );
|
SocketStateUnlock( FCB );
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID SocketCalloutLeave( PAFD_FCB FCB ) {
|
VOID SocketCalloutLeave( PAFD_FCB FCB ) {
|
||||||
|
ASSERT(FCB->Critical);
|
||||||
FCB->Critical = FALSE;
|
FCB->Critical = FALSE;
|
||||||
SocketAcquireStateLock( FCB );
|
SocketAcquireStateLock( FCB );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue