Author: cgutman
Date: Mon Aug 3 05:41:34 2009
New Revision: 42358
URL:
http://svn.reactos.org/svn/reactos?rev=42358&view=rev
Log:
- 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)
Modified:
trunk/reactos/drivers/network/afd/afd/bind.c
trunk/reactos/drivers/network/afd/afd/connect.c
trunk/reactos/drivers/network/afd/afd/main.c
trunk/reactos/drivers/network/afd/afd/tdi.c
Modified: trunk/reactos/drivers/network/afd/afd/bind.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/bi…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/bind.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/bind.c [iso-8859-1] Mon Aug 3 05:41:34 2009
@@ -32,11 +32,6 @@
FCB->LocalAddress,
&FCB->AddressFile.Handle,
&FCB->AddressFile.Object );
-
- if (NT_SUCCESS(Status))
- {
- ObReferenceObject(FCB->AddressFile.Object);
- }
AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status));
Modified: trunk/reactos/drivers/network/afd/afd/connect.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/co…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/connect.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/connect.c [iso-8859-1] Mon Aug 3 05:41:34 2009
@@ -29,11 +29,6 @@
FCB->Connection.Object );
}
- if (NT_SUCCESS(Status))
- {
- ObReferenceObject(FCB->Connection.Object);
- }
-
return Status;
}
Modified: trunk/reactos/drivers/network/afd/afd/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/ma…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/main.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/main.c [iso-8859-1] Mon Aug 3 05:41:34 2009
@@ -96,6 +96,8 @@
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,14 +224,20 @@
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 );
Modified: trunk/reactos/drivers/network/afd/afd/tdi.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/td…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/tdi.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/tdi.c [iso-8859-1] Mon Aug 3 05:41:34 2009
@@ -146,30 +146,12 @@
}
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,