all groups > dotnet clr > july 2006 >
You're in the

dotnet clr

group:

Bug in HttpWebRequest/Response Dispose() implementation?


Re: Bug in HttpWebRequest/Response Dispose() implementation? Jon Skeet [C# MVP]
7/5/2006 8:52:00 PM
dotnet clr:
[quoted text, click to view]

<snip>

[quoted text, click to view]

Yes. Could you show us the code that doesn't work, preferrably as a
short but complete program?

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
Re: Bug in HttpWebRequest/Response Dispose() implementation? Barry Kelly
7/5/2006 9:02:44 PM
[quoted text, click to view]

I'm not sure I understand - can you show us the code that didn't work,
rather than the code that did? :)

-- Barry

--
Bug in HttpWebRequest/Response Dispose() implementation? Vagif Abilov
7/5/2006 9:29:47 PM
Hello,

We have a simple piece of code that exchanges data using HTTP
request/reponse. It uses "using" statement to guarantee that the
communication channel is properly closed on completion. However, if the code
is executed multiple times, the first execution attempt works fine, but the
second attempt times out.

To verify if the channel is closed properly, we replaced that code with the
following:

HttpWebRequest request = PrepareRequest(userVerificationData,
schufaRequestType, null);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

string requestID = response.Headers["RequestID"];
try
{
// Do something
}
finally
{
request = null;
response = null;
GC.Collect();
}

Then suddently everything worked! But the difference is that now we call
expensive garbage collection which of course kills the performance.

Why using Dispose method does not do the same? Isn't it the purpose of
IDisposable interface?

Vagif Abilov
Oslo Norway

Re: Bug in HttpWebRequest/Response Dispose() implementation? Jon Skeet [C# MVP]
7/5/2006 10:27:32 PM
[quoted text, click to view]

Hmm. Glad you've found it. I *suspect* that .NET 2.0 doesn't have the
same problem, given that it was fixed against 1.1 in the hotfix. I
wouldn't like to say for sure though.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
Re: Bug in HttpWebRequest/Response Dispose() implementation? Vagif Abilov
7/5/2006 10:47:14 PM
I am not in the office right now, but I guess the original code looked like
this:

HttpWebRequest request = PrepareRequest(...);
using(HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
... do something with response
}

HttpWebRequest is not disposable, so we applied "using" pattern to
HttpWebResponse object only.

While searching for the source of the problem, I found couple of documents:

http://dturini.blogspot.com/2004/06/on-past-few-days-im-dealing-with-some.html

http://support.microsoft.com/?kbid=831138

Looks like there .NET 1.1 had a problem with release of unmanaged resources
allocated by HttpResponse. Does .NET 2.0 has the same problem?

Vagif


[quoted text, click to view]

Re: Bug in HttpWebRequest/Response Dispose() implementation? Vagif Abilov
7/5/2006 10:48:00 PM
Please see my reply to Jon Skeet.

Best regards
Vagif


[quoted text, click to view]

Re: Bug in HttpWebRequest/Response Dispose() implementation? Vagif Abilov
7/5/2006 11:53:16 PM
Well, the problem we discovered was actually in our code running on .NET 2.0
:-(

We will investigate more, but first impression - the problem is still there,
since "using" does not work and GC.Collect does.

Vagif


[quoted text, click to view]

AddThis Social Bookmark Button