2010-03-17 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Wed, 17 Mar 2010 07:05:41 +0000 (07:05 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Wed, 17 Mar 2010 07:05:41 +0000 (07:05 -0000)
* SvcHttpHandler.cs, AspNetReplyChannel.cs, HttpChannelListener.cs,
  HttpListenerManager.cs : refactoring on acquiring SvcHttpHandler
  to not raise "not found" error (see bug #573795).

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

mcs/class/System.ServiceModel/System.ServiceModel.Channels/AspNetReplyChannel.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpChannelListener.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpListenerManager.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandler.cs

index 75cf52ce010905483037ed1489643c0317ea7fc4..8b083f5e9847f3d5eb19f145ae39ee9a6ade9558 100644 (file)
@@ -54,7 +54,7 @@ namespace System.ServiceModel.Channels
                        if (http_context == null)
                                return;
                        try {
-                               listener.HttpHandler.EndRequest (listener, http_context);
+                               ((AspNetListenerManager) listener.ListenerManager).HttpHandler.EndRequest (listener, http_context);
                        } finally {
                                http_context = null;
                        }
@@ -65,7 +65,7 @@ namespace System.ServiceModel.Channels
                        lock (waiting)
                                foreach (HttpContext ctx in waiting)
                                        try {
-                                               listener.HttpHandler.EndRequest (listener, ctx);
+                                               ((AspNetListenerManager) listener.ListenerManager).HttpHandler.EndRequest (listener, ctx);
                                        } catch {
                                        }
                }
index 64872d110e6bd4599901497acf324955b3d7f8bf..50bc62c56130055b5bde6162a1aa9581c3416a36 100755 (executable)
@@ -1,3 +1,9 @@
+2010-03-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SvcHttpHandler.cs, AspNetReplyChannel.cs, HttpChannelListener.cs,
+         HttpListenerManager.cs : refactoring on acquiring SvcHttpHandler
+         to not raise "not found" error (see bug #573795).
+
 2010-03-16  Jb Evain  <jbevain@novell.com>
 
        * HttpRequestChannel.cs, HttpTransportBindingElement.cs: use
index bb268417eacc146fe9316dd4206a59324d0972d1..f88df1e7464e49a2d9f3da2965e0861df2768e2a 100644 (file)
@@ -79,10 +79,6 @@ namespace System.ServiceModel.Channels
                {
                }
 
-               internal SvcHttpHandler HttpHandler {
-                       get { return ((AspNetListenerManager) ListenerManager).Source; }
-               }
-
                protected override TChannel CreateChannel (TimeSpan timeout)
                {
                        if (typeof (TChannel) == typeof (IReplyChannel))
index 51b1272bef92368f1cd8bbadacdb2ec9549a6d78..0ce97088b5b2b4d53fe5e99f48e8402d0022bd82 100644 (file)
@@ -212,12 +212,10 @@ namespace System.ServiceModel.Channels
                public AspNetListenerManager (IChannelListener channelListener, HttpTransportBindingElement source, ServiceCredentialsSecurityTokenManager securityTokenManager)
                        : base (channelListener, source, securityTokenManager)
                {
-                       http_handler = SvcHttpHandlerFactory.GetHandlerForListener (channelListener);
+                       http_handler = SvcHttpHandler.Current;
                }
 
-               public SvcHttpHandler Source {
-                       get { return http_handler; }
-               }
+               internal SvcHttpHandler HttpHandler { get { return http_handler; } }
 
                protected override void OnRegister (IChannelListener channelListener, TimeSpan timeout)
                {
index 413650ba3eba8c874975e1c9549d1b2174f6842f..161b3f476b45c37473abf35b1d2fa69844a6ac3a 100644 (file)
@@ -63,6 +63,8 @@ namespace System.ServiceModel.Channels {
 
        internal class SvcHttpHandler : IHttpHandler
        {
+               internal static SvcHttpHandler Current;
+
                static object type_lock = new object ();
 
                Type type;
@@ -135,7 +137,9 @@ namespace System.ServiceModel.Channels {
                                if (best == null)
                                        best = l;
                        }
-                       return best;
+                       if (best != null)
+                               return best;
+                       throw new InvalidOperationException (String.Format ("The argument HTTP context did not match any of the registered listener manager (could be mismatch in URL, method etc.) {0}", ctx.Request.Url));
 /*
                        var actx = new AspNetHttpContextInfo (ctx);
                        foreach (var i in listeners)
@@ -194,7 +198,17 @@ namespace System.ServiceModel.Channels {
                void EnsureServiceHost ()
                {
                        lock (type_lock) {
+                               Current = this;
+                               try {
+                                       EnsureServiceHostCore ();
+                               } finally {
+                                       Current = null;
+                               }
+                       }
+               }
 
+               void EnsureServiceHostCore ()
+               {
                        if (host != null)
                                return;
 
@@ -211,8 +225,6 @@ namespace System.ServiceModel.Channels {
 
                        // Not precise, but it needs some wait time to have all channels start requesting. And it is somehow required.
                        Thread.Sleep (500);
-
-                       }
                }
        }
 }