mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 23:41:26 +12:00
sys_net: add a workaround for WSAPoll with timeout
Don't call WSAPoll with empty socket list.
This commit is contained in:
parent
45dc5d9b02
commit
01b1b21efd
1 changed files with 18 additions and 0 deletions
|
@ -83,7 +83,25 @@ void fmt_class_string<sys_net_error>::format(std::string& out, u64 arg)
|
||||||
// Workaround function for WSAPoll not reporting failed connections
|
// Workaround function for WSAPoll not reporting failed connections
|
||||||
void windows_poll(pollfd* fds, unsigned long nfds, int timeout, bool* connecting)
|
void windows_poll(pollfd* fds, unsigned long nfds, int timeout, bool* connecting)
|
||||||
{
|
{
|
||||||
|
// Don't call WSAPoll with zero nfds (errors 10022 or 10038)
|
||||||
|
if (std::none_of(fds, fds + nfds, [](pollfd& pfd) { return pfd.fd != INVALID_SOCKET; }))
|
||||||
|
{
|
||||||
|
if (timeout > 0)
|
||||||
|
{
|
||||||
|
Sleep(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int r = ::WSAPoll(fds, nfds, timeout);
|
int r = ::WSAPoll(fds, nfds, timeout);
|
||||||
|
|
||||||
|
if (r == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
sys_net.error("WSAPoll failed: %u", WSAGetLastError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned long i = 0; i < nfds; i++)
|
for (unsigned long i = 0; i < nfds; i++)
|
||||||
{
|
{
|
||||||
if (connecting[i])
|
if (connecting[i])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue