ソースを参照

access selector resources before it's closed

svn path=/trunk/mcs/; revision=76072
Konstantin Triger 18 年 前
コミット
cdb8b6daa0
1 ファイル変更12 行追加0 行削除
  1. 12 0
      mcs/class/System/System.Net.Sockets/GHSocketFactory.jvm.cs

+ 12 - 0
mcs/class/System/System.Net.Sockets/GHSocketFactory.jvm.cs

@@ -173,6 +173,7 @@ namespace System.Net.Sockets
 			{
 				java.nio.channels.SelectionKey key = (java.nio.channels.SelectionKey)it.next();
 				Socket source = (Socket)key.attachment();
+				key.cancel ();
 				try
 				{
 					if (source.Blocking)
@@ -193,6 +194,17 @@ namespace System.Net.Sockets
 #endif
 				}
 			}
+
+			try
+			{
+				selector.close();
+			}
+			catch (Exception e)
+			{
+#if DEBUG
+				Console.WriteLine("Caught exception during CloseSelector selector.close - {0}: {1}\n{2}", e.GetType(), e.Message, e.StackTrace);
+#endif
+			}
 		}
 	}
 }