TdiBuildDisconnect with TDI_DISCONNECT_RELEASE takes a long time

Hi all,
here I mostly ask you for advice.
I have a FILE_OBJECT (and a DEVICE_OBJECT), which describes a TCP connection.
At some point in time I wish to close this connection,
so I use:
TdiBuildInternalDeviceControlIrp(TDI_DISCONNECT, …)
and then
TdiBuildDisconnect(Irp, DeviceObject, FileObject,
NULL, NULL, NULL,

Hi all,
here I mostly ask you for advice.
I have a FILE_OBJECT (and a DEVICE_OBJECT), which describes a TCP connection.
At some point in time I wish to close this connection,
so I use:
TdiBuildInternalDeviceControlIrp(TDI_DISCONNECT, …)
and then
TdiBuildDisconnect(Irp, DeviceObject, FileObject,
NULL, NULL, NULL,
TDI_DISCONNECT_RELEASE,
…)
Then I issue IoCallDriver and wait for it complete.
Sometimes my wait lasts a long time - up to 1 minute.
The reason might be that there is a heavy ongoing traffic on the connection.

Is there anything I can do here?
Maybe I can use TDI_DISCONNECT_ABORT?

> Then I issue IoCallDriver and wait for it complete.

Sometimes my wait lasts a long time - up to 1 minute.
The reason might be that there is a heavy ongoing traffic on the connection.

You send TDI_DISCONNECT_RELEASE
You wait for its completion, and also for incoming ClientEventDisconnect.

When both events occur - the connection is gone.

This is the normal FIN-based 2-way graceful goodbye handshake of TCP.

Maybe I can use TDI_DISCONNECT_ABORT?

No, this is another song, this sends RST packet, the other side will have
“Connection reset by peer” error on the socket instead of graceful close.


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

Maxim,
this is exactly what happens!
I wait for TDI_DISCONNECT_RELEASE to complete.
During this wait I receive TDI_EVENT_DISCONNECT.
Then TDI_DISCONNECT_RELEASE also completes.

So basically, you say that it’s OK for these waits to take some time.