diff --git a/rpcs3/Emu/Cell/lv2/sys_net.cpp b/rpcs3/Emu/Cell/lv2/sys_net.cpp index bc9e475cad..8ac67bc072 100644 --- a/rpcs3/Emu/Cell/lv2/sys_net.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_net.cpp @@ -255,11 +255,6 @@ struct network_thread lv2_socket& sock = *socklist[i]; -#ifdef _WIN32 - if (was_connecting[i] && !connecting[i]) - sock.is_connecting = false; -#endif - if (fds[i].revents & (POLLIN | POLLHUP) && socklist[i]->events.test_and_reset(lv2_socket::poll::read)) events += lv2_socket::poll::read; if (fds[i].revents & POLLOUT && socklist[i]->events.test_and_reset(lv2_socket::poll::write)) @@ -271,6 +266,11 @@ struct network_thread { std::lock_guard lock(socklist[i]->mutex); +#ifdef _WIN32 + if (was_connecting[i] && !connecting[i]) + sock.is_connecting = false; +#endif + for (auto it = socklist[i]->queue.begin(); events && it != socklist[i]->queue.end();) { if (it->second(events)) @@ -313,6 +313,10 @@ struct network_thread for (std::size_t i = 0; i < socklist.size(); i++) { +#ifdef _WIN32 + std::lock_guard lock(socklist[i]->mutex); +#endif + auto events = socklist[i]->events.load(); fds[i].fd = events ? socklist[i]->socket : -1; @@ -576,14 +580,14 @@ error_code sys_net_bnet_connect(ppu_thread& ppu, s32 s, vm::ptr events) -> bool { @@ -612,6 +616,9 @@ error_code sys_net_bnet_connect(ppu_thread& ppu, s32 s, vm::ptr events) -> bool {