Fix some closesocket bugs

This commit is contained in:
Henrik Rydgård 2025-01-07 23:12:40 +01:00
parent 8505e24812
commit fcb3d636b4

View file

@ -798,10 +798,17 @@ static int sceNetInetClose(int socket) {
return hleLogError(Log::sceNet, ERROR_INET_EBADF, "Bad socket #%d", socket);
}
int retVal = closesocket(socket);
int retVal = closesocket(inetSock->sock);
if (retVal == 0) {
inetSock->sock = 0;
inetSock->state = SocketState::Unused;
} else {
ERROR_LOG(Log::sceNet, "closesocket(%d) failed (socket=%d)", inetSock->sock, socket);
}
return hleLogSuccessI(Log::sceNet, retVal);
}
// TODO: How is this different than just sceNetInetClose?
static int sceNetInetCloseWithRST(int socket) {
WARN_LOG(Log::sceNet, "UNTESTED %s(%i) at %08x", __FUNCTION__, socket, currentMIPS->pc);
@ -816,6 +823,12 @@ static int sceNetInetCloseWithRST(int socket) {
sl.l_linger = 0; // timeout interval in seconds
setsockopt(inetSock->sock, SOL_SOCKET, SO_LINGER, (const char*)&sl, sizeof(sl));
int retVal = closesocket(inetSock->sock);
if (retVal == 0) {
inetSock->sock = 0;
inetSock->state = SocketState::Unused;
} else {
ERROR_LOG(Log::sceNet, "closesocket(%d) failed (socket=%d)", inetSock->sock, socket);
}
return hleLogSuccessI(Log::sceNet, retVal);
}