cleanup is taking years to fire

hi all,

i ve a following situation:
i ve a driver and a user mode app. user mode app issues custom ioctls to
the driver. the driver marks all these irps as pending and queues them in
an internal list. at leisure it process them and completes them. there is
also cleanup routine which checks for the pending irps in the queue and
cancels them by marking the status field to STATUS_CANCELLED and by
completing the irp.
problem occurs when the app issues an ioctl and abruptly terminates. i
expected that the cleanup would fire immediately since the process is
bieing terminated, but this doesnt happen. the process can be seen in
taskmanager for some time and then cleanup occurs which cancels all the
pending irps and then the process dies. why is cleanup taking so much of
time to fire ?

thanks
-Kjo

This is working as per design. The problem is that the IRPs you pended
in the queue are not cancellable.

The reason you see the process taking a long time to exit, is because IO
attempts to cancel all the IRPs on the thread list and wait for all of
them to complete before letting thread exit go through. However it does
have a timeout (to handle precisely drivers which don’t implement
cancel), which is about 5 minutes or so.
Since you don’t implement cancel, the full timeout is being reached
before IO is letting the thread exit go through, and the rundown of the
handle table which closes outstanding handles happens later - thereby
you get the cleanup, and complete the IRPs then.

The solution is to actually implement a cancel routine for each IRP &
not wait till cleanup. For Windows XP onwards you can use the
cancel-safe API library provided by IO.

Ravi

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: kjo [mailto:xxxxx@yahoo.com]
Sent: Thursday, October 17, 2002 11:31 AM
To: File Systems Developers
Subject: [ntfsd] cleanup is taking years to fire

hi all,

i ve a following situation:
i ve a driver and a user mode app. user mode app issues custom ioctls to
the driver. the driver marks all these irps as pending and queues them
in an internal list. at leisure it process them and completes them.
there is also cleanup routine which checks for the pending irps in the
queue and cancels them by marking the status field to STATUS_CANCELLED
and by completing the irp. problem occurs when the app issues an ioctl
and abruptly terminates. i expected that the cleanup would fire
immediately since the process is bieing terminated, but this doesnt
happen. the process can be seen in taskmanager for some time and then
cleanup occurs which cancels all the pending irps and then the process
dies. why is cleanup taking so much of time to fire ?

thanks
-Kjo


You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to %%email.unsub%%

Cleanup is not enough, you must register a cancel routine in each IRP.

Max

----- Original Message -----
From: “kjo”
To: “File Systems Developers”
Sent: Thursday, October 17, 2002 10:31 PM
Subject: [ntfsd] cleanup is taking years to fire

> hi all,
>
> i ve a following situation:
> i ve a driver and a user mode app. user mode app issues custom
ioctls to
> the driver. the driver marks all these irps as pending and queues
them in
> an internal list. at leisure it process them and completes them.
there is
> also cleanup routine which checks for the pending irps in the queue
and
> cancels them by marking the status field to STATUS_CANCELLED and by
> completing the irp.
> problem occurs when the app issues an ioctl and abruptly terminates.
i
> expected that the cleanup would fire immediately since the process
is
> bieing terminated, but this doesnt happen. the process can be seen
in
> taskmanager for some time and then cleanup occurs which cancels all
the
> pending irps and then the process dies. why is cleanup taking so
much of
> time to fire ?
>
> thanks
> -Kjo
>
> —
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to %%email.unsub%%
>

Just as a side-note here, the Windows 2000 build environment for the Windows
XP (and .NET) DDK contain a library of cancel safe queue routines that can
be linked and used on the earlier OS version.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: Ravisankar Pudipeddi [mailto:xxxxx@windows.microsoft.com]
Sent: Thursday, October 17, 2002 4:40 PM
To: File Systems Developers
Subject: [ntfsd] RE: cleanup is taking years to fire

This is working as per design. The problem is that the IRPs you pended
in the queue are not cancellable.

The reason you see the process taking a long time to exit, is because IO
attempts to cancel all the IRPs on the thread list and wait for all of
them to complete before letting thread exit go through. However it does
have a timeout (to handle precisely drivers which don’t implement
cancel), which is about 5 minutes or so.
Since you don’t implement cancel, the full timeout is being reached
before IO is letting the thread exit go through, and the rundown of the
handle table which closes outstanding handles happens later - thereby
you get the cleanup, and complete the IRPs then.

The solution is to actually implement a cancel routine for each IRP &
not wait till cleanup. For Windows XP onwards you can use the
cancel-safe API library provided by IO.

Ravi

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: kjo [mailto:xxxxx@yahoo.com]
Sent: Thursday, October 17, 2002 11:31 AM
To: File Systems Developers
Subject: [ntfsd] cleanup is taking years to fire

hi all,

i ve a following situation:
i ve a driver and a user mode app. user mode app issues custom ioctls to
the driver. the driver marks all these irps as pending and queues them
in an internal list. at leisure it process them and completes them.
there is also cleanup routine which checks for the pending irps in the
queue and cancels them by marking the status field to STATUS_CANCELLED
and by completing the irp. problem occurs when the app issues an ioctl
and abruptly terminates. i expected that the cleanup would fire
immediately since the process is bieing terminated, but this doesnt
happen. the process can be seen in taskmanager for some time and then
cleanup occurs which cancels all the pending irps and then the process
dies. why is cleanup taking so much of time to fire ?

thanks
-Kjo


You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to %%email.unsub%%