Merge pull request #1225 from strawd/bug22307
[mono.git] / mcs / class / System.ServiceModel / System.ServiceModel.Dispatcher / ChannelDispatcher.cs
index 10834fc0ae81deafcb1f22b0a54bd2ab3f12b939..65b5c8cf38ae6913b2482b54609ecc8ee45064e4 100644 (file)
@@ -35,6 +35,9 @@ using System.Threading;
 using System.Transactions;
 using System.ServiceModel;
 using System.ServiceModel.Description;
+using System.Net.Sockets;
+using System.Xml;
+using System.IO;
 
 namespace System.ServiceModel.Dispatcher
 {
@@ -584,10 +587,14 @@ namespace System.ServiceModel.Dispatcher
                        {
                                Message msg;
                                var input = (IInputChannel) result.AsyncState;
-                               if (input.EndTryReceive (result, out msg))
-                                       ProcessInput (input, msg);
-                               else
+                               try {
+                                       if (input.EndTryReceive (result, out msg))
+                                               ProcessInput (input, msg);
+                                       else
+                                               input.Close ();
+                               } catch (ObjectDisposedException) {
                                        input.Close ();
+                               }
                        }
 
                        void ProcessRequest (IReplyChannel reply, RequestContext rc)
@@ -601,7 +608,10 @@ namespace System.ServiceModel.Dispatcher
                                        if (ProcessErrorWithHandlers (reply, ex, out res))
                                                return;
 
-                                       rc.Reply (res);
+                                       if ((!(ex is SocketException)) && 
+                                           (!(ex is XmlException)) &&
+                                           (!(ex is IOException)))
+                                               rc.Reply (res);
                                        
                                        reply.Close (owner.DefaultCloseTimeout); // close the channel
                                } finally {