Add logging in socket implementation #661
@ -92,16 +92,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
{
|
{
|
||||||
newSocket = new ManagedSocket(Socket.Accept());
|
newSocket = new ManagedSocket(Socket.Accept());
|
||||||
|
|
||||||
var remoteEndPoint = newSocket.RemoteEndPoint as IPEndPoint;
|
IPEndPoint remoteEndPoint = newSocket.RemoteEndPoint;
|
||||||
bool isLDNPrivateIP = remoteEndPoint.Address.ToString().StartsWith("192.168.");
|
bool isPrivateIp = remoteEndPoint.Address.ToString().StartsWith("192.168.");
|
||||||
if (isLDNPrivateIP)
|
Logger.Info?.PrintMsg(LogClass.ServiceBsd,
|
||||||
{
|
isPrivateIp
|
||||||
Logger.Info?.PrintMsg(LogClass.ServiceBsd, $"Accepted connection from {ProtocolType}/{remoteEndPoint.Address}:{remoteEndPoint.Port}");
|
? $"Accepted connection from {ProtocolType}/{remoteEndPoint.Address}:{remoteEndPoint.Port}"
|
||||||
}
|
: $"Accepted connection from {ProtocolType}/***:{remoteEndPoint.Port}");
|
||||||
else
|
|
||||||
{
|
|
||||||
Logger.Info?.PrintMsg(LogClass.ServiceBsd, $"Accepted connection from {ProtocolType}/***:{remoteEndPoint.Port}");
|
|
||||||
}
|
|
||||||
|
|
||||||
return LinuxError.SUCCESS;
|
return LinuxError.SUCCESS;
|
||||||
}
|
}
|
||||||
@ -111,7 +107,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
|
|
||||||
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception.ToString()}");
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
}
|
}
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
}
|
}
|
||||||
@ -130,7 +126,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
{
|
{
|
||||||
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception.ToString()}");
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
}
|
}
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
}
|
}
|
||||||
@ -168,7 +164,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
{
|
{
|
||||||
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception.ToString()}");
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
}
|
}
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
}
|
}
|
||||||
@ -177,13 +173,13 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
|
|
||||||
public void Disconnect()
|
public void Disconnect()
|
||||||
{
|
{
|
||||||
Logger.Info?.Print(LogClass.ServiceBsd, $"Socket disconnecting");
|
Logger.Info?.Print(LogClass.ServiceBsd, "Socket disconnecting");
|
||||||
Socket.Disconnect(true);
|
Socket.Disconnect(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Logger.Info?.Print(LogClass.ServiceBsd, $"Socket closed");
|
Logger.Info?.Print(LogClass.ServiceBsd, "Socket closed");
|
||||||
Socket.Close();
|
Socket.Close();
|
||||||
Socket.Dispose();
|
Socket.Dispose();
|
||||||
}
|
}
|
||||||
@ -202,7 +198,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
{
|
{
|
||||||
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception.ToString()}");
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
}
|
}
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
}
|
}
|
||||||
@ -225,13 +221,13 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
{
|
{
|
||||||
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception.ToString()}");
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
}
|
}
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasEmittedBlockingWarning = false;
|
private bool _hasEmittedBlockingWarning;
|
||||||
|
|
||||||
public LinuxError Receive(out int receiveSize, Span<byte> buffer, BsdSocketFlags flags)
|
public LinuxError Receive(out int receiveSize, Span<byte> buffer, BsdSocketFlags flags)
|
||||||
{
|
{
|
||||||
@ -247,10 +243,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
shouldBlockAfterOperation = true;
|
shouldBlockAfterOperation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Blocking && !hasEmittedBlockingWarning)
|
if (Blocking && !_hasEmittedBlockingWarning)
|
||||||
{
|
{
|
||||||
Logger.Warning?.PrintMsg(LogClass.ServiceBsd, "Blocking socket operations are not yet working properly. Expect network errors.");
|
Logger.Warning?.PrintMsg(LogClass.ServiceBsd, "Blocking socket operations are not yet working properly. Expect network errors.");
|
||||||
hasEmittedBlockingWarning = true;
|
_hasEmittedBlockingWarning = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
receiveSize = Socket.Receive(buffer, ConvertBsdSocketFlags(flags));
|
receiveSize = Socket.Receive(buffer, ConvertBsdSocketFlags(flags));
|
||||||
@ -261,7 +257,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
{
|
{
|
||||||
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception.ToString()}");
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
}
|
}
|
||||||
receiveSize = -1;
|
receiveSize = -1;
|
||||||
|
|
||||||
@ -294,10 +290,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
shouldBlockAfterOperation = true;
|
shouldBlockAfterOperation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Blocking && !hasEmittedBlockingWarning)
|
if (Blocking && !_hasEmittedBlockingWarning)
|
||||||
{
|
{
|
||||||
Logger.Warning?.PrintMsg(LogClass.ServiceBsd, "Blocking socket operations are not yet working properly. Expect network errors.");
|
Logger.Warning?.PrintMsg(LogClass.ServiceBsd, "Blocking socket operations are not yet working properly. Expect network errors.");
|
||||||
hasEmittedBlockingWarning = true;
|
_hasEmittedBlockingWarning = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Socket.IsBound)
|
if (!Socket.IsBound)
|
||||||
@ -316,7 +312,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
{
|
{
|
||||||
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception.ToString()}");
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
}
|
}
|
||||||
receiveSize = -1;
|
receiveSize = -1;
|
||||||
|
|
||||||
@ -343,7 +339,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
{
|
{
|
||||||
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception.ToString()}");
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
}
|
}
|
||||||
sendSize = -1;
|
sendSize = -1;
|
||||||
|
|
||||||
@ -363,7 +359,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
{
|
{
|
||||||
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception.ToString()}");
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
}
|
}
|
||||||
sendSize = -1;
|
sendSize = -1;
|
||||||
|
|
||||||
@ -404,7 +400,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
{
|
{
|
||||||
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception.ToString()}");
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
}
|
}
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
}
|
}
|
||||||
@ -454,7 +450,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
{
|
{
|
||||||
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception.ToString()}");
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
}
|
}
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
}
|
}
|
||||||
@ -590,7 +586,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
{
|
{
|
||||||
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception.ToString()}");
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
}
|
}
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
}
|
}
|
||||||
@ -632,7 +628,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
{
|
{
|
||||||
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception.ToString()}");
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
}
|
}
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user