TdiDispatchClose

TDI_STATUS
TdiDispatchClose (
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);

TdiDispatchClose calls the TDI driver’s close routine, which closes an address, connection endpoint, or control channel object.

Note The I/O subsystem calls TdiDispatchClose if it is removing its last reference to the file object handle. If it is closing the last handle for the object, it calls TdiDispatchCleanup.

Parameters

DeviceObject

Points to the device object that describes the TDI driver.

Irp

Points to the IRP the Windows NT kernel passes to TdiDispatchClose. The IRP major function code is IRP_MJ_CLOSE.

Return Value

TdiDispatchClose can return the following status codes:

STATUS_INVALID_CONNECTION
STATUS_INVALID_DEVICE_STATE
STATUS_INVALID_HANDLE
STATUS_PENDING
STATUS_SUCCESS

For more information about status codes, see Part II, Chapter 10.

Comments

IRP fields related to a close object request are:

IRP Component Meaning
IoStatus.Status Specifies the final status of the close object request.
IrpSp->MajorFunction Specifies IRP_MJ_CLOSE (or IRP_MJ_CLEANUP).
IrpSp->MinorFunction Unused.
IrpSp->FileObject Points to the file object for an address, connection endpoint, or control channel object.

A client closes an address object to cancel the use of a transport address. The associated internal driver close object function frees driver resources, completes any pending requests with the appropriate error code, and deregisters client event handlers registered on the address object. This function returns only when it has closed all connections and completed all requests.

When closing a connection, the client closes the associated connection endpoint object. The internal driver close object function for this operation frees associated TDI driver resources and immediately cancels any active connection associated with the endpoint. The client does not have to disassociate the connection endpoint from its address object before closing it. If necessary, the driver simulates the effects of a disassociation. After this function returns, the TDI driver can no longer deliver receive events to the client. The client can reuse the context that it associates with the connection endpoint.

A client can also close a control channel object, which shuts down the control channel it uses for communication when address and connection endpoint objects are not used. A close object request in this case has no effect on addresses and connection endpoints open to the TDI driver. Before returning, the associated internal driver close object function either cancels or completes any requests in progress on the control channel.

See Also

TdiDispatchCleanup