2010-04-23 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Fri, 23 Apr 2010 09:26:26 +0000 (09:26 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 23 Apr 2010 09:26:26 +0000 (09:26 -0000)
* HttpChannelListener.cs, HttpListenerManager.cs :
  actually it should be ChannelDispatcher-to-HttpChannelListener,
  to identify which dispatcher to send reqs.

* ServiceHostBase.cs: (ditto)

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

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/ChangeLog
mcs/class/System.ServiceModel/System.ServiceModel/ServiceHostBase.cs

index e1b9a857cc635e63bcb923563096e7a1acd82ac1..85719547a9f75c8c02b97fd0181585f9d5255440 100755 (executable)
@@ -1,3 +1,9 @@
+2010-04-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpChannelListener.cs, HttpListenerManager.cs :
+         actually it should be ChannelDispatcher-to-HttpChannelListener,
+         to identify which dispatcher to send reqs.
+
 2010-04-23  Atsushi Enomoto  <atsushi@ximian.com>
 
        * HttpReplyChannel.cs : remove old Http Keep-Alive workaround.
index 73dab4d308a2122ab9c0677425337bb5c1e622c3..988d431c508e8402f8023c85f9eca6361bb680ee 100644 (file)
@@ -33,6 +33,7 @@ using System.Net;
 using System.Net.Security;
 using System.ServiceModel;
 using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
 using System.ServiceModel.Security;
 using System.Text;
 
@@ -66,7 +67,7 @@ namespace System.ServiceModel.Channels
 
                protected override HttpListenerManager CreateListenerManager ()
                {
-                       return new HttpSimpleListenerManager (this, Source, SecurityTokenManager, Host);
+                       return new HttpSimpleListenerManager (this, Source, SecurityTokenManager, ChannelDispatcher);
                }
        }
 
@@ -89,7 +90,7 @@ namespace System.ServiceModel.Channels
 
                protected override HttpListenerManager CreateListenerManager ()
                {
-                       return new AspNetListenerManager (this, Source, SecurityTokenManager, Host);
+                       return new AspNetListenerManager (this, Source, SecurityTokenManager, ChannelDispatcher);
                }
        }
 
@@ -100,11 +101,14 @@ namespace System.ServiceModel.Channels
                MessageEncoder encoder;
                HttpListenerManager httpChannelManager;
 
+               internal static HttpChannelListenerBase<TChannel>CurrentHttpChannelListener;
+
                public HttpChannelListenerBase (HttpTransportBindingElement source,
                        BindingContext context)
                        : base (context)
                {
-                       Host = ServiceHostBase.CurrentServiceHostHack;
+                       if (ServiceHostBase.CurrentServiceHostHack != null)
+                               DispatcherBuilder.ChannelDispatcherSetter = delegate (ChannelDispatcher cd) { this.ChannelDispatcher = cd; };
 
                        this.Source = source;
                        // The null Uri check looks weird, but it seems the listener can be built without it.
@@ -126,7 +130,7 @@ namespace System.ServiceModel.Channels
                                SecurityTokenManager = new ServiceCredentialsSecurityTokenManager ((ServiceCredentials) context.BindingParameters [typeof (ServiceCredentials)]);
                }
 
-               public ServiceHostBase Host { get; private set; }
+               internal ChannelDispatcher ChannelDispatcher { get; set; }
 
                public HttpTransportBindingElement Source { get; private set; }
 
index eb49cbf8fc5c305aec9922d7de098362e85036bb..41d83e2ada2949d6014575f18dea6fe643981a27 100644 (file)
@@ -33,6 +33,7 @@ using System.Collections.Specialized;
 using System.IdentityModel.Selectors;
 using System.IdentityModel.Tokens;
 using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
 using System.ServiceModel.Security;
 using System.Security.Principal;
 using System.Text;
@@ -145,10 +146,10 @@ namespace System.ServiceModel.Channels
                Dictionary<Uri, HttpListener> opened_listeners;
                HttpListener http_listener;
 
