From: David Straw Date: Fri, 22 Aug 2014 17:28:24 +0000 (-0600) Subject: Fix for bug 22307 - Intermittent IndexOutOfRangeException on closing connection X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=5b6c684d26995e720a05ff5d1cd2210e31d041ad;p=mono.git Fix for bug 22307 - Intermittent IndexOutOfRangeException on closing connection --- 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));