From: Maxim S. Shatskih [maxim@storagecraft.com] Sent: Friday, August 13, 1999 4:50 PM To: ntdev@atria.com; Chris Cant Subject: Re: [ntdev] Pending IRPs The field will govern whether IoCompleteRequest() will schedule IopCompleteRequest() (this is a thread-specific part of IRP completion) as an APC or will rely on the top-level IO manager's IRP sending code in NtReadFile() etc to call IopCompleteRequest(). Violating the DDK rules mentioned by you will lead either to calling IopCompleteRequest() twice - a guaranteed BSOD - or by forgetting to call it at all - not a good thing too. There is a large discussion on it in Rajeev Nagar's book. Max ----- Original Message ----- From: Chris Cant To: Sent: Friday, August 13, 1999 6:03 PM Subject: [ntdev] Pending IRPs > Can someone clear up the use of the IRP PendingReturned flag? > > The DDK header says this about BOOLEAN PendingReturned; > // Pending returned - TRUE if pending was initially returned as the > // status for this packet. > > When exactly is PendingReturned set? Is it set when any driver in the stack > returns pending from its dispatch routine? > > It seems to be standard practice to include this code in an IRP completion > routine. I'm not sure why. > if(Irp->PendingReturned) > IoMarkIrpPending(Irp); > > If a completion routine decides that it wants to queue an IRP, then I can > see why it should call IoMarkIrpPending, but I cannot see why it needs to do > this in the normal case. > > IoMarkIrpPending just sets a flag in the current IRP stack location. > #define IoMarkIrpPending( Irp ) ( \ > IoGetCurrentIrpStackLocation( (Irp) )->Control |= SL_PENDING_RETURNED ) > > I suppose I want to know how the kernel uses this flag. > Is it so that the kernel knows if the execution context has changed, so that > it can do the right things when the IRP is completed? > > The documentation for IoMarkIrpPending says > "Unless a driver calls IoCompleteRequest from its Dispatch routine with a > given IRP or passes the IRP on to lower drivers, it must call > IoMarkIrpPending with the IRP. Otherwise, the I/O Manager attempts to > complete the IRP as soon as the Dispatch routine returns control." > > Does this mean that if I forget to complete an IRP in a dispatch routine > (and do not call IoMarkIrpPending) that the I/O Manager will indeed complete > the IRP for me? > > It seems as though there are three methods of indicating that an IRP is pending. > - Not calling IoCompleteRequest > - Calling IoMarkIrpPending > - return STATUS_PENDING > > Everyone usually does all three things. Are all three methods necessary? > > > Elsewhere the DDK indicates that it is possible to complete an IRP with a > Pending status. This seems a very unlikely thing to want to do. > > > PS I tried to see if this topic was covered in the archives. However there > seems to be no searchable index to the large archive files. > > Chris Cant > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > [ To unsubscribe, send email to ntdev-request@atria.com with body > UNSUBSCRIBE (the subject is ignored). ] > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ]