diff options
| author | Thog <me@thog.eu> | 2019-12-22 20:33:59 +0100 |
|---|---|---|
| committer | jduncanator <1518948+jduncanator@users.noreply.github.com> | 2019-12-23 06:33:59 +1100 |
| commit | bce8972e7a42687c2add1bd939d2c8b2441dc5f1 (patch) | |
| tree | 6383f055717eb283937e0d0b4d28c7042d3567ea | |
| parent | bd010869a5e6005331be2f6f3ed0e72dfc006d41 (diff) | |
Fix an endge case in bsd IClient::Poll implementation (#848)
This add some code to handle usage of poll without any fds.
This is required by Dark Souls Remastered main loop logic as it's
calling it without any fds during initialization.
===
General system stability improvements to enhance the user's experience.
| -rw-r--r-- | Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs index af9b3881..b2b3d052 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs @@ -1,11 +1,12 @@ -using Ryujinx.Common; -using Ryujinx.Common.Logging; +using Ryujinx.Common.Logging; using Ryujinx.HLE.Utilities; +using System; using System.Buffers.Binary; using System.Collections.Generic; using System.Net; using System.Net.Sockets; using System.Text; +using System.Threading; namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { @@ -379,13 +380,26 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd } } - try + if (fdsCount != 0) + { + try + { + System.Net.Sockets.Socket.Select(readEvents, writeEvents, errorEvents, timeout); + } + catch (SocketException exception) + { + return WriteWinSock2Error(context, (WsaError)exception.ErrorCode); + } + } + else if (timeout == -1) { - System.Net.Sockets.Socket.Select(readEvents, writeEvents, errorEvents, timeout); + // FIXME: If we get a timeout of -1 and there is no fds to wait on, this should kill the KProces. (need to check that with re) + throw new InvalidOperationException(); } - catch (SocketException exception) + else { - return WriteWinSock2Error(context, (WsaError)exception.ErrorCode); + // FIXME: We should make the KThread sleep but we can't do much about it yet. + Thread.Sleep(timeout); } for (int i = 0; i < fdsCount; i++) |
