mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
- Check if the handle is valid before closing it
- Remove (unused) TdiCloseDevice - Don't reference the Connection/Address File object twice (it is already referenced in TdiOpenDevice) svn path=/trunk/; revision=42358
This commit is contained in:
parent
7d6218e65b
commit
aee54b26cf
4 changed files with 11 additions and 31 deletions
|
@ -33,11 +33,6 @@ NTSTATUS WarmSocketForBind( PAFD_FCB FCB ) {
|
|||
&FCB->AddressFile.Handle,
|
||||
&FCB->AddressFile.Object );
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
ObReferenceObject(FCB->AddressFile.Object);
|
||||
}
|
||||
|
||||
AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status));
|
||||
|
||||
return Status;
|
||||
|
|
|
@ -29,11 +29,6 @@ NTSTATUS WarmSocketForConnection( PAFD_FCB FCB ) {
|
|||
FCB->Connection.Object );
|
||||
}
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
ObReferenceObject(FCB->Connection.Object);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,6 +96,8 @@ AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
FCB->DeviceExt = DeviceExt;
|
||||
FCB->Recv.Size = DEFAULT_RECEIVE_WINDOW_SIZE;
|
||||
FCB->Send.Size = DEFAULT_SEND_WINDOW_SIZE;
|
||||
FCB->AddressFile.Handle = INVALID_HANDLE_VALUE;
|
||||
FCB->Connection.Handle = INVALID_HANDLE_VALUE;
|
||||
|
||||
KeInitializeSpinLock( &FCB->SpinLock );
|
||||
ExInitializeFastMutex( &FCB->Mutex );
|
||||
|
@ -222,15 +224,21 @@ VOID CleanupSocket( PAFD_FCB FCB ) {
|
|||
FCB->RemoteAddress = NULL;
|
||||
}
|
||||
if( FCB->Connection.Object ) {
|
||||
ZwClose(FCB->Connection.Handle);
|
||||
ObDereferenceObject(FCB->Connection.Object);
|
||||
FCB->Connection.Object = NULL;
|
||||
}
|
||||
if( FCB->AddressFile.Object ) {
|
||||
ZwClose(FCB->AddressFile.Handle);
|
||||
ObDereferenceObject(FCB->AddressFile.Object);
|
||||
FCB->AddressFile.Object = NULL;
|
||||
}
|
||||
if( FCB->AddressFile.Handle != INVALID_HANDLE_VALUE ) {
|
||||
ZwClose(FCB->AddressFile.Handle);
|
||||
FCB->AddressFile.Handle = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
if( FCB->Connection.Handle != INVALID_HANDLE_VALUE ) {
|
||||
ZwClose(FCB->Connection.Handle);
|
||||
FCB->Connection.Handle = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
SocketStateUnlock( FCB );
|
||||
}
|
||||
|
|
|
@ -146,31 +146,13 @@ static NTSTATUS TdiOpenDevice(
|
|||
}
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
*Handle = NULL;
|
||||
*Handle = INVALID_HANDLE_VALUE;
|
||||
*Object = NULL;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS TdiCloseDevice(
|
||||
HANDLE Handle,
|
||||
PFILE_OBJECT FileObject)
|
||||
{
|
||||
AFD_DbgPrint(MAX_TRACE, ("Called. Handle (0x%X) FileObject (0x%X)\n",
|
||||
Handle, FileObject));
|
||||
|
||||
if (Handle)
|
||||
ZwClose(Handle);
|
||||
|
||||
if (FileObject)
|
||||
ObDereferenceObject(FileObject);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS TdiOpenAddressFile(
|
||||
PUNICODE_STRING DeviceName,
|
||||
PTRANSPORT_ADDRESS Name,
|
||||
|
|
Loading…
Reference in a new issue