Fix games freezing after initializing LDN 1021 times (#5787)
* Close handle for stateChangeEvent on Finalize * Properly dispose NetworkClient before setting it to null
This commit is contained in:
parent
ac4f2c1e70
commit
4e2bb13080
1 changed files with 16 additions and 10 deletions
|
@ -29,6 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
||||||
private const bool IsDevelopment = false;
|
private const bool IsDevelopment = false;
|
||||||
|
|
||||||
private readonly KEvent _stateChangeEvent;
|
private readonly KEvent _stateChangeEvent;
|
||||||
|
private int _stateChangeEventHandle;
|
||||||
|
|
||||||
private NetworkState _state;
|
private NetworkState _state;
|
||||||
private DisconnectReason _disconnectReason;
|
private DisconnectReason _disconnectReason;
|
||||||
|
@ -277,12 +278,12 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
||||||
// AttachStateChangeEvent() -> handle<copy>
|
// AttachStateChangeEvent() -> handle<copy>
|
||||||
public ResultCode AttachStateChangeEvent(ServiceCtx context)
|
public ResultCode AttachStateChangeEvent(ServiceCtx context)
|
||||||
{
|
{
|
||||||
if (context.Process.HandleTable.GenerateHandle(_stateChangeEvent.ReadableEvent, out int stateChangeEventHandle) != Result.Success)
|
if (_stateChangeEventHandle == 0 && context.Process.HandleTable.GenerateHandle(_stateChangeEvent.ReadableEvent, out _stateChangeEventHandle) != Result.Success)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Out of handles!");
|
throw new InvalidOperationException("Out of handles!");
|
||||||
}
|
}
|
||||||
|
|
||||||
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(stateChangeEventHandle);
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_stateChangeEventHandle);
|
||||||
|
|
||||||
// Returns ResultCode.InvalidArgument if handle is null, doesn't occur in our case since we already throw an Exception.
|
// Returns ResultCode.InvalidArgument if handle is null, doesn't occur in our case since we already throw an Exception.
|
||||||
|
|
||||||
|
@ -964,6 +965,12 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
||||||
SetDisconnectReason(DisconnectReason.None);
|
SetDisconnectReason(DisconnectReason.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_stateChangeEventHandle != 0)
|
||||||
|
{
|
||||||
|
context.Process.HandleTable.CloseHandle(_stateChangeEventHandle);
|
||||||
|
_stateChangeEventHandle = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return resultCode;
|
return resultCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1021,7 +1028,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
||||||
|
|
||||||
SetState(NetworkState.None);
|
SetState(NetworkState.None);
|
||||||
|
|
||||||
NetworkClient?.DisconnectAndStop();
|
NetworkClient?.Dispose();
|
||||||
NetworkClient = null;
|
NetworkClient = null;
|
||||||
|
|
||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
|
@ -1072,7 +1079,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// NOTE: Service returns differents ResultCode here related to the nifm ResultCode.
|
// NOTE: Service returns different ResultCode here related to the nifm ResultCode.
|
||||||
resultCode = ResultCode.DeviceDisabled;
|
resultCode = ResultCode.DeviceDisabled;
|
||||||
_nifmResultCode = resultCode;
|
_nifmResultCode = resultCode;
|
||||||
}
|
}
|
||||||
|
@ -1084,14 +1091,13 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (NetworkClient != null)
|
_station?.Dispose();
|
||||||
{
|
_station = null;
|
||||||
_station?.Dispose();
|
|
||||||
_accessPoint?.Dispose();
|
|
||||||
|
|
||||||
NetworkClient.DisconnectAndStop();
|
_accessPoint?.Dispose();
|
||||||
}
|
_accessPoint = null;
|
||||||
|
|
||||||
|
NetworkClient?.Dispose();
|
||||||
NetworkClient = null;
|
NetworkClient = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue