Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/aspnetwebstack.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryoussefm <youssefm@microsoft.com>2012-09-11 22:11:17 +0400
committeryoussefm <youssefm@microsoft.com>2012-09-17 22:09:53 +0400
commit75b5e7ea58d2a120242ff0d840600e33e9b65882 (patch)
treeb29f5be3a9a6af72d8a126290740b9bcd2dc30d9
parent3c9ae825ac2fabc8a2bee021a7e1ee21d6d153ab (diff)
Resolving client disconnection issues for self host serverv2-rtm
-rw-r--r--src/System.Web.Http.SelfHost/HttpSelfHostServer.cs22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/System.Web.Http.SelfHost/HttpSelfHostServer.cs b/src/System.Web.Http.SelfHost/HttpSelfHostServer.cs
index 891f3499..90b66a09 100644
--- a/src/System.Web.Http.SelfHost/HttpSelfHostServer.cs
+++ b/src/System.Web.Http.SelfHost/HttpSelfHostServer.cs
@@ -1040,14 +1040,32 @@ namespace System.Web.Http.SelfHost
/// Releases unmanaged and - optionally - managed resources
/// </summary>
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged SRResources.</param>
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "We never want to fail here so we have to catch all exceptions.")]
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
- RequestContext.Close();
- Reply.Close();
+ // RequestContext.Close can throw if the client disconnects before it finishes receiving the response
+ // Catch here to avoid throwing in a Dispose method
+ try
+ {
+ RequestContext.Close();
+ }
+ catch
+ {
+ }
+
+ // HttpMessage.Close can throw if the request message throws in its Dispose implementation
+ // Catch here to avoid throwing in a Dispose method
+ try
+ {
+ Reply.Close();
+ }
+ catch
+ {
+ }
}
_disposed = true;