Imported Upstream version 5.4.0.167

Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-08-21 15:34:15 +00:00
parent e49d6f06c0
commit 536cd135cc
12856 changed files with 563812 additions and 223249 deletions

View File

@ -30,7 +30,7 @@ namespace System.ServiceModel.Dispatcher
List<IDuplexRequest> requests;
List<ICorrelatorKey> timedOutRequests;
ChannelHandler channelHandler;
volatile bool requestAborted;
bool requestAborted;
internal DuplexChannelBinder(IDuplexChannel channel, IRequestReplyCorrelator correlator)
{
@ -207,25 +207,32 @@ namespace System.ServiceModel.Dispatcher
void AbortRequests()
{
IDuplexRequest[] array = null;
lock (this.ThisLock)
{
if (this.requests != null)
{
array = this.requests.ToArray();
foreach (IDuplexRequest request in array)
{
request.Abort();
}
this.requests = null;
}
this.requests = null;
this.requestAborted = true;
}
bool hadRequests = array != null && array.Length > 0;
if (hadRequests)
{
foreach (IDuplexRequest request in array)
{
request.Abort();
}
}
// Remove requests from the correlator since the channel might be either faulting or aborting,
// We are not going to get a reply for these requests. If they are not removed from the correlator, this will cause a leak.
// This operation does not have to be under the lock
if (array != null && array.Length > 0)
if (hadRequests)
{
RequestReplyCorrelator requestReplyCorrelator = this.correlator as RequestReplyCorrelator;
if (requestReplyCorrelator != null)
@ -537,7 +544,7 @@ namespace System.ServiceModel.Dispatcher
}
}
// ASSUMPTION: ([....]) caller holds lock (this.mutex)
// ASSUMPTION: (Microsoft) caller holds lock (this.mutex)
void RequestStarting(Message message, IDuplexRequest request)
{
if (request != null)
@ -552,7 +559,7 @@ namespace System.ServiceModel.Dispatcher
}
// ASSUMPTION: ([....]) caller holds lock (this.mutex)
// ASSUMPTION: (Microsoft) caller holds lock (this.mutex)
void RequestCompleting(IDuplexRequest request)
{
this.pending--;
@ -1473,7 +1480,7 @@ namespace System.ServiceModel.Dispatcher
public void EndClose(IAsyncResult result)
{
// don't need to lock here since BeginClose is the [....]-point
// don't need to lock here since BeginClose is the sync-point
if (this.closeState.TryUserClose())
{
this.innerChannel.EndClose(result);