Files
mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/InputOrReplyRequestProcessor.cs
T
Atsushi Eno 657c31a31b Ongoing service channel closing fix and session management in ChannelDispatcher.
It is part of bugfix 687902.

To get the bug fixed, the new "using" sections in ChannelDispatcher.cs to
explicitly dispose channels. But this causes regression in PerSession-based
tests. So some new session management code is (likely) required as well.

It will also alter "mixed" MaxConcurrentCalls and MaxConcurrentSessions with
correct management code.
2011-04-20 16:57:58 +09:00

83 lines
2.6 KiB
C#

using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Security;
using System.ServiceModel.Security.Tokens;
using System.Text;
using System.ServiceModel.MonoInternal;
namespace System.ServiceModel.Dispatcher
{
internal class InputOrReplyRequestProcessor : BaseRequestProcessor, IDisposable
{
DispatchRuntime dispatch_runtime;
IChannel reply_or_input;
IContextChannel context_channel;
public InputOrReplyRequestProcessor (DispatchRuntime runtime, IChannel replyOrInput)
{
Init (runtime, replyOrInput);
//initialization
InitializeChain.AddHandler (new InitializingHandler ());
//processing
ProcessingChain.AddHandler (new PostReceiveRequestHandler ()).
AddHandler (new OperationInvokerHandler (replyOrInput));
//errors
ErrorChain.AddHandler (new ErrorProcessingHandler (replyOrInput));
//finalize
FinalizationChain.AddHandler (new FinalizeProcessingHandler ());
}
public void Dispose ()
{
if (context_channel != null)
context_channel.Close ();
}
void Init (DispatchRuntime runtime, IChannel replyOrInput)
{
dispatch_runtime = runtime;
reply_or_input = replyOrInput;
}
public void ProcessInput (Message message)
{
OperationContext opcx = CreateOperationContext (message);
ProcessRequest (new MessageProcessingContext (opcx));
}
public void ProcessReply (RequestContext rc)
{
OperationContext opcx = CreateOperationContext (rc.RequestMessage);
opcx.RequestContext = rc;
ProcessRequest (new MessageProcessingContext (opcx));
}
OperationContext CreateOperationContext (Message incoming)
{
IContextChannel contextChannel;
if (dispatch_runtime.CallbackClientRuntime.CallbackClientType != null) {
#if DISABLE_REAL_PROXY
var type = ServiceProxyGenerator.CreateCallbackProxyType (dispatch_runtime, dispatch_runtime.CallbackClientRuntime.CallbackClientType);
contextChannel = (ServiceRuntimeChannel) Activator.CreateInstance (type, new object [] {reply_or_input, dispatch_runtime});
#else
contextChannel = (IContextChannel) new ClientRealProxy (dispatch_runtime.CallbackClientRuntime.CallbackClientType, new DuplexServiceRuntimeChannel (reply_or_input, dispatch_runtime), true).GetTransparentProxy ();
#endif
}
else
contextChannel = new ServiceRuntimeChannel (reply_or_input, dispatch_runtime);
contextChannel.Open (); // FIXME: timeout?
OperationContext opCtx = new OperationContext (contextChannel);
opCtx.IncomingMessage = incoming;
opCtx.EndpointDispatcher = dispatch_runtime.EndpointDispatcher;
context_channel = contextChannel;
return opCtx;
}
}
}