RE: what we need to do When CancelIo request is made- in Application

Hi Mark

Thanks alot. My doubt is cleared .

Now I implemented the Cancel routine for the pended IRP . When the IRP is in
pended state , terminated the application . In this condition , I expected
the terminating thread to call "Cancel routine " which I set before . But it
was never going through cancel routine . Instead of that, completion routine
of the IRP is called which is completing the request . The status of IRP is
set to STATUS_CANCELLED . I guess when the application is terminated ,
first it calls the cancel routine if any set and cancels the IRP . Is that
right ?
Though I am issuing CancelIo seperately it never called cancel routine .

One more thing , I have two applications , one is win32 application and
other is MFC application . Both are using same thread code for sending
request to the device . When WaitForSingleObject is set with finite time in
both applications, the Win32 application is cancelling the pending IRP
properly , where as the MFC application does do that . Any idea what is
going on here . Or Do I need to do anything special ?

once again Thanks for being patient in answering my questions.

Thanks in advance
srinivas

-----Original Message-----
From: Mark Roddy [mailto:xxxxx@hollistech.com]
Sent: Sunday, September 09, 2001 4:44 PM
To: NT Developers Interest List
Subject: [ntdev] RE: what we need to do When CancelIo request is made in
Application

Srinivasa,

Your completion handler will get called.

VOID
IoSetCompletionRoutine(
IN PIRP Irp,
IN PIO_COMPLETION_ROUTINE CompletionRoutine,
IN PVOID Context,
IN BOOLEAN InvokeOnSuccess,
IN BOOLEAN InvokeOnError,
IN BOOLEAN InvokeOnCancel <---- what might this mean?
);

Your cancel routine is going to complete the IRP after setting it’s
status to STATUS_CANCELLED.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
Srinivasa Rao Deevi
Sent: Sunday, September 09, 2001 6:46 PM
To: NT Developers Interest List
Subject: [ntdev] RE: what we need to do When CancelIo request
is made in Application

Thanks alot for the reply Mark and Gary.

Ok . That means if the cancel routine is not set it will not
be cancelled and it will wait for 5 minutes to complete the
request .
if I set the cancel routine is set for the IRP , in the
cancel routine complete the request with status cancelled ,
will the completion routine is still called . Because , I
would have allocated some context memory structures and URB
structures which will be released when the completion routine
is called. When setting the cancel routine it is not possible
to pass all the parameters I need . How do I get rid of them
? If I don’t release them as I was doing in completion
routine it will be a memory leak . Do you guys agree with this ?

this is the doubt I have . I could not find much information on it .

Thanks in advance
srinivas

-----Original Message-----
From: Gary G. Little [mailto:xxxxx@inland.net]
Sent: Sunday, September 09, 2001 1:06 PM
To: NT Developers Interest List
Subject: [ntdev] RE: what we need to do When CancelIo request
is made in Application

Yes all IRPs for that thread are cancelled, well, it is
better said that their cancel routines will be called. If you
have not set a cancel routine for an IRP then that IRP will
not be cancelled. This will cause nasty-grams from driver
verifier and an unloadable driver.

Gary

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
Srinivasa Rao Deevi
Sent: Sunday, September 09, 2001 11:50 AM
To: NT Developers Interest List
Subject: [ntdev] RE: what we need to do When CancelIo request is
made
in Application

Hi Mark

Thanks for the reply.

Is that means when “CancelIo” call is made from the
application , all pended IRP’s Cancel routines are called for
that particular thread ? If there is no cacncel routine for
that particulat IRP what happens ? I could not find any
information related to this . Any help in this regard is
appreciated . I wanted to know what happens in case of
"Synchronization with out cancel routines " . I guess in this
case when ever these IRP’s are cancelled by the Io Manager
the completion routine of that IRPs pended should be called
because InvokeOnCancel bit is set . But When I tested this,
the cancelIo call did not call any cancellation of IRP and my
completion routine was never called until I close the handle
for the device . Am I missing something here ?

Thanks in advance
srinivas

-----Original Message-----
From: Mark Roddy [mailto:xxxxx@hollistech.com]
Sent: Saturday, September 08, 2001 6:53 PM
To: NT Developers Interest List
Subject: [ntdev] RE: what we need to do When CancelIo request
is made in Application

If you queue IRPs, marking the IRPs as pending and returning
STATUS_PENDING from the dispatch routine for those IRPs, then
the IoManager may attempt to perform cancel processing on
those IRPs, as a consequence of thread termination or
explicit thread action (CancelIo.) See the DDK for
documentation about IoSetCancelRoutine and related
documentation regarding cancel processing in drivers. The
idea is that your driver is responsible for satisfying the
notification that the originating application no longer is
interested in performing the request(s), typically by
dequeueing and completing the indicated IRP(s). It has to be
your driver in the case where you ‘pended’ the IRP, as only
your driver really knows where the IRP is queued, and how to
unqueue it and complete it.

> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Srinivasa Rao
> Deevi
> Sent: Saturday, September 08, 2001 9:37 PM
> To: NT Developers Interest List
> Subject: [ntdev] what we need to do When CancelIo request
is made in
> Application
>
>
> Hi all
>
> I have a doubt about “CancelIo” request . What we need to do in the
> driver level when we receive the request "CancelIo( Handle to the
> device ) ? can anybody tell me How this logic works ?
>
> Thanks in advance
> srinivas
>
> —
> You are currently subscribed to ntdev as: xxxxx@hollistech.com To
> unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
>


You are currently subscribed to ntdev as:
xxxxx@transilica.com To unsubscribe send a blank email to
leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@inland.net
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as:
xxxxx@transilica.com To unsubscribe send a blank email to
leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as:
xxxxx@hollistech.com To unsubscribe send a blank email to
leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@transilica.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com