[System] Fixes ConnectAsync UnhandledEx
authorMarcos Henrich <marcos.henrich@xamarin.com>
Mon, 27 Jun 2016 09:00:01 +0000 (10:00 +0100)
committerMarcos Henrich <marcos.henrich@xamarin.com>
Mon, 27 Jun 2016 09:42:05 +0000 (10:42 +0100)
Fixes #41616

ConnectAsyncCallback now throws an exception when called a second time.
ConnectAsync reuses SocketAsyncEventArgs in BeginConnect which
already updates its state and calls ConnectAsyncCallback.

The changes make sure that ConnectAsyncCallback no longer called on
ConnectAsync catch block, while the state is still updated with the
exception.

mcs/class/System/System.Net.Sockets/Socket.cs

index c7576897189c0e6c30b155b2380569a1867cc119..07896d201380eea623b23d5a0ecfd9365798af18 100644 (file)
@@ -1328,7 +1328,7 @@ namespace System.Net.Sockets
                        if (e.RemoteEndPoint == null)
                                throw new ArgumentNullException ("remoteEP");
 
-                       InitSocketAsyncEventArgs (e, ConnectAsyncCallback, e, SocketOperation.Connect);
+                       InitSocketAsyncEventArgs (e, null, e, SocketOperation.Connect);
 
                        try {
                                IPAddress [] addresses;