Logging messages change errno, save the return value from recv before logging

This commit is contained in:
Pierre Bourdon 2012-02-19 19:31:55 +01:00
parent 81d7eefd6a
commit 31788791e8
1 changed files with 26 additions and 23 deletions

View File

@ -1355,7 +1355,6 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommandV(SIOCtlVBuffer& CommandBuffer
u32 sock = Memory::Read_U32(_BufferIn);
u32 flags = Memory::Read_U32(_BufferIn + 4);
char *buf = (char *)Memory::GetPointer(_BufferOut);
int len = BufferOutSize;
struct sockaddr_in addr;
@ -1366,7 +1365,26 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommandV(SIOCtlVBuffer& CommandBuffer
fromlen = BufferOutSize2 >= sizeof(struct sockaddr) ? BufferOutSize2 : sizeof(struct sockaddr);
}
if (fromlen)
{
WARN_LOG(WII_IPC_NET, "IOCTLV_SO_RECVFROM "
"Socket: %08X, Flags: %08X, "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferOut: (%08x, %i), BufferOut2: (%08x, %i)",
sock, flags,
_BufferIn, BufferInSize, _BufferIn2, BufferInSize2,
_BufferOut, BufferOutSize, _BufferOut2, BufferOutSize2);
}
else
{
WARN_LOG(WII_IPC_NET, "IOCTLV_SO_RECV "
"Socket: %08X, Flags: %08X, "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferOut: (%08x, %i), BufferOut2: (%08x, %i)",
sock, flags,
_BufferIn, BufferInSize, _BufferIn2, BufferInSize2,
_BufferOut, BufferOutSize, _BufferOut2, BufferOutSize2);
}
if (flags != 2)
flags = 0;
@ -1382,33 +1400,18 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommandV(SIOCtlVBuffer& CommandBuffer
}
#endif
ret = recvfrom(sock, buf, len, flags,
fromlen ? (struct sockaddr*) &addr : NULL, fromlen ? &fromlen : 0);
fromlen ? (struct sockaddr*) &addr : NULL,
fromlen ? &fromlen : 0);
int err = getNetErrorCode(ret, fromlen ? "SO_RECVFROM" : "SO_RECV", true);
if (BufferOutSize2 != 0)
{
addr.sin_family = (addr.sin_family << 8) | (BufferOutSize2&0xFF);
Memory::WriteBigEData((u8*)&addr, _BufferOut2, BufferOutSize2);
}
if(fromlen){
WARN_LOG(WII_IPC_NET, "IOCTLV_SO_RECVFROM = %d "
"Socket: %08X, Flags: %08X, "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferOut: (%08x, %i), BufferOut2: (%08x, %i)",
ret, sock, flags,
_BufferIn, BufferInSize, _BufferIn2, BufferInSize2,
_BufferOut, BufferOutSize, _BufferOut2, BufferOutSize2);
}else{
WARN_LOG(WII_IPC_NET, "IOCTLV_SO_RECV = %d "
"Socket: %08X, Flags: %08X, "
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
"BufferOut: (%08x, %i), BufferOut2: (%08x, %i)",
ret, sock, flags,
_BufferIn, BufferInSize, _BufferIn2, BufferInSize2,
_BufferOut, BufferOutSize, _BufferOut2, BufferOutSize2);
}
return getNetErrorCode(ret, fromlen ? "SO_RECVFROM" : "SO_RECV", true);
break;
return err;
}
case IOCTLV_SO_GETADDRINFO: