Przeglądaj źródła

[bcl] Fix a regression introduced by 91c68de23f5067d000207194466813239cda7866. If a thread was added to (#4038)

blocking_threads twice, then removed once, the corresponding entry in threads_stacktraces was removed,
causing an exception in ReleaseHandle () later.
Zoltan Varga 9 lat temu
rodzic
commit
a90de75524

+ 6 - 3
mcs/class/System/System.Net.Sockets/SafeSocketHandle.cs

@@ -127,9 +127,12 @@ namespace System.Net.Sockets {
 		{
 			//If this NRE, we're in deep problems because Register Must have
 			lock (blocking_threads) {
-				blocking_threads.Remove (Thread.CurrentThread);
-				if (THROW_ON_ABORT_RETRIES)
-					threads_stacktraces.Remove (Thread.CurrentThread);
+				var current = Thread.CurrentThread;
+				blocking_threads.Remove (current);
+				if (THROW_ON_ABORT_RETRIES) {
+					if (blocking_threads.IndexOf (current) == -1)
+						threads_stacktraces.Remove (current);
+				}
 
 				if (in_cleanup && blocking_threads.Count == 0)
 					Monitor.Pulse (blocking_threads);