Solved

InternetReadFile 100% cpu usage

Posted on 2007-03-28
6
534 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SetCurrentDirectory path limit 7 131
Would like to move button in a function 3 79
Dynamically allocate memory 9 63
C++ :Change value from  DisableCMD registry 4 66
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

828 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