From 78ffb973b1c488d2f112425c75fe96c1e5d2cd50 Mon Sep 17 00:00:00 2001 From: LibretroAdmin <105389611+LibretroAdmin@users.noreply.github.com> Date: Mon, 10 Oct 2022 18:04:05 +0200 Subject: [PATCH] Add WIIU ifdef for socket_connect_with_timeout and revert (#14503) else default codepath --- libretro-common/net/net_socket.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index d6d19d2af9..0ad03a2495 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -762,15 +762,21 @@ bool socket_connect_with_timeout(int fd, void *data, int timeout) return false; #elif defined(_3DS) /* libctru getsockopt does not return expected value */ - if (connect(fd, addr->ai_addr, addr->ai_addrlen) < 0 && errno != EISCONN) + if ((connect(fd, addr->ai_addr, addr->ai_addrlen) < 0) && errno != EISCONN) + return false; +#elif defined(WIIU) + /* On WiiU, getsockopt() returns -1 and sets lastsocketerr() (Wii's + * equivalent to errno) to 16. */ + if ((connect(fd, addr->ai_addr, addr->ai_addrlen) == -1) + && socketlasterr() != SO_EISCONN) return false; #else { int error = -1; socklen_t errsz = sizeof(error); - /* Only error out here if the getsockopt() call succeeds and error is still set. */ - if(!getsockopt(fd, SOL_SOCKET, SO_ERROR, (char*)&error, &errsz) && error) + getsockopt(fd, SOL_SOCKET, SO_ERROR, (char*)&error, &errsz); + if (error) return false; } #endif