[System]: WebRequest.GetSystemProxy(): Return custom proxy for monodroid.
[mono.git] / mcs / class / System / System.Net / EndPointListener.cs
index 094f8a5f3ebe045df6b2800fb43cc8713d3b4eb7..909101100999098d3e2f99bff94e6306de28fcf3 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0 && SECURITY_DEP
+#if SECURITY_DEP
+
+#if MONOTOUCH
+using Mono.Security.Authenticode;
+#else
+extern alias MonoSecurity;
+using MonoSecurity::Mono.Security.Authenticode;
+#endif
 
 using System.IO;
 using System.Net.Sockets;
 using System.Collections;
+using System.Collections.Generic;
 using System.Security.Cryptography;
 using System.Security.Cryptography.X509Certificates;
 using System.Threading;
-using Mono.Security.Authenticode;
 
 namespace System.Net {
        sealed class EndPointListener
@@ -48,7 +55,7 @@ namespace System.Net {
                X509Certificate2 cert;
                AsymmetricAlgorithm key;
                bool secure;
-               Hashtable unregistered;
+               Dictionary<HttpConnection, HttpConnection> unregistered;
 
                public EndPointListener (IPAddress addr, int port, bool secure)
                {
@@ -66,7 +73,7 @@ namespace System.Net {
                        args.Completed += OnAccept;
                        sock.AcceptAsync (args);
                        prefixes = new Hashtable ();
-                       unregistered = new Hashtable ();
+                       unregistered = new Dictionary<HttpConnection, HttpConnection> ();
                }
 
                void LoadCertificateAndKey (IPAddress addr, int port)
@@ -276,7 +283,12 @@ namespace System.Net {
                {
                        sock.Close ();
                        lock (unregistered) {
-                               foreach (HttpConnection c in unregistered.Keys)
+                               //
+                               // Clone the list because RemoveConnection can be called from Close
+                               //
+                               var connections = new List<HttpConnection> (unregistered.Keys);
+
+                               foreach (HttpConnection c in connections)
                                        c.Close (true);
                                unregistered.Clear ();
                        }