diff options
author | Alexander Köplinger <alex.koeplinger@outlook.com> | 2018-01-09 17:45:47 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-09 17:45:47 +0300 |
commit | ad5703adfd84c309292d4c33a2fcaa5e60de9100 (patch) | |
tree | fd83dfc2d8d01f5851d2dc27202e9cc052af937a /mcs/class/System | |
parent | e6a167a7cd15ecd424e76e8d39856cf355066fb7 (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.
Diffstat (limited to 'mcs/class/System')
-rw-r--r-- | mcs/class/System/System.Net.Sockets/SocketAsyncEventArgs.cs | 25 |
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; + } } } } |