Imported Upstream version 4.3.2.467

Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
Xamarin Public Jenkins
2016-02-22 11:00:01 -05:00
parent f302175246
commit f3e3aab35a
4097 changed files with 122406 additions and 82300 deletions

View File

@@ -5,6 +5,7 @@
namespace System.ServiceModel.Dispatcher
{
using System;
using System.Diagnostics;
using System.Globalization;
using System.Runtime;
using System.Runtime.CompilerServices;
@@ -769,7 +770,7 @@ namespace System.ServiceModel.Dispatcher
bool HandleError(Exception e, ref ErrorHandlerFaultInfo faultInfo)
{
if (!(e != null))
if (e == null)
{
Fx.Assert(SR.GetString(SR.GetString(SR.SFxNonExceptionThrown)));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.GetString(SR.SFxNonExceptionThrown))));
@@ -944,7 +945,8 @@ namespace System.ServiceModel.Dispatcher
return false;
}
ServiceModelActivity activity = DiagnosticUtility.ShouldUseActivity ? TraceUtility.ExtractActivity(request.RequestMessage) : null;
ServiceModelActivity activity = DiagnosticUtility.ShouldUseActivity ? TraceUtility.ExtractActivity(request) : null;
using (ServiceModelActivity.BoundOperation(activity))
{
if (this.HandleRequestAsReply(request))
@@ -1440,7 +1442,7 @@ namespace System.ServiceModel.Dispatcher
{
if (this.isConcurrent)
{
this.isPumpAcquired = 0;
Interlocked.Exchange(ref this.isPumpAcquired, 0);
}
}
@@ -1793,8 +1795,6 @@ namespace System.ServiceModel.Dispatcher
}
this.requestInfo.ChannelHandlerOwnsInstanceContextThrottle = (this.requestInfo.ExistingInstanceContext == null);
if (this.DispatchAndReleasePump(request, false, null))
{
this.EnsurePump();
@@ -1802,9 +1802,42 @@ namespace System.ServiceModel.Dispatcher
}
}
bool TryRetrievingInstanceContext(RequestContext request)
{
try
{
return TryRetrievingInstanceContextCore(request);
}
catch (Exception ex)
{
if (Fx.IsFatal(ex))
{
throw;
}
DiagnosticUtility.TraceHandledException(ex, TraceEventType.Error);
try
{
request.Close();
}
catch (Exception e)
{
if (Fx.IsFatal(e))
{
throw;
}
request.Abort();
}
return false;
}
}
//Return: False denotes failure, Caller should discard the request.
// : True denotes operation is sucessful.
bool TryRetrievingInstanceContext(RequestContext request)
bool TryRetrievingInstanceContextCore(RequestContext request)
{
bool releasePump = true;
try
@@ -1870,6 +1903,7 @@ namespace System.ServiceModel.Dispatcher
}
this.HandleError(e, request, channel);
return false;
}
finally
@@ -1949,10 +1983,7 @@ namespace System.ServiceModel.Dispatcher
{
if (this.isConcurrent)
{
if (this.isPumpAcquired != 0 || Interlocked.CompareExchange(ref this.isPumpAcquired, 1, 0) != 0)
{
return false;
}
return Interlocked.CompareExchange(ref this.isPumpAcquired, 1, 0) == 0;
}
return true;

View File

@@ -1030,7 +1030,7 @@ namespace System.ServiceModel.Dispatcher
void ProcessMessage31(ref MessageRpc rpc)
{
rpc.NextProcessor = this.ProcessMessage4;
rpc.NextProcessor = this.processMessage4;
if (this.transaction != null)
{

View File

@@ -50,16 +50,23 @@ namespace System.ServiceModel.Dispatcher
{
get
{
lock (this.ThisLock)
if (this.calls == null)
{
if (this.calls == null)
lock (this.ThisLock)
{
this.calls = new FlowThrottle(this.GotCall, ServiceThrottle.DefaultMaxConcurrentCallsCpuCount,
ServiceThrottle.MaxConcurrentCallsPropertyName, ServiceThrottle.MaxConcurrentCallsConfigName);
this.calls.SetRatio(this.RatioCallsToken);
if (this.calls == null)
{
FlowThrottle callsFt = new FlowThrottle(this.GotCall, ServiceThrottle.DefaultMaxConcurrentCallsCpuCount,
ServiceThrottle.MaxConcurrentCallsPropertyName, ServiceThrottle.MaxConcurrentCallsConfigName);
callsFt.SetRatio(this.RatioCallsToken);
this.calls = callsFt;
}
}
return this.calls;
}
return this.calls;
}
}
@@ -67,16 +74,23 @@ namespace System.ServiceModel.Dispatcher
{
get
{
lock (this.ThisLock)
if (this.sessions == null)
{
if (this.sessions == null)
lock (this.ThisLock)
{
this.sessions = new FlowThrottle(this.GotSession, ServiceThrottle.DefaultMaxConcurrentSessionsCpuCount,
ServiceThrottle.MaxConcurrentSessionsPropertyName, ServiceThrottle.MaxConcurrentSessionsConfigName);
this.sessions.SetRatio(this.RatioSessionsToken);
if (this.sessions == null)
{
FlowThrottle sessionsFt = new FlowThrottle(this.GotSession, ServiceThrottle.DefaultMaxConcurrentSessionsCpuCount,
ServiceThrottle.MaxConcurrentSessionsPropertyName, ServiceThrottle.MaxConcurrentSessionsConfigName);
sessionsFt.SetRatio(this.RatioSessionsToken);
this.sessions = sessionsFt;
}
}
return this.sessions;
}
return this.sessions;
}
}
@@ -84,16 +98,22 @@ namespace System.ServiceModel.Dispatcher
{
get
{
lock (this.ThisLock)
if (this.dynamic == null)
{
if (this.dynamic == null)
lock (this.ThisLock)
{
this.dynamic = new QuotaThrottle(this.GotDynamic, new object());
this.dynamic.Owner = "ServiceHost";
if (this.dynamic == null)
{
QuotaThrottle dynamicQt = new QuotaThrottle(this.GotDynamic, new object());
dynamicQt.Owner = "ServiceHost";
this.dynamic = dynamicQt;
}
}
this.UpdateIsActive();
return this.dynamic;
}
this.UpdateIsActive();
return this.dynamic;
}
}
@@ -158,20 +178,27 @@ namespace System.ServiceModel.Dispatcher
{
get
{
lock (this.ThisLock)
if (this.instanceContexts == null)
{
if (this.instanceContexts == null)
lock (this.ThisLock)
{
this.instanceContexts = new FlowThrottle(this.GotInstanceContext, Int32.MaxValue,
ServiceThrottle.MaxConcurrentInstancesPropertyName, ServiceThrottle.MaxConcurrentInstancesConfigName);
this.instanceContexts.SetRatio(this.RatioInstancesToken);
if (this.servicePerformanceCounters != null)
if (this.instanceContexts == null)
{
InitializeInstancePerfCounterSettings();
FlowThrottle instanceContextsFt = new FlowThrottle(this.GotInstanceContext, Int32.MaxValue,
ServiceThrottle.MaxConcurrentInstancesPropertyName, ServiceThrottle.MaxConcurrentInstancesConfigName);
instanceContextsFt.SetRatio(this.RatioInstancesToken);
if (this.servicePerformanceCounters != null)
{
InitializeInstancePerfCounterSettings(instanceContextsFt);
}
this.instanceContexts = instanceContextsFt;
}
}
return this.instanceContexts;
}
return this.instanceContexts;
}
}
@@ -191,7 +218,7 @@ namespace System.ServiceModel.Dispatcher
//instance throttle is created through the behavior, set the perf counter callbacks if initialized
if (this.instanceContexts != null)
{
InitializeInstancePerfCounterSettings();
InitializeInstancePerfCounterSettings(this.instanceContexts);
}
//this.calls and this.sessions throttles are created by the constructor. Set the perf counter callbacks
@@ -199,14 +226,14 @@ namespace System.ServiceModel.Dispatcher
InitializeSessionsPerfCounterSettings();
}
void InitializeInstancePerfCounterSettings()
void InitializeInstancePerfCounterSettings(FlowThrottle instanceContextsFt)
{
Fx.Assert(this.instanceContexts != null, "Expect instanceContext to be initialized");
Fx.Assert(instanceContextsFt != null, "Expect instanceContext to be initialized");
Fx.Assert(this.servicePerformanceCounters != null, "expect servicePerformanceCounters to be set");
this.instanceContexts.SetAcquired(this.AcquiredInstancesToken);
this.instanceContexts.SetReleased(this.ReleasedInstancesToken);
this.instanceContexts.SetRatio(this.RatioInstancesToken);
this.servicePerformanceCounters.SetThrottleBase((int)ServicePerformanceCounters.PerfCounters.InstancesPercentMaxInstancesBase, this.instanceContexts.Capacity);
instanceContextsFt.SetAcquired(this.AcquiredInstancesToken);
instanceContextsFt.SetReleased(this.ReleasedInstancesToken);
instanceContextsFt.SetRatio(this.RatioInstancesToken);
this.servicePerformanceCounters.SetThrottleBase((int)ServicePerformanceCounters.PerfCounters.InstancesPercentMaxInstancesBase, instanceContextsFt.Capacity);
}
void InitializeCallsPerfCounterSettings()