2009-01-21 Geoff Norton <gnorton@novell.com>
authorGeoff Norton <grompf@sublimeintervention.com>
Thu, 22 Jan 2009 04:27:43 +0000 (04:27 -0000)
committerGeoff Norton <grompf@sublimeintervention.com>
Thu, 22 Jan 2009 04:27:43 +0000 (04:27 -0000)
        * WebClient_2_1.cs: Make the ManualResetEvent local to the callback
        because a WebClient can be reused causing a wait-handle race here
        allowing a delegate to get collected causing a crash.

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

mcs/class/System.Net/System.Net/ChangeLog
mcs/class/System.Net/System.Net/WebClient_2_1.cs

index c8695c9825f1a3393d7f97ade2f7c164fb8fcbb9..24eb99d5496b85801cea7107ee03ee2ab6de21f1 100644 (file)
@@ -1,3 +1,9 @@
+2009-01-21  Geoff Norton  <gnorton@novell.com>
+
+       * WebClient_2_1.cs: Make the ManualResetEvent local to the callback
+       because a WebClient can be reused causing a wait-handle race here
+       allowing a delegate to get collected causing a crash.
+
 2009-01-21  Chris Toshok  <toshok@ximian.com>
 
        * WebClient_2_1.cs: add 1 method back in, CancelAsync.
index 2d535bbae715b1cc177963f28321e7960702a612..3363e549712f54be63d42469645f6d237049d21d 100644 (file)
@@ -1421,13 +1421,13 @@ namespace System.Net
                        }
                }
                
-               private ManualResetEvent wait_event = new ManualResetEvent (false);
                private object callback_args;
 
                protected virtual void OnOpenReadCompleted (OpenReadCompletedEventArgs args)
                {
                        CompleteAsync ();
                        if (OpenReadCompleted != null) {
+                               ManualResetEvent wait_event = new ManualResetEvent (false);
                                GSourceFunc callback = (GSourceFunc) delegate (IntPtr ctx) { OpenReadCompleted (this, (OpenReadCompletedEventArgs) callback_args); wait_event.Set (); return false; };
                                callback_args = args;
 
@@ -1447,6 +1447,7 @@ namespace System.Net
                {
                        CompleteAsync ();
                        if (DownloadStringCompleted != null) {
+                               ManualResetEvent wait_event = new ManualResetEvent (false);
                                GSourceFunc callback = (GSourceFunc) delegate (IntPtr ctx) { DownloadStringCompleted (this, (DownloadStringCompletedEventArgs) callback_args); wait_event.Set (); return false; };
                                callback_args = args;