From 4317291827b74bdb52ee80ba399d5af9aa88de36 Mon Sep 17 00:00:00 2001 From: RipleyTom Date: Fri, 28 Aug 2020 02:06:01 +0200 Subject: [PATCH] tcp_timeout_monitor deadlock fix (#8783) --- rpcs3/Emu/Cell/lv2/sys_net.cpp | 13 +++++++++---- rpcs3/Emu/NP/rpcn_client.cpp | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_net.cpp b/rpcs3/Emu/Cell/lv2/sys_net.cpp index 3f5b2f710b..0011c33aae 100644 --- a/rpcs3/Emu/Cell/lv2/sys_net.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_net.cpp @@ -255,7 +255,7 @@ static void network_clear_queue(ppu_thread& ppu) // Object in charge of retransmiting packets for STREAM_P2P sockets class tcp_timeout_monitor { - public: +public: void add_message(s32 sock_id, const sockaddr_in *dst, std::vector data, u64 seq) { { @@ -306,6 +306,9 @@ class tcp_timeout_monitor else wakey.wait(lock); + if (abort) + return; + const auto now = std::chrono::system_clock::now(); // Check for messages that haven't been acked std::set rtt_increased; @@ -368,11 +371,12 @@ class tcp_timeout_monitor } } - public: +public: std::condition_variable wakey; - static constexpr auto thread_name = "Tcp Over Udp Timeout Manager Thread"sv; + static constexpr auto thread_name = "Tcp Over Udp Timeout Manager Thread"sv; + std::atomic abort = false; - private: +private: std::mutex data_mutex; // List of outgoing messages struct message @@ -835,6 +839,7 @@ struct network_thread WSACleanup(); #endif auto tcpm = g_fxo->get>(); + tcpm->abort = true; tcpm->wakey.notify_one(); } diff --git a/rpcs3/Emu/NP/rpcn_client.cpp b/rpcs3/Emu/NP/rpcn_client.cpp index 498f689f0b..b6251d6c8f 100644 --- a/rpcs3/Emu/NP/rpcn_client.cpp +++ b/rpcs3/Emu/NP/rpcn_client.cpp @@ -52,10 +52,10 @@ rpcn_client::~rpcn_client() std::string rpcn_client::get_wolfssl_error(int error) { - std::string error_string(80, '\0'); + char error_string[80]{}; auto wssl_err = wolfSSL_get_error(wssl, error); wolfSSL_ERR_error_string(wssl_err, &error_string[0]); - return error_string; + return std::string(error_string); } void rpcn_client::disconnect()