Network/SocketImpl: Fix possible code errors (Posix)

This commit is contained in:
Lynix 2017-01-27 15:05:26 +01:00
parent 453ca77c1b
commit d8b7ff9fa6
1 changed files with 16 additions and 3 deletions

View File

@ -464,6 +464,9 @@ namespace Nz
if (byteRead == SOCKET_ERROR)
{
int errorCode = GetLastErrorCode();
if (errorCode == EAGAIN)
errorCode = EWOULDBLOCK;
switch (errorCode)
{
case EWOULDBLOCK:
@ -513,6 +516,9 @@ namespace Nz
if (byteRead == SOCKET_ERROR)
{
int errorCode = GetLastErrorCode();
if (errorCode == EAGAIN)
errorCode = EWOULDBLOCK;
switch (errorCode)
{
case EWOULDBLOCK:
@ -563,6 +569,8 @@ namespace Nz
if (byteSent == SOCKET_ERROR)
{
int errorCode = GetLastErrorCode();
if (errorCode == EAGAIN)
errorCode = EWOULDBLOCK;
switch (errorCode)
{
@ -595,7 +603,7 @@ namespace Nz
NazaraAssert(buffers && bufferCount > 0, "Invalid buffers");
StackAllocation memory = NazaraStackAllocation(bufferCount * sizeof(iovec));
iovec* sysBuffers = static_cast<iovec*>(memory.GetPtr());
struct iovec* sysBuffers = static_cast<struct iovec*>(memory.GetPtr());
for (std::size_t i = 0; i < bufferCount; ++i)
{
sysBuffers[i].iov_base = buffers[i].data;
@ -615,6 +623,9 @@ namespace Nz
if (byteSent == SOCKET_ERROR)
{
int errorCode = GetLastErrorCode();
if (errorCode == EAGAIN)
errorCode = EWOULDBLOCK;
switch (errorCode)
{
case EWOULDBLOCK:
@ -652,6 +663,8 @@ namespace Nz
if (byteSent == SOCKET_ERROR)
{
int errorCode = GetLastErrorCode();
if (errorCode == EAGAIN)
errorCode = EWOULDBLOCK;
switch (errorCode)
{