Add logging in socket implementation (#661)

Adds logging to most Socket calls to help with debugging network
issues.

Shouldn't affect any functionality. There's a small chance it could spam
the log in some games.
This commit is contained in:
Vudjun 2025-02-16 07:03:44 +00:00 committed by GitHub
parent 66054dd225
commit 61975ca44d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 101 additions and 7 deletions

View file

@ -34,6 +34,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{
if (errorCode != LinuxError.SUCCESS)
{
if (errorCode != LinuxError.EWOULDBLOCK)
{
Logger.Warning?.Print(LogClass.ServiceBsd, $"Operation failed with error {errorCode}.");
}
result = -1;
}
@ -66,6 +70,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
BsdSocketType type = (BsdSocketType)context.RequestData.ReadInt32();
ProtocolType protocol = (ProtocolType)context.RequestData.ReadInt32();
Logger.Info?.PrintMsg(LogClass.ServiceBsd, $"Creating socket with domain={domain}, type={type}, protocol={protocol}");
BsdSocketCreationFlags creationFlags = (BsdSocketCreationFlags)((int)type >> (int)BsdSocketCreationFlags.FlagsShift);
type &= BsdSocketType.TypeMask;
@ -111,6 +117,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
if (exempt)
{
Logger.Info?.Print(LogClass.ServiceBsd, "Disconnecting exempt socket.");
newBsdSocket.Disconnect();
}
@ -797,7 +804,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{
errno = socket.Listen(backlog);
}
else
{
Logger.Warning?.PrintMsg(LogClass.ServiceBsd, $"Invalid socket fd '{socketFd}'.");
}
return WriteBsdResult(context, 0, errno);
}