2009-12-21 Gonzalo Paniagua Javier <gonzalo@novell.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Mon, 21 Dec 2009 17:12:57 +0000 (17:12 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Mon, 21 Dec 2009 17:12:57 +0000 (17:12 -0000)
* WebConnectionGroup.cs:
* ServicePoint.cs: implemented CloseConnectionGroup().

svn path=/trunk/mcs/; revision=148813

mcs/class/System/System.Net/ChangeLog
mcs/class/System/System.Net/ServicePoint.cs
mcs/class/System/System.Net/WebConnectionGroup.cs

index 494d1f1bd935f94257ed4be13d32791a961c56f2..da2cd79773d88a08dd982a736227993883ca7469 100644 (file)
@@ -1,3 +1,8 @@
+2009-12-21 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * WebConnectionGroup.cs:
+       * ServicePoint.cs: implemented CloseConnectionGroup().
+
 2009-12-04  Sebastien Pouliot  <sebastien@ximian.com>
 
        * System.Net/DnsEndPoint.cs: Moved from System.Net (where the
index 88be5a7ec71e32ec867f736332aa4dcf2d2425ec..740b8402a6b57c8c84cbf5f163049f754fd23bba 100644 (file)
@@ -298,10 +298,17 @@ namespace System.Net
                }
 #endif
 #if NET_2_0
-               [MonoNotSupported ("")]
                public bool CloseConnectionGroup (string connectionGroupName)
                {
-                       throw new NotImplementedException ();
+                       lock (locker) {
+                               WebConnectionGroup cncGroup = GetConnectionGroup (connectionGroupName);
+                               if (cncGroup != null) {
+                                       cncGroup.Close ();
+                                       return true;
+                               }
+                       }
+
+                       return false;
                }
 #endif
 
index 96bc94f79aa1de3657ca36e4e07975c129fd76f0..f98144db88f122fd0bd1c491ba58be3ee48d4c74 100644 (file)
@@ -51,6 +51,26 @@ namespace System.Net
                        queue = new Queue ();
                }
 
+               public void Close ()
+               {
+                       //TODO: what do we do with the queue? Empty it out and abort the requests?
+                       //TODO: abort requests or wait for them to finish
+                       lock (connections) {
+                               WeakReference cncRef = null;
+
+                               int end = connections.Count;
+                               ArrayList removed = null;
+                               for (int i = 0; i < end; i++) {
+                                       cncRef = (WeakReference) connections [i];
+                                       WebConnection cnc = cncRef.Target as WebConnection;
+                                       if (cnc != null) {
+                                               cnc.Close (false);
+                                       }
+                               }
+                               connections.Clear ();
+                       }
+               }
+
                public WebConnection GetConnection (HttpWebRequest request)
                {
                        WebConnection cnc = null;