2010-07-12 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Mon, 12 Jul 2010 09:43:24 +0000 (09:43 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Mon, 12 Jul 2010 09:43:24 +0000 (09:43 -0000)
* ChannelDispatcher.cs : apply ErrorHandlers to IInputChannel too.

svn path=/trunk/mcs/; revision=160228

mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChangeLog
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs

index bf3a3287b7ebddc341863a467300836058c83c90..0eb826f0fee5734beb1eced32c32458802b0d29d 100644 (file)
@@ -1,3 +1,7 @@
+2010-07-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDispatcher.cs : apply ErrorHandlers to IInputChannel too.
+
 2010-07-09  Atsushi Enomoto  <atsushi@ximian.com>
 
        * PostReceiveRequestHandler.cs : don't replace correctly passed-by-
index 9af2252ab5d3193998cd7a69e0ab2dea7c706861..d71d76da166279dceccc2b0b359d0d25991a1155 100644 (file)
@@ -578,23 +578,13 @@ namespace System.ServiceModel.Dispatcher
                                        var ed = FindEndpointDispatcher (req);
                                        new InputOrReplyRequestProcessor (ed.DispatchRuntime, reply).ProcessReply (rc);
                                } catch (Exception ex) {
-                                       foreach (var eh in owner.ErrorHandlers)
-                                               if (eh.HandleError (ex))
-                                                       return; // error is handled appropriately.
-
-                                       // FIXME: log it.
-                                       Console.WriteLine (ex);
-
-                                       Message res = null;
-                                       foreach (var eh in owner.ErrorHandlers)
-                                               eh.ProvideFault (ex, owner.MessageVersion, ref res);
-                                       if (res == null) {
-                                               var conv = reply.GetProperty<FaultConverter> () ?? FaultConverter.GetDefaultFaultConverter (rc.RequestMessage.Version);
-                                               if (!conv.TryCreateFaultMessage (ex, out res))
-                                                       res = Message.CreateMessage (owner.MessageVersion, new FaultCode ("Receiver"), ex.Message, owner.MessageVersion.Addressing.FaultNamespace);
-                                       }
+                                       Message res;
+                                       if (ProcessErrorWithHandlers (reply, ex, out res))
+                                               return;
 
                                        rc.Reply (res);
+                                       
+                                       reply.Close (owner.DefaultCloseTimeout); // close the channel
                                } finally {
                                        if (rc != null)
                                                rc.Close ();
@@ -604,6 +594,28 @@ namespace System.ServiceModel.Dispatcher
                                }
                        }
 
+                       bool ProcessErrorWithHandlers (IChannel ch, Exception ex, out Message res)
+                       {
+                               res = null;
+
+                               foreach (var eh in owner.ErrorHandlers)
+                                       if (eh.HandleError (ex))
+                                               return true; // error is handled appropriately.
+
+                               // FIXME: log it.
+                               Console.WriteLine (ex);
+
+                               foreach (var eh in owner.ErrorHandlers)
+                                       eh.ProvideFault (ex, owner.MessageVersion, ref res);
+                               if (res == null) {
+                                       var conv = ch.GetProperty<FaultConverter> () ?? FaultConverter.GetDefaultFaultConverter (owner.MessageVersion);
+                                       if (!conv.TryCreateFaultMessage (ex, out res))
+                                               res = Message.CreateMessage (owner.MessageVersion, new FaultCode ("Receiver"), ex.Message, owner.MessageVersion.Addressing.FaultNamespace);
+                               }
+
+                               return false;
+                       }
+
                        void ProcessInput (IInputChannel input, Message message)
                        {
                                try {
@@ -613,8 +625,8 @@ namespace System.ServiceModel.Dispatcher
                                                ProcessInput (message);
                                }
                                catch (Exception ex) {
-                                       // FIXME: log it.
-                                       Console.WriteLine (ex);
+                                       Message dummy;
+                                       ProcessErrorWithHandlers (input, ex, out dummy);
                                } finally {
                                        // unless it is closed by session/call manager, move it back to the loop to receive the next message.
                                        if (loop && input.State != CommunicationState.Closed)