Discussion:
Closing Internet handle terminating thread on Smartphone2003 emulator
(too old to reply)
Fred
2006-02-23 03:23:29 UTC
Permalink
Hi, This is a follow up to the question I asked a couple of weeks ago ie
"Asynch wininet - Threaded or not?"

I decided to try and get around the fact that wininet synchronous timeouts
doesn't work by closing the Internet handle if a thread is hanging similar
to

http://support.microsoft.com/kb/224318/EN-US/

I expect the httpsendrequest to hang or the read - both of which use the
handle returned by openrequest.

Now I have tested on the desktop successfully by using a firewall to block
access by waiting on its dialog asking whether to allow access to the
internet for the prog. I reply "yes"access the closehandle from the managing
thread - just the main thread in my test prog. The httpsendrequest() aborts
immediately and everything works as expected.

However, when I try the same using the smartphone2003 emulator, the
httpsendrequest() still succeeds even after the main thread has closed the
handle.

Is this just an artifact of the emulator not processing threads correctly or
is there something more ominous at work?

Also is the mechanism I use with the firewall good enough, or is there a
better way I can simulate a hang on httpsendrequest?

TIA
Scherbina Vladimir
2006-02-23 06:08:28 UTC
Permalink
Hello, Fred.

1. Simulator is not a good ambient to test real situations. I remember
excellent working app. on simulator but hunging on real devices. (I hope
gurus at microsoft.public.smartphone, microsoft.public.smartphone.developer
NG's will explain this behavour).

2. Yes, simulating hunging using blocking by firewall is ok, additioanlly
you may send a huge amount of data - HttpSendRequest will hung for a long
time in case of big blobs.
--
Vladimir
Post by Fred
Hi, This is a follow up to the question I asked a couple of weeks ago ie
"Asynch wininet - Threaded or not?"
I decided to try and get around the fact that wininet synchronous timeouts
doesn't work by closing the Internet handle if a thread is hanging similar
to
http://support.microsoft.com/kb/224318/EN-US/
I expect the httpsendrequest to hang or the read - both of which use the
handle returned by openrequest.
Now I have tested on the desktop successfully by using a firewall to block
access by waiting on its dialog asking whether to allow access to the
internet for the prog. I reply "yes"access the closehandle from the managing
thread - just the main thread in my test prog. The httpsendrequest() aborts
immediately and everything works as expected.
However, when I try the same using the smartphone2003 emulator, the
httpsendrequest() still succeeds even after the main thread has closed the
handle.
Is this just an artifact of the emulator not processing threads correctly or
is there something more ominous at work?
Also is the mechanism I use with the firewall good enough, or is there a
better way I can simulate a hang on httpsendrequest?
TIA
Fred
2006-02-23 10:17:59 UTC
Permalink
Post by Scherbina Vladimir
Hello, Fred.
1. Simulator is not a good ambient to test real situations. I remember
excellent working app. on simulator but hunging on real devices. (I hope
gurus at microsoft.public.smartphone,
microsoft.public.smartphone.developer
Post by Scherbina Vladimir
NG's will explain this behavour).
2. Yes, simulating hunging using blocking by firewall is ok, additioanlly
you may send a huge amount of data - HttpSendRequest will hung for a long
time in case of big blobs.
I had a big blob after eating too much at an Indian Restaurant.
I don't see how that will help resolve my issue...and even if it does it
seems very messy and impractical ;)
Scherbina Vladimir
2006-02-23 14:52:36 UTC
Permalink
BLOB - Binary Large OBject. My advise was to send a big chunk(s) of data
using HttpSendRequest(Ex). It will cause hunging of mentioned function and
"simulating" your case.
--
Vladimir
Fred
2006-02-23 18:59:31 UTC
Permalink
Post by Scherbina Vladimir
BLOB - Binary Large OBject. My advise was to send a big chunk(s) of data
using HttpSendRequest(Ex). It will cause hunging of mentioned function and
"simulating" your case.
Yes. What I told was a joke.
Alexander
2006-03-03 11:22:25 UTC
Permalink
Hello, Fred!

I'm experiencing similar problem.
When firewall blocks SendRequest call I try to
CloseHandle from another thread but it doesn't succeed,
just application hangs.
Same if terminate process which called SendRequest -
application hangs after some time - seems there is
some important block still captured by SendRequest.

If anybody have any info/thoughts on it I will
appriciate your help much.

Thanks,
Alex.

PS Sorry that my question is not directly about Smartphone2003. But I think
it is much related.
Scherbina Vladimir
2006-03-03 11:39:37 UTC
Permalink
Alexander,

This behavour most likely is caused by firewalls. If they hook
HttpSendRequest(Ex) then *their* code is executed untill HttpSendRequest(Ex)
returns control. That's why wininet cannot detect that handle is closed and
return from HttpSendRequest(Ex) immidiatly.
--
Vladimir
Loading...