connect: Allow async connections, and assume that concurrent operations

(like write) can happen.
main: Allow empty EaInfo in open, re: async select and the special control
socket.
read + write: assertions
tdi: don't wait for connect to return, remove event.

svn path=/trunk/; revision=11876
This commit is contained in:
Art Yerkes 2004-11-30 04:49:50 +00:00
parent 38ac0afdbb
commit 6b4f09638b
5 changed files with 54 additions and 49 deletions

View file

@ -1,4 +1,4 @@
/* $Id: connect.c,v 1.5 2004/11/21 20:54:52 arty Exp $
/* $Id: connect.c,v 1.6 2004/11/30 04:49:50 arty Exp $
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/net/afd/afd/connect.c
@ -53,10 +53,9 @@ NTSTATUS DDKAPI StreamSocketConnectComplete
AFD_DbgPrint(MID_TRACE,("Called: FCB %x, FO %x\n",
Context, FCB->FileObject));
/* Check the result of the connect operation */
/* Since the previous does not return until we come through here, we do
* not need to relock. */
/* if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp ); */
/* I was wrong about this before as we can have pending writes to a not
* yet connected socket */
if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp, FALSE );
AFD_DbgPrint(MID_TRACE,("Irp->IoStatus.Status = %x\n",
Irp->IoStatus.Status));
@ -118,7 +117,7 @@ NTSTATUS DDKAPI StreamSocketConnectComplete
Status = STATUS_SUCCESS;
}
/* SocketStateUnlock( FCB ); */
SocketStateUnlock( FCB );
AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status));
@ -202,6 +201,10 @@ AfdStreamSocketConnect(PDEVICE_OBJECT DeviceObject, PIRP Irp,
FCB );
ExFreePool( TargetAddress );
AFD_DbgPrint(MID_TRACE,("Queueing IRP %x\n", Irp));
return LeaveIrpUntilLater( FCB, Irp, FUNCTION_CONNECT );
} else Status = STATUS_NO_MEMORY;
break;

View file

@ -1,4 +1,4 @@
/* $Id: main.c,v 1.13 2004/11/21 20:54:52 arty Exp $
/* $Id: main.c,v 1.14 2004/11/30 04:49:50 arty Exp $
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/net/afd/afd/main.c
@ -47,9 +47,9 @@ AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
PFILE_OBJECT FileObject;
PAFD_DEVICE_EXTENSION DeviceExt;
PFILE_FULL_EA_INFORMATION EaInfo;
PAFD_CREATE_PACKET ConnectInfo;
PAFD_CREATE_PACKET ConnectInfo = NULL;
ULONG EaLength;
PWCHAR EaInfoValue;
PWCHAR EaInfoValue = NULL;
UINT Disposition, i;
AFD_DbgPrint(MID_TRACE,
@ -62,23 +62,19 @@ AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
Irp->IoStatus.Information = 0;
EaInfo = Irp->AssociatedIrp.SystemBuffer;
ConnectInfo = (PAFD_CREATE_PACKET)(EaInfo->EaName + EaInfo->EaNameLength + 1);
EaInfoValue = (PWCHAR)(((PCHAR)ConnectInfo) + sizeof(AFD_CREATE_PACKET));
if(!EaInfo) {
AFD_DbgPrint(MIN_TRACE, ("No EA Info in IRP.\n"));
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
IoCompleteRequest( Irp, IO_NO_INCREMENT );
return STATUS_INVALID_PARAMETER;
if( EaInfo ) {
ConnectInfo = (PAFD_CREATE_PACKET)(EaInfo->EaName + EaInfo->EaNameLength + 1);
EaInfoValue = (PWCHAR)(((PCHAR)ConnectInfo) + sizeof(AFD_CREATE_PACKET));
EaLength = sizeof(FILE_FULL_EA_INFORMATION) +
EaInfo->EaNameLength +
EaInfo->EaValueLength;
AFD_DbgPrint(MID_TRACE,("EaInfo: %x, EaInfoValue: %x\n",
EaInfo, EaInfoValue));
}
EaLength = sizeof(FILE_FULL_EA_INFORMATION) +
EaInfo->EaNameLength +
EaInfo->EaValueLength;
AFD_DbgPrint(MID_TRACE,("EaInfo: %x, EaInfoValue: %x\n",
EaInfo, EaInfoValue));
AFD_DbgPrint(MID_TRACE,("About to allocate the new FCB\n"));
FCB = ExAllocatePool(NonPagedPool, sizeof(AFD_FCB));
@ -88,11 +84,11 @@ AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
return STATUS_NO_MEMORY;
}
AFD_DbgPrint(MID_TRACE,("Initializing the new FCB @ %x (FileObject %x Flags %x)\n", FCB, FileObject, ConnectInfo->EndpointFlags));
AFD_DbgPrint(MID_TRACE,("Initializing the new FCB @ %x (FileObject %x Flags %x)\n", FCB, FileObject, ConnectInfo ? ConnectInfo->EndpointFlags : 0));
RtlZeroMemory( FCB, sizeof( *FCB ) );
FCB->Flags = ConnectInfo->EndpointFlags;
FCB->Flags = ConnectInfo ? ConnectInfo->EndpointFlags : 0;
FCB->State = SOCKET_STATE_CREATED;
FCB->FileObject = FileObject;
FCB->DeviceExt = DeviceExt;
@ -111,24 +107,29 @@ AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
AFD_DbgPrint(MID_TRACE,("%x: Checking command channel\n", FCB));
FCB->TdiDeviceName.Length = ConnectInfo->SizeOfTransportName;
FCB->TdiDeviceName.MaximumLength = FCB->TdiDeviceName.Length;
FCB->TdiDeviceName.Buffer =
ExAllocatePool( NonPagedPool, FCB->TdiDeviceName.Length );
RtlCopyMemory( FCB->TdiDeviceName.Buffer,
ConnectInfo->TransportName,
FCB->TdiDeviceName.Length );
if( ConnectInfo ) {
FCB->TdiDeviceName.Length = ConnectInfo->SizeOfTransportName;
FCB->TdiDeviceName.MaximumLength = FCB->TdiDeviceName.Length;
FCB->TdiDeviceName.Buffer =
ExAllocatePool( NonPagedPool, FCB->TdiDeviceName.Length );
RtlCopyMemory( FCB->TdiDeviceName.Buffer,
ConnectInfo->TransportName,
FCB->TdiDeviceName.Length );
if( !FCB->TdiDeviceName.Buffer ) {
ExFreePool(FCB);
AFD_DbgPrint(MID_TRACE,("Could not copy target string\n"));
Irp->IoStatus.Status = STATUS_NO_MEMORY;
IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
return STATUS_NO_MEMORY;
if( !FCB->TdiDeviceName.Buffer ) {
ExFreePool(FCB);
AFD_DbgPrint(MID_TRACE,("Could not copy target string\n"));
Irp->IoStatus.Status = STATUS_NO_MEMORY;
IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
return STATUS_NO_MEMORY;
}
AFD_DbgPrint(MID_TRACE,("Success: %s %wZ\n",
EaInfo->EaName, &FCB->TdiDeviceName));
} else {
AFD_DbgPrint(MID_TRACE,("Success: Control connection\n"));
}
AFD_DbgPrint(MID_TRACE,("Success: %s %wZ\n",
EaInfo->EaName, &FCB->TdiDeviceName));
FileObject->FsContext = FCB;
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );

View file

@ -1,4 +1,4 @@
/* $Id: read.c,v 1.12 2004/11/21 20:54:52 arty Exp $
/* $Id: read.c,v 1.13 2004/11/30 04:49:50 arty Exp $
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/net/afd/afd/read.c
@ -78,7 +78,9 @@ NTSTATUS DDKAPI ReceiveComplete
UINT TotalBytesCopied = 0;
AFD_DbgPrint(MID_TRACE,("Called\n"));
ASSERT_IRQL(APC_LEVEL);
if( !SocketAcquireStateLock( FCB ) ) return Status;
FCB->ReceiveIrp.InFlightRequest = NULL;

View file

@ -286,7 +286,6 @@ NTSTATUS TdiConnect(
PDEVICE_OBJECT DeviceObject;
IO_STATUS_BLOCK Iosb;
NTSTATUS Status;
KEVENT Event;
AFD_DbgPrint(MAX_TRACE, ("Called\n"));
@ -294,12 +293,10 @@ NTSTATUS TdiConnect(
DeviceObject = IoGetRelatedDeviceObject(ConnectionObject);
KeInitializeEvent(&Event, NotificationEvent, FALSE);
*Irp = TdiBuildInternalDeviceControlIrp(TDI_CONNECT, /* Sub function */
DeviceObject, /* Device object */
ConnectionObject, /* File object */
&Event, /* Event */
NULL, /* Event */
&Iosb); /* Status */
if (!*Irp) {
return STATUS_INSUFFICIENT_RESOURCES;
@ -314,7 +311,7 @@ NTSTATUS TdiConnect(
RemoteAddress, /* Request connection information */
RemoteAddress); /* Return connection information */
Status = TdiCall(*Irp, DeviceObject, &Event, &Iosb);
Status = TdiCall(*Irp, DeviceObject, NULL, &Iosb);
return Status;
}

View file

@ -1,4 +1,4 @@
/* $Id: write.c,v 1.12 2004/11/21 20:54:52 arty Exp $
/* $Id: write.c,v 1.13 2004/11/30 04:49:50 arty Exp $
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/net/afd/afd/write.c
@ -30,6 +30,8 @@ NTSTATUS DDKAPI SendComplete
Irp->IoStatus.Status,
Irp->IoStatus.Information));
ASSERT_IRQL(APC_LEVEL);
if( !SocketAcquireStateLock( FCB ) ) return Status;
FCB->SendIrp.InFlightRequest = NULL;