From 5b6c684d26995e720a05ff5d1cd2210e31d041ad Mon Sep 17 00:00:00 2001 From: David Straw Date: Fri, 22 Aug 2014 11:28:24 -0600 Subject: [PATCH] Fix for bug 22307 - Intermittent IndexOutOfRangeException on closing connection --- .../System.ServiceModel.Dispatcher/ChannelDispatcher.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs index 15731e65a3a..10834fc0ae8 100644 --- a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs +++ b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs @@ -452,8 +452,11 @@ namespace System.ServiceModel.Dispatcher public void CloseInput () { foreach (var ch in channels.ToArray ()) { - if (ch.State == CommunicationState.Closed) - RemoveChannel (ch); + if (ch.State == CommunicationState.Closed) { + lock (channels) { + RemoveChannel (ch); + } + } else { try { ch.Close (close_timeout - (DateTime.Now - close_started)); -- 2.25.1