summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2020-06-19 03:48:13 +0200
committerGitHub <noreply@github.com>2020-06-19 03:48:13 +0200
commitebd08c82dbf634db06a6ae037e4eb2aa325e43f2 (patch)
tree5e6d2cd21d3c532455000591fa2aae75754c90a1 /Source/Core
parentd6341c4117d59565b3bc42264d6fa5ba7e796526 (diff)
parentdc2733ce249f17afe97b80372b3306c3c5b27af1 (diff)
Merge pull request #8796 from sepalani/so-econn
Socket: Fix ENOTCONN error code
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/IOS/Network/Socket.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/Source/Core/Core/IOS/Network/Socket.cpp b/Source/Core/Core/IOS/Network/Socket.cpp
index 2435486182..b2ff4c6795 100644
--- a/Source/Core/Core/IOS/Network/Socket.cpp
+++ b/Source/Core/Core/IOS/Network/Socket.cpp
@@ -51,7 +51,12 @@ char* WiiSockMan::DecodeError(s32 ErrorCode)
#endif
}
-static s32 TranslateErrorCode(s32 native_error, bool isRW)
+// The following functions can return
+// - EAGAIN / EWOULDBLOCK: send(to), recv(from), accept
+// - EINPROGRESS: connect, bind
+// - WSAEWOULDBLOCK: send(to), recv(from), accept, connect
+// On Windows is_rw is used to correct the return value for connect
+static s32 TranslateErrorCode(s32 native_error, bool is_rw)
{
switch (native_error)
{
@@ -67,7 +72,7 @@ static s32 TranslateErrorCode(s32 native_error, bool isRW)
case ERRORCODE(EISCONN):
return -SO_EISCONN;
case ERRORCODE(ENOTCONN):
- return -SO_EAGAIN; // After proper blocking SO_EAGAIN shouldn't be needed...
+ return -SO_ENOTCONN;
case ERRORCODE(EINPROGRESS):
return -SO_EINPROGRESS;
case ERRORCODE(EALREADY):
@@ -86,14 +91,7 @@ static s32 TranslateErrorCode(s32 native_error, bool isRW)
case ERRORCODE(ENETRESET):
return -SO_ENETRESET;
case EITHER(WSAEWOULDBLOCK, EAGAIN):
- if (isRW)
- {
- return -SO_EAGAIN; // EAGAIN
- }
- else
- {
- return -SO_EINPROGRESS; // EINPROGRESS
- }
+ return (is_rw) ? (-SO_EAGAIN) : (-SO_EINPROGRESS);
default:
return -1;
}