Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Köplinger <alex.koeplinger@outlook.com>2018-01-09 17:45:47 +0300
committerMarek Safar <marek.safar@gmail.com>2018-01-09 19:33:39 +0300
commit3f5fd4287be28a32314262a6f8dcb5bdde86e0b1 (patch)
tree3ed6edf778b436b6d4afed0fc8b26288ec80db44
parent253f2e9b27e23a9b4fce0a2bd1fd3fdcfc477094 (diff)
[System] Set exception on Finish*Failure in SocketAsyncEventArgs (#6462)
Follow up to https://github.com/mono/mono/pull/6431, we should capture the exception that is passed to the methods. Copied the SetResult() method that referencesource uses. (cherry picked from commit ad5703adfd84c309292d4c33a2fcaa5e60de9100)
-rw-r--r--mcs/class/System/System.Net.Sockets/SocketAsyncEventArgs.cs25
1 files changed, 25 insertions, 0 deletions
diff --git a/mcs/class/System/System.Net.Sockets/SocketAsyncEventArgs.cs b/mcs/class/System/System.Net.Sockets/SocketAsyncEventArgs.cs
index 534aff06207..d2c86104408 100644
--- a/mcs/class/System/System.Net.Sockets/SocketAsyncEventArgs.cs
+++ b/mcs/class/System/System.Net.Sockets/SocketAsyncEventArgs.cs
@@ -249,6 +249,8 @@ namespace System.Net.Sockets
internal void FinishConnectByNameSyncFailure (Exception exception, int bytesTransferred, SocketFlags flags)
{
+ SetResults (exception, bytesTransferred, flags);
+
if (current_socket != null)
current_socket.is_connected = false;
@@ -257,6 +259,8 @@ namespace System.Net.Sockets
internal void FinishOperationAsyncFailure (Exception exception, int bytesTransferred, SocketFlags flags)
{
+ SetResults (exception, bytesTransferred, flags);
+
if (current_socket != null)
current_socket.is_connected = false;
@@ -274,8 +278,29 @@ namespace System.Net.Sockets
internal void SetResults (SocketError socketError, int bytesTransferred, SocketFlags flags)
{
SocketError = socketError;
+ ConnectByNameError = null;
+ BytesTransferred = bytesTransferred;
+ SocketFlags = flags;
+ }
+
+ internal void SetResults (Exception exception, int bytesTransferred, SocketFlags flags)
+ {
+ ConnectByNameError = exception;
BytesTransferred = bytesTransferred;
SocketFlags = flags;
+
+ if (exception == null)
+ {
+ SocketError = SocketError.Success;
+ }
+ else
+ {
+ var socketException = exception as SocketException;
+ if (socketException != null)
+ SocketError = socketException.SocketErrorCode;
+ else
+ SocketError = SocketError.SocketError;
+ }
}
}
}