Browse Source

[System] Fixes ConnectAsync UnhandledEx

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.
Marcos Henrich 9 years ago
parent
commit
992d27a8e6
1 changed files with 1 additions and 1 deletions
  1. 1 1
      mcs/class/System/System.Net.Sockets/Socket.cs

+ 1 - 1
mcs/class/System/System.Net.Sockets/Socket.cs

@@ -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;