/* Allocate the receive area and start receiving */
FCB->Recv.Window =
- ExAllocatePool( NonPagedPool, FCB->Recv.Size );
+ ExAllocatePool( PagedPool, FCB->Recv.Size );
if( !FCB->Recv.Window ) return STATUS_NO_MEMORY;
FCB->Send.Window =
- ExAllocatePool( NonPagedPool, FCB->Send.Size );
+ ExAllocatePool( PagedPool, FCB->Send.Size );
if( !FCB->Send.Window ) {
- ExFreePool( FCB->Recv.Window );
+ ExFreePool( FCB->Recv.Window );
+ FCB->Recv.Window = NULL;
return STATUS_NO_MEMORY;
}
if( Status == STATUS_PENDING ) Status = STATUS_SUCCESS;
+ FCB->PollState |= AFD_EVENT_CONNECT | AFD_EVENT_SEND;
+ PollReeval( FCB->DeviceExt, FCB->FileObject );
+
return Status;
}
AFD_DbgPrint(MID_TRACE,("Called: FCB %x, FO %x\n",
Context, FCB->FileObject));
- if( Irp->Cancel ) {
- if( FCB ) FCB->ConnectIrp.InFlightRequest = NULL;
- return STATUS_CANCELLED;
- }
-
/* I was wrong about this before as we can have pending writes to a not
* yet connected socket */
- if( !SocketAcquireStateLock( FCB ) ) return STATUS_FILE_CLOSED;
+ if( !SocketAcquireStateLock( FCB ) )
+ return STATUS_FILE_CLOSED;
AFD_DbgPrint(MID_TRACE,("Irp->IoStatus.Status = %x\n",
Irp->IoStatus.Status));
FCB->ConnectIrp.InFlightRequest = NULL;
- if( NT_SUCCESS(Irp->IoStatus.Status) ) {
- FCB->PollState |= AFD_EVENT_CONNECT | AFD_EVENT_SEND;
- AFD_DbgPrint(MID_TRACE,("Going to connected state %d\n", FCB->State));
- FCB->State = SOCKET_STATE_CONNECTED;
- } else {
- FCB->PollState |= AFD_EVENT_CONNECT_FAIL | AFD_EVENT_RECEIVE;
+ if( FCB->State == SOCKET_STATE_CLOSED ) {
+ /* Cleanup our IRP queue because the FCB is being destroyed */
+ while( !IsListEmpty( &FCB->PendingIrpList[FUNCTION_CONNECT] ) ) {
+ NextIrpEntry = RemoveHeadList(&FCB->PendingIrpList[FUNCTION_CONNECT]);
+ NextIrp = CONTAINING_RECORD(NextIrpEntry, IRP, Tail.Overlay.ListEntry);
+ NextIrp->IoStatus.Status = STATUS_FILE_CLOSED;
+ NextIrp->IoStatus.Information = 0;
+ if( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) );
+ (void)IoSetCancelRoutine(NextIrp, NULL);
+ IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT );
+ }
+ SocketStateUnlock( FCB );
+ return STATUS_FILE_CLOSED;
+ }
+
+ if( !NT_SUCCESS(Irp->IoStatus.Status) ) {
+ FCB->PollState |= AFD_EVENT_CONNECT_FAIL;
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]);
NextIrp->IoStatus.Status = Status;
NextIrp->IoStatus.Information = 0;
if( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) );
+ (void)IoSetCancelRoutine(NextIrp, NULL);
IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT );
}
/* Return the socket object for ths request only if it is a connected or
stream type. */
-NTSTATUS STDCALL
+NTSTATUS NTAPI
AfdStreamSocketConnect(PDEVICE_OBJECT DeviceObject, PIRP Irp,
PIO_STACK_LOCATION IrpSp) {
NTSTATUS Status = STATUS_INVALID_PARAMETER;
if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
if( !(ConnectReq = LockRequest( Irp, IrpSp )) )
return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp,
- 0, NULL );
+ 0 );
AFD_DbgPrint(MID_TRACE,("Connect request:\n"));
#if 0
TaCopyTransportAddress( &ConnectReq->RemoteAddress );
if( FCB->LocalAddress ) {
- RtlZeroMemory( FCB->LocalAddress,
- TaLengthOfTransportAddress
- ( &ConnectReq->RemoteAddress ) );
-
- FCB->LocalAddress->TAAddressCount = 1;
- FCB->LocalAddress->Address[0].AddressType =
- ConnectReq->RemoteAddress.Address[0].AddressType;
- FCB->LocalAddress->Address[0].AddressLength =
- ConnectReq->RemoteAddress.Address[0].AddressLength;
-
Status = WarmSocketForBind( FCB );
if( NT_SUCCESS(Status) )
FCB->State = SOCKET_STATE_BOUND;
else
- return UnlockAndMaybeComplete( FCB, Status, Irp, 0, NULL );
+ return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
} else
return UnlockAndMaybeComplete
- ( FCB, STATUS_NO_MEMORY, Irp, 0, NULL );
+ ( FCB, STATUS_NO_MEMORY, Irp, 0 );
/* Drop through to SOCKET_STATE_BOUND */
break;
}
- return UnlockAndMaybeComplete( FCB, Status, Irp, 0, NULL );
+ return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
}