5.13 Closing a Transport Address or Control Channel

After closing any associated connection(s), a TDI client is ready to close an open transport address.

When a client no longer has any use for an open transport address or control channel, it must release that object as follows:

In a similar manner, a TDI client also can close any control channel it has opened in its underlying transport driver.

If the client opened the file object representing a control channel with a call to IoGetDeviceObjectPointer, it must pass the returned file object pointer to ObDereferenceObject to release the file object.

Then, the I/O Manager submits IRPs to the transport’s TdiDispatchCleanup and TdiDispatchClose routines.

These transport routines immediately close the transport address or control channel and free all associated client-specific transport driver resources. For example, TdiDispatchCleanup cancels any pending requests on a transport address that is being closed, deregisters any ClientEventXxx handlers on that address, and cleans up client-specific state for that address. If this client has released the last file handle for a particular transport address, the transport also releases internal state for that transport address.

After ZwClose returns to the client, it cannot submit a request to the underlying transport for the transport address or control channel it previously had open. The client-specific file object representing that address or control channel no longer exists.