Solved

InternetReadFile 100% cpu usage

Posted on 2007-03-28
6
504 Views
Last Modified: 2010-05-18
Hi,

im using InternetReadFile win api function on this url : http://fotball.aftenposten.no/tv/article77811.ece
from some reason the last chunk im trying to read is stuck and cause 100% cpu utilization and doesn't seems to end, i did some google, and found out this kb from Microsoft: http://support.microsoft.com/kb/263754
 i tried what was recommended there and it didn't work, does anyone has new idea about it ?

Thanks,
Amit



0
Comment
Question by:Relegence
  • 2
  • 2
  • 2
6 Comments
 
LVL 11

Expert Comment

by:DeepuAbrahamK
ID: 18807144
It's c learly written, 'The problem is caused by a bug in the InternetReadFile API. Under some conditions, InternetReadFile fails to detect a connection closure and still tries to read data from the socket. '

RESOLUTION
----------------
Because this problem only occurs when chunked encoding is used, you can disable chunked encoding to solve the problem. Because chunked encoding is not used with HTTP 1.0, you can work around this problem by using HTTP
1.0
To do so you must:
1. Specify HTTP/1.0 in the HttpOpenRequest API.
2. In Internet Explorer, from the Tools menu, click Internet Options, and then select the Advanced tab. Clear the Use HTTP 1.1 and Use HTTP 1.1 through proxy connections check boxes.

Did you try this?
Best Regards,
DeepuAbrahamK
0
 

Author Comment

by:Relegence
ID: 18807165
of course i tried that,  :-)
0
 
LVL 11

Expert Comment

by:DeepuAbrahamK
ID: 18807167
Read this also, if you are not able to specify the http version by using HttpOpenRequest().
http://support.microsoft.com/kb/258425/EN-US/
Best Regards,
DeepuAbrahamK
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 39

Accepted Solution

by:
itsmeandnobodyelse earned 500 total points
ID: 18807180
I would assume it's another bug if the above doesn't help (you restarted the machine after changing to HTTP 1.1 Proxy?). Maybe a newer IE would solve the issue.

As a last resort you may put the call in a separate thread and set it to low priority. Then establish a watchdog which checks CPU and kills the thread if it runs into the infinite loop.

Regards, Alex
0
 

Author Comment

by:Relegence
ID: 18807619
Guys, thanks you all for your quick responses,
i already tried  the "watchdog" option itsmeandnobodyelse suggested , this approach imposes another problem because there is not safe way to kill threads without causing memory leaks, i think the solution is here : http://www.codeproject.com/internet/asyncwininet.asp?df=100&forumid=1409&exp=0&select=975072

Amit

0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 18808720
Amit, you shouldn't give C grade without further feedback. If you found the solution yourself you could tell the moderator and get points back. Or if you think that one or more comments have helped give a B grade which was appropriate. A C grade is appropriate if you asked for more help but didn't get it. Or if it was a really poor help such as "Help yourself and look at your sources".

I personally prefer to get no points rather than a C grade.

Regards, Alex
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now