Fix for bug 22307 - Intermittent IndexOutOfRangeException on closing connection
authorDavid Straw <david.straw@hp.com>
Fri, 22 Aug 2014 17:28:24 +0000 (11:28 -0600)
committerDavid Straw <david.straw@hp.com>
Fri, 22 Aug 2014 17:50:08 +0000 (11:50 -0600)
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs

index 15731e65a3a594d4909d5bdf3a59236debb2f5ab..10834fc0ae81deafcb1f22b0a54bd2ab3f12b939 100644 (file)
@@ -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));