-               public HttpSimpleListenerManager (IChannelListener channelListener, HttpTransportBindingElement source, ServiceCredentialsSecurityTokenManager securityTokenManager, ServiceHostBase host)
-                       : base (channelListener, source, securityTokenManager, host)
+               public HttpSimpleListenerManager (IChannelListener channelListener, HttpTransportBindingElement source, ServiceCredentialsSecurityTokenManager securityTokenManager, ChannelDispatcher dispatcher)
+                       : base (channelListener, source, securityTokenManager, dispatcher)
                {
-                       object key = host ?? new object (); // so that HttpChannelListener without ServiceHost is always assigned a new table.
+                       object key = dispatcher != null ? dispatcher.Host : new object (); // so that HttpChannelListener without ServiceHost is always assigned a new table.
                        if (!http_listeners_table.TryGetValue (key, out opened_listeners)) {
                                opened_listeners = new Dictionary<Uri, HttpListener> ();
                                http_listeners_table [key] = opened_listeners;
@@ -211,8 +212,8 @@ namespace System.ServiceModel.Channels
        {
                SvcHttpHandler http_handler;
 
-               public AspNetListenerManager (IChannelListener channelListener, HttpTransportBindingElement source, ServiceCredentialsSecurityTokenManager securityTokenManager, ServiceHostBase host)
-                       : base (channelListener, source, securityTokenManager, host)
+               public AspNetListenerManager (IChannelListener channelListener, HttpTransportBindingElement source, ServiceCredentialsSecurityTokenManager securityTokenManager, ChannelDispatcher dispatcher)
+                       : base (channelListener, source, securityTokenManager, dispatcher)
                {
                        http_handler = SvcHttpHandler.Current;
                }
@@ -253,7 +254,7 @@ namespace System.ServiceModel.Channels
 
                public MetadataPublishingInfo MexInfo { get { return mex_info; } }
                public HttpTransportBindingElement Source { get; private set; }
-               public ServiceHostBase Host { get; private set; }
+               public ChannelDispatcher Dispatcher { get; private set; }
 
                SecurityTokenAuthenticator security_token_authenticator;
                SecurityTokenResolver security_token_resolver;
@@ -263,9 +264,9 @@ namespace System.ServiceModel.Channels
                        registered_channels = new Dictionary<Uri, List<IChannelListener>> ();
                }
 
-               protected HttpListenerManager (IChannelListener channelListener, HttpTransportBindingElement source, ServiceCredentialsSecurityTokenManager securityTokenManager, ServiceHostBase host)
+               protected HttpListenerManager (IChannelListener channelListener, HttpTransportBindingElement source, ServiceCredentialsSecurityTokenManager securityTokenManager, ChannelDispatcher dispatcher)
                {
-                       this.Host = host;
+                       this.Dispatcher = dispatcher;
                        this.channel_listener = channelListener;
                        // FIXME: this cast should not be required, but current JIT somehow causes an internal error.
                        mex_info = ((IChannelListener) channelListener).GetProperty<MetadataPublishingInfo> ();
index aa5b6662b82e335c435e7950503da6514690ac4e..dd610773554f9735138232077ea36d12cf6853ab 100755 (executable)
@@ -1,3 +1,9 @@
+2010-04-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostBase.cs:
+         actually it should be ChannelDispatcher-to-HttpChannelListener,
+         to identify which dispatcher to send reqs.
+
 2010-04-23  Atsushi Enomoto  <atsushi@ximian.com>
 
        * ServiceHostBase.cs : add host-to-http-listener mapping so that
index 1a681a1cb71f1045e080a45329ebd06cb9ba8e2c..81b5608aabdaa9e6acbd19776e59d7d5e5c23a3a 100644 (file)
@@ -599,7 +599,9 @@ namespace System.ServiceModel
 
                List<ChannelDispatcher> built_dispatchers = new List<ChannelDispatcher> ();
                Dictionary<ServiceEndpoint, EndpointDispatcher> ep_to_dispatcher_ep = new Dictionary<ServiceEndpoint, EndpointDispatcher> ();
-               
+
+               internal static Action<ChannelDispatcher> ChannelDispatcherSetter;
+
                internal ChannelDispatcher BuildChannelDispatcher (Type serviceType, ServiceEndpoint se, BindingParameterCollection commonParams)
                {
                        //Let all behaviors add their binding parameters
@@ -615,8 +617,12 @@ namespace System.ServiceModel
                                lock (HttpTransportBindingElement.ListenerBuildLock) {
                                        ServiceHostBase.CurrentServiceHostHack = host;
                                        IChannelListener lf = BuildListener (se, commonParams);
-                                       ServiceHostBase.CurrentServiceHostHack = null;
                                        cd = new ChannelDispatcher (lf, se.Binding.Name);
+                                       if (ChannelDispatcherSetter != null) {
+                                               ChannelDispatcherSetter (cd);
+                                               ChannelDispatcherSetter = null;
+                                       }
+                                       ServiceHostBase.CurrentServiceHostHack = null;
                                }
                                ep = cd.InitializeServiceEndpoint (serviceType, se);
                                built_dispatchers.Add (cd);