Discussion:
Trouble with InternetReadFile in async mode and WaitForSingleObject
(too old to reply)
bit_twiddler
2006-12-05 01:21:15 UTC
Permalink
I'm having trouble with using InternetReadFile in async mode.

I do the following:
o InternetOpen in async mode
o set callback function
o create and reset an event
o InternetOpenURL
o wait for event to signal

loop:
o reset event
o InternetReadFile
o wait for event to signal

where my callback signals the event on read complete status.

Now occasionally what happens is InternetReadFile will return false and
last error is
ERROR_IO_PENDING, which is normal, and I call WaitForSingleObject on my
event
object, and that will return WAIT_OBJECT_0 which indicates that the
object is signalled,
but I my callback never received the read complete status. And given
that this condition
is the only place where I signal my event I don't see how
WaitForSingleObject can be
returning signalled.
If I then ResetEvent and wait again, then I get the correct result.

Anyone have any ideas, or at least had similar experiences and want to
commiserate?

Thanks.
Vladimir Scherbina
2006-12-05 11:33:49 UTC
Permalink
This post might be inappropriate. Click to display it.
bit_twiddler
2006-12-05 18:16:00 UTC
Permalink
It's manual reset. I don't have the source for SetEvent so I'm not
sure I can set a
breakpoint. I'm using VC++ 6.0.
Post by Vladimir Scherbina
What type of event do you create? I believe it is *manual reset*. If not,
use manual reset and control all things by yourself. In case when you create
manual reset event put breakpoint to SetEvent and look who calls it.
--
Vladimir (Windows SDK MVP)
http://msmvps.com/blogs/v_scherbina/
Post by bit_twiddler
I'm having trouble with using InternetReadFile in async mode.
o InternetOpen in async mode
o set callback function
o create and reset an event
o InternetOpenURL
o wait for event to signal
o reset event
o InternetReadFile
o wait for event to signal
where my callback signals the event on read complete status.
Now occasionally what happens is InternetReadFile will return false and
last error is
ERROR_IO_PENDING, which is normal, and I call WaitForSingleObject on my
event
object, and that will return WAIT_OBJECT_0 which indicates that the
object is signalled,
but I my callback never received the read complete status. And given
that this condition
is the only place where I signal my event I don't see how
WaitForSingleObject can be
returning signalled.
If I then ResetEvent and wait again, then I get the correct result.
Anyone have any ideas, or at least had similar experiences and want to
commiserate?
Thanks.
Vladimir Scherbina
2006-12-06 23:20:38 UTC
Permalink
In VC8.0 you can set the breakpoint to a function. I believe this also can
be done in VC6.0. If you can't find how to do that then simply put
breakpoint as you usually do on a call to function and track whether it's
called.
--
Vladimir (Windows SDK MVP)
http://msmvps.com/blogs/v_scherbina/
Post by bit_twiddler
It's manual reset. I don't have the source for SetEvent so I'm not
sure I can set a
breakpoint. I'm using VC++ 6.0.
Post by Vladimir Scherbina
What type of event do you create? I believe it is *manual reset*. If not,
use manual reset and control all things by yourself. In case when you create
manual reset event put breakpoint to SetEvent and look who calls it.
--
Vladimir (Windows SDK MVP)
http://msmvps.com/blogs/v_scherbina/
Post by bit_twiddler
I'm having trouble with using InternetReadFile in async mode.
o InternetOpen in async mode
o set callback function
o create and reset an event
o InternetOpenURL
o wait for event to signal
o reset event
o InternetReadFile
o wait for event to signal
where my callback signals the event on read complete status.
Now occasionally what happens is InternetReadFile will return false and
last error is
ERROR_IO_PENDING, which is normal, and I call WaitForSingleObject on my
event
object, and that will return WAIT_OBJECT_0 which indicates that the
object is signalled,
but I my callback never received the read complete status. And given
that this condition
is the only place where I signal my event I don't see how
WaitForSingleObject can be
returning signalled.
If I then ResetEvent and wait again, then I get the correct result.
Anyone have any ideas, or at least had similar experiences and want to
commiserate?
Thanks.
Loading...