Author: gonzalo
Date: 2005-04-10 19:17:26 -0400 (Sun, 10 Apr 2005)
New Revision: 42770

Modified:
   trunk/mcs/class/System/System.Net/ChangeLog
   trunk/mcs/class/System/System.Net/HttpWebRequest.cs
   trunk/mcs/class/System/System.Net/WebConnection.cs
Log:
2005-04-10 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>

        * WebConnection.cs:
        * HttpWebRequest.cs: now Abort() works properly. Fixes bug #74177.



Modified: trunk/mcs/class/System/System.Net/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Net/ChangeLog 2005-04-10 22:51:07 UTC (rev 
42769)
+++ trunk/mcs/class/System/System.Net/ChangeLog 2005-04-10 23:17:26 UTC (rev 
42770)
@@ -1,5 +1,10 @@
 2005-04-10 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
 
+       * WebConnection.cs:
+       * HttpWebRequest.cs: now Abort() works properly. Fixes bug #74177.
+
+2005-04-10 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
        * WebConnection.cs: fix some breakage from my last patch.
        * WebConnectionStream.cs: invoke the callback when done even in EndRead.
 

Modified: trunk/mcs/class/System/System.Net/HttpWebRequest.cs
===================================================================
--- trunk/mcs/class/System/System.Net/HttpWebRequest.cs 2005-04-10 22:51:07 UTC 
(rev 42769)
+++ trunk/mcs/class/System/System.Net/HttpWebRequest.cs 2005-04-10 23:17:26 UTC 
(rev 42770)
@@ -698,7 +698,7 @@
 
                        if (result.GotException)
                                throw result.Exception;
-                       
+
                        return result.Response;
                }
 
@@ -734,7 +734,7 @@
                        if (abortHandler != null) {
                                try {
                                        abortHandler (this, EventArgs.Empty);
-                               } catch {}
+                               } catch (Exception) {}
                                abortHandler = null;
                        }
 
@@ -988,13 +988,9 @@
 
                internal void SetResponseError (WebExceptionStatus status, 
Exception e, string where)
                {
+                       if (aborted)
+                               return;
                        string msg = String.Format ("Error getting response 
stream ({0}): {1}", where, status);
-                       if (webResponse != null) {
-                               if (e is WebException)
-                                       throw e;
-                               throw new WebException (msg, e, status, null);
-                       }
-                       
                        WebAsyncResult r = asyncRead;
                        if (r == null)
                                r = asyncWrite;

Modified: trunk/mcs/class/System/System.Net/WebConnection.cs
===================================================================
--- trunk/mcs/class/System/System.Net/WebConnection.cs  2005-04-10 22:51:07 UTC 
(rev 42769)
+++ trunk/mcs/class/System/System.Net/WebConnection.cs  2005-04-10 23:17:26 UTC 
(rev 42770)
@@ -51,6 +51,7 @@
                ServicePoint sPoint;
                Stream nstream;
                Socket socket;
+               object socketLock = new object ();
                WebExceptionStatus status;
                WebConnectionGroup group;
                bool busy;
@@ -98,7 +99,7 @@
                
                void Connect ()
                {
-                       lock (this) {
+                       lock (socketLock) {
                                if (socket != null && socket.Connected && 
status == WebExceptionStatus.Success) {
                                        // Take the chunked stream to the 
expected state (State.None)
                                        if (CanReuse () && CompleteChunkedRead 
()) {
@@ -286,7 +287,8 @@
                                req = Data.request;
 
                        Close (true);
-                       req.SetResponseError (st, e, where);
+                       if (req != null)
+                               req.SetResponseError (st, e, where);
                }
                
                static void ReadDone (IAsyncResult result)
@@ -858,7 +860,26 @@
 
                void Abort (object sender, EventArgs args)
                {
-                       HandleError (WebExceptionStatus.RequestCanceled, null, 
"Abort");
+                       lock (this) {
+                               if (Data.request == sender) {
+                                       HandleError 
(WebExceptionStatus.RequestCanceled, null, "Abort");
+                                       return;
+                               }
+
+                               lock (queue) {
+                                       if (queue.Count > 0 && queue.Peek () == 
sender) {
+                                               queue.Dequeue ();
+                                               return;
+                                       }
+
+                                       object [] old = queue.ToArray ();
+                                       queue.Clear ();
+                                       for (int i = old.Length - 1; i >= 0; 
i--) {
+                                               if (old [i] != sender)
+                                                       queue.Enqueue (old [i]);
+                                       }
+                               }
+                       }
                }
 
                internal bool Busy {

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

Reply via email to