In the dispatch function, I queued an Irp and marked it
IoMarkIrpPending(). Then in the dispatch function itself, because of
someother action, I have decided not to pend the Irp and to complete
the Irp in dispatch function itself.

Now what should be the Irp.status.IoStatus and Irp.Status.Information.
Can I give relevant error like STATUS_INSUFFICIENT_RESOURCES or should
it be STATUS_PENDING. The return value of dispatch function and Irp
completion status should be same ? The dispactch function will return
STATUS_PENDING because I called IoMarkIrpPending.

Can I legitimately change my mind to complete the pended Irp in
dispatch function?

Re: Irp pending and not by David

David
Tue Aug 05 19:32:40 CDT 2003

Let me see if I get this right - You queue the Irp and call
IoMarkIrpPending() and then you decide you want to complete it here in the
dispatch function (or one of its subroutines)? Bad design. If you don't
know you need to pend an Irp, don't. That code will bite anyone who has to
maintain it. They will look and look and never see the "unpend" and
completion of the same Irp.

I guess you could look at what IoMarkIrpPending() and reverse it. You will
need to assume that no one else will have set the pending bit in your stack
location, but that should be fairly safe.

In summary, don't mark it pending until you know it will be pended and
STATUS_PENDING will be returned from the dispatch function. Clean up the
code and simplify it so it can be followed.

"Raj" <r_konjeti@mailcity.com> wrote in message
news:8509fde8.0308051519.7ede9c0@posting.google.com...
> In the dispatch function, I queued an Irp and marked it
> IoMarkIrpPending(). Then in the dispatch function itself, because of
> someother action, I have decided not to pend the Irp and to complete
> the Irp in dispatch function itself.
>
> Now what should be the Irp.status.IoStatus and Irp.Status.Information.
> Can I give relevant error like STATUS_INSUFFICIENT_RESOURCES or should
> it be STATUS_PENDING. The return value of dispatch function and Irp
> completion status should be same ? The dispactch function will return
> STATUS_PENDING because I called IoMarkIrpPending.
>
> Can I legitimately change my mind to complete the pended Irp in
> dispatch function?



Re: Irp pending and not by Alexander

Alexander
Tue Aug 05 20:45:52 CDT 2003

If you call IoMarkIrpPending(), you must return STATUS_PENDING.
Other than that, there is no restrictions. You can complete the Irp at any
moment, during your dispatch function call, or later. Make sure not to
complete IRP twice.

"Raj" <r_konjeti@mailcity.com> wrote in message
news:8509fde8.0308051519.7ede9c0@posting.google.com...
> In the dispatch function, I queued an Irp and marked it
> IoMarkIrpPending(). Then in the dispatch function itself, because of
> someother action, I have decided not to pend the Irp and to complete
> the Irp in dispatch function itself.
>
> Now what should be the Irp.status.IoStatus and Irp.Status.Information.
> Can I give relevant error like STATUS_INSUFFICIENT_RESOURCES or should
> it be STATUS_PENDING. The return value of dispatch function and Irp
> completion status should be same ? The dispactch function will return
> STATUS_PENDING because I called IoMarkIrpPending.
>
> Can I legitimately change my mind to complete the pended Irp in
> dispatch function?



Re: Irp pending and not by r_konjeti

r_konjeti
Wed Aug 06 14:04:55 CDT 2003

>>Bad design. If you don't know you need to pend an Irp, don't. That
code >>will bite anyone who has to maintain it.
>>In summary, don't mark it pending until you know it will be pended
and
>>STATUS_PENDING will be returned from the dispatch function. Clean
up the
>>code and simplify it so it can be followed.

The problem here is by the time I understand Irp need not be pended,
it may be completed. Here I receive an Irp in dispatch routine. I
queue it and mark Irp pending. Send request using new allocated Irp
and if this request fails for new allocated Irp, I want to complete
Irp received in Dispatch routine also with failure. If the request
with new alloc Irp succeeds, I want to wait for response. I get
response before I come from dispatch routine. So I have to pend it
before I send request. If sending request fails, I dont need to wait
for response and so I want to complete with Irp.IoStatus = Error
reason for not sending request.

I dont understand any better design for this. Any help is appreciated.

Thanks.

Re: Irp pending and not by Maxim

Maxim
Fri Aug 08 17:10:44 CDT 2003

> IoMarkIrpPending(). Then in the dispatch function itself, because of
> someother action, I have decided not to pend the Irp and to complete
> the Irp in dispatch function itself.

Do not call IoMarkIrpPending
Set Irp->IoStatus.Status to some status value, but NOT STATUS_PENDING, this
must be done before IoCompleteRequest.
Return the same status value.

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




Re: Irp pending and not by r_konjeti

r_konjeti
Mon Aug 11 11:13:20 CDT 2003

> Do not call IoMarkIrpPending
> Set Irp->IoStatus.Status to some status value, but NOT STATUS_PENDING, this
> must be done before IoCompleteRequest.
> Return the same status value.

I mark original dispatch Irp pending because I may need to wait for
response and complete dispatch Irp. It is so happening that my Irp is
completed before I return from my dispatch routine. But it doesn't
have to happen that way. So marking Irp pending may be needed.

What is wrong if

1. Mark dispacth Irp pending

2. But complete Irp in another function from queue(when dispatch
routine has not yet return)

3. Return STATUS_PENDING in dispatch routine.

My intention was to complete Irp after I return from dispatch routine.
But becoz my response is coming faster, I am completing before I
return. But I cannot gaurantee I always complete. So I am pending Irp.

Re: Irp pending and not by Alexei

Alexei
Mon Aug 11 22:09:57 CDT 2003

Yes, you can do this. There is no requirement to complete pending IRP after
dispatch function returns or complete it in another thread. IRP has to be
completed with some meaningful status, never assign STATUS_PENDING to
Irp->IoStatus.Status.

Alexei.

> What is wrong if
>
> 1. Mark dispacth Irp pending
>
> 2. But complete Irp in another function from queue(when dispatch
> routine has not yet return)
>
> 3. Return STATUS_PENDING in dispatch routine.
>
> My intention was to complete Irp after I return from dispatch routine.
> But becoz my response is coming faster, I am completing before I
> return. But I cannot gaurantee I always complete. So I am pending Irp.