Author: gonzalo
Date: 2005-05-03 05:54:10 -0400 (Tue, 03 May 2005)
New Revision: 43917

Modified:
   trunk/mcs/class/System/System.Net.Sockets/ChangeLog
   trunk/mcs/class/System/System.Net.Sockets/Socket.cs
Log:
2005-05-03 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>

        * Socket.cs: if there are outstanding aio requests and one of them gets
        an ObjectDisposedException, throw the same exception for the rest.



Modified: trunk/mcs/class/System/System.Net.Sockets/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Net.Sockets/ChangeLog 2005-05-03 09:41:51 UTC 
(rev 43916)
+++ trunk/mcs/class/System/System.Net.Sockets/ChangeLog 2005-05-03 09:54:10 UTC 
(rev 43917)
@@ -1,3 +1,8 @@
+2005-05-03 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+       * Socket.cs: if there are outstanding aio requests and one of them gets
+       an ObjectDisposedException, throw the same exception for the rest.
+
 2005-05-02 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
 
        * Socket.cs: removed hack added to fix bug #53229 (more than a year ago)

Modified: trunk/mcs/class/System/System.Net.Sockets/Socket.cs
===================================================================
--- trunk/mcs/class/System/System.Net.Sockets/Socket.cs 2005-05-03 09:41:51 UTC 
(rev 43916)
+++ trunk/mcs/class/System/System.Net.Sockets/Socket.cs 2005-05-03 09:54:10 UTC 
(rev 43917)
@@ -103,6 +103,24 @@
                                }
                        }
 
+                       void CompleteAllOnDispose (Queue queue)
+                       {
+                               object [] pending = queue.ToArray ();
+                               queue.Clear ();
+
+                               WaitCallback cb;
+                               for (int i = 0; i < pending.Length; i++) {
+                                       SocketAsyncResult ares = 
(SocketAsyncResult) pending [i];
+                                       cb = new WaitCallback 
(ares.CompleteDisposed);
+                                       ThreadPool.QueueUserWorkItem (cb, null);
+                               }
+                       }
+
+                       void CompleteDisposed (object unused)
+                       {
+                               Complete ();
+                       }
+
                        public void Complete ()
                        {
                                if (operation != SocketOperation.Receive && 
Sock.disposed)
@@ -124,8 +142,12 @@
                                                queue.Dequeue (); // remove 
ourselves
                                                if (queue.Count > 0) {
                                                        req = 
(SocketAsyncResult) queue.Peek ();
-                                                       Worker worker = new 
Worker (req);
-                                                       sac = GetDelegate 
(worker, req.operation);
+                                                       if (!Sock.disposed) {
+                                                               Worker worker = 
new Worker (req);
+                                                               sac = 
GetDelegate (worker, req.operation);
+                                                       } else {
+                                                               
CompleteAllOnDispose (queue);
+                                                       }
                                                }
                                        }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to