xxxxx@hotmail.com wrote:
The application is blocking at READFILE call until the data
is received though I specified the overlapped structure with
an event. The ReadFile call is supposed to unblock.
Two things -
One, specifying the OVERLAPPED structure is not enough. You have to
have specified FILE_FLAG_OVERLAPPED on your CreateFile call. (And then
you’re required to provide the OVERLAPPED structure.)
Two, even if you got all that right, this is only a request, not a
demand. As long as no one in the stack returns control before passing
the IRP to a lower layer, any driver in the stack might be completing
the request “in line”. If the IRP is passed to IoCompleteRequest before
the top-level driver’s dispatch routine returns control to its caller –
which can happen for a ReadFile, if for example the required data is
already in a buffer or a cache somewhere – you will get the behavior
you’re describing.
If this seems confusing, think about what would happen if your dispatch
routine passed the IRP to IoCompleteRequest. This is a perfectly
reasonable thing to do in many cases. Well, the same thing can happen
in a lower layer, it’s just a few more nested procedure calls. Or for
that matter a lower layer can pass the IRP to a queueing routine, and
thence to a “start IO” routine or similar - but THAT routine can call
IoCompleteRequest. Again, it all happens in the context of the calling
thread, and there is no chance to “return before the IO is done”, so you
will see no computational activity in your calling thread in user mode
before the IO is done.
If this is unclear or seems incomplete in any way, please don’t hesitate
to ask for clarification.
— Jamie Hanrahan
Azius Developer Training http://www.azius.com/
Windows Driver Consulting and Training
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@hotmail.com
Sent: Friday, March 21, 2003 01:49
To: NT Developers Interest List
Subject: [ntdev] ReadFile with OVERLAPPED is blocking!! help
Hi,
In my functional driver,
In the read dispatch routine I am doing :
return (IoCallDriver(deviceExtension->LowerDeviceObject,
Irp)); I am *not* calling IoMarkIrpPending in the dispatch
routune. This IRP is not created by my driver. My driver does
not do queuing of IRPs and hence no startio routine. The
driver uses DIRECT IO.
In the completion routine i am doing:
if ( Irp->PendingReturned )
{
IoMarkIrpPending(Irp);
}
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = bytesTransferred;
//some cleanup
return STATUS_SUCCESS;
The application is blocking at READFILE call until the data
is received though I specified the overlapped structure with
an event. The ReadFile call is supposed to unblock.
Let me know where I am doing wrong.
Thanks in advance.
You are currently subscribed to ntdev as: xxxxx@cmkrnl.com
To unsubscribe send a blank email to xxxxx@lists.osr.com