Network/SocketPoller: Uniformize behavior accross platforms

On Windows, a closed connection will mark as ready for read/write
This commit is contained in:
Jérôme Leclercq 2017-10-04 10:53:51 +02:00
parent 99d21b8722
commit f17be35cab
3 changed files with 16 additions and 9 deletions

View File

@ -111,9 +111,6 @@ namespace Nz
if (m_events[i].events & (EPOLLOUT | EPOLLERR))
m_readyToWriteSockets.insert(m_events[i].data.fd);
if (m_events[i].events & EPOLLERR)
NazaraWarning("Descriptor " + String::Number(m_events[i].data.fd) + " was returned by epoll with EPOLLERR status");
}
else
{

View File

@ -90,12 +90,12 @@ namespace Nz
int socketRemaining = activeSockets;
for (PollSocket& entry : m_sockets)
{
if (entry.revents != 0)
if (entry.revents & (POLLRDNORM | POLLWRNORM | POLLHUP | POLLERR))
{
if (entry.revents & POLLRDNORM)
if (entry.revents & (POLLRDNORM | POLLHUP | POLLERR))
m_readyToReadSockets.insert(entry.fd);
if (entry.revents & POLLWRNORM)
if (entry.revents & (POLLWRNORM | POLLERR))
m_readyToWriteSockets.insert(entry.fd);
entry.revents = 0;
@ -103,6 +103,11 @@ namespace Nz
if (--socketRemaining == 0)
break;
}
else
{
NazaraWarning("Socket " + String::Number(entry.fd) + " was returned by WSAPoll without POLLRDNORM nor POLLWRNORM events (events: 0x" + String::Number(entry.events, 16) + ')');
activeSockets--;
}
}
}

View File

@ -143,12 +143,12 @@ namespace Nz
int socketRemaining = activeSockets;
for (PollSocket& entry : m_sockets)
{
if (entry.revents != 0)
if (entry.revents & (POLLRDNORM | POLLWRNORM | POLLHUP | POLLERR))
{
if (entry.revents & POLLRDNORM)
if (entry.revents & (POLLRDNORM | POLLHUP | POLLERR))
m_readyToReadSockets.insert(entry.fd);
if (entry.revents & POLLWRNORM)
if (entry.revents & (POLLWRNORM | POLLERR))
m_readyToWriteSockets.insert(entry.fd);
entry.revents = 0;
@ -156,6 +156,11 @@ namespace Nz
if (--socketRemaining == 0)
break;
}
else
{
NazaraWarning("Socket " + String::Number(entry.fd) + " was returned by WSAPoll without POLLRDNORM nor POLLWRNORM events (events: 0x" + String::Number(entry.events, 16) + ')');
activeSockets--;
}
}
}