From 3e9ac1aaf33c814df7b1720b239205f1988c8dbc Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Mon, 26 Feb 2024 20:45:40 -0800 Subject: [PATCH] fix tapserver SIGPIPE handling on Linux --- Source/Core/Core/HW/EXI/BBA/TAPServerConnection.cpp | 10 ++++++++-- Source/Core/Core/HW/EXI/BBA/TAPServerConnection.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/HW/EXI/BBA/TAPServerConnection.cpp b/Source/Core/Core/HW/EXI/BBA/TAPServerConnection.cpp index 077b306db4..1f76340222 100644 --- a/Source/Core/Core/HW/EXI/BBA/TAPServerConnection.cpp +++ b/Source/Core/Core/HW/EXI/BBA/TAPServerConnection.cpp @@ -32,7 +32,7 @@ using ws_ssize_t = int; using ws_ssize_t = ssize_t; #endif -#ifdef __LINUX__ +#ifdef __linux__ #define SEND_FLAGS MSG_NOSIGNAL #else #define SEND_FLAGS 0 @@ -262,7 +262,13 @@ void TAPServerConnection::ReadThreadHandler() timeval timeout; timeout.tv_sec = 0; timeout.tv_usec = 50000; - if (select(m_fd + 1, &rfds, nullptr, nullptr, &timeout) <= 0) + int select_res = select(m_fd + 1, &rfds, nullptr, nullptr, &timeout); + if (select_res < 0) + { + ERROR_LOG_FMT(SP1, "Can\'t poll tapserver fd: {}", Common::StrNetworkError()); + break; + } + if (select_res == 0) continue; // The tapserver protocol is very simple: there is a 16-bit little-endian diff --git a/Source/Core/Core/HW/EXI/BBA/TAPServerConnection.h b/Source/Core/Core/HW/EXI/BBA/TAPServerConnection.h index f622c312c9..42c2020ffa 100644 --- a/Source/Core/Core/HW/EXI/BBA/TAPServerConnection.h +++ b/Source/Core/Core/HW/EXI/BBA/TAPServerConnection.h @@ -40,7 +40,7 @@ private: }; const std::string m_destination; - const std::function m_recv_cb; + const RecvCallback m_recv_cb; const std::size_t m_max_frame_size; Common::SocketContext m_socket_context;