mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2025-02-09 13:14:46 +01:00
Fix some usages of SharedRef
This commit is contained in:
parent
a23d01e934
commit
1f14a1c360
@ -1,10 +1,11 @@
|
||||
using LibHac.Fs.Fsa;
|
||||
using System;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.Fs.Shim;
|
||||
using LibHac.FsSystem;
|
||||
|
||||
namespace LibHac.Fs
|
||||
{
|
||||
public class FileSystemClient
|
||||
public class FileSystemClient : IDisposable
|
||||
{
|
||||
internal FileSystemClientGlobals Globals;
|
||||
|
||||
@ -15,9 +16,14 @@ namespace LibHac.Fs
|
||||
{
|
||||
Globals.Initialize(this, horizonClient);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Globals.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
internal struct FileSystemClientGlobals
|
||||
internal struct FileSystemClientGlobals : IDisposable
|
||||
{
|
||||
public HorizonClient Hos;
|
||||
public object InitMutex;
|
||||
@ -37,6 +43,11 @@ namespace LibHac.Fs
|
||||
FsContextHandler.Initialize(fsClient);
|
||||
DirectorySaveDataFileSystem.Initialize(fsClient);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
FileSystemProxyServiceObject.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
// Functions in the nn::fs::detail namespace use this struct.
|
||||
|
@ -229,10 +229,7 @@ namespace LibHac.Fs.Fsa
|
||||
public Result OpenFile(ref UniqueRef<IFile> file, in Path path, OpenMode mode)
|
||||
{
|
||||
if ((mode & OpenMode.ReadWrite) == 0 || (mode & ~OpenMode.All) != 0)
|
||||
{
|
||||
UnsafeHelpers.SkipParamInit(out file);
|
||||
return ResultFs.InvalidOpenMode.Log();
|
||||
}
|
||||
|
||||
return DoOpenFile(ref file, in path, mode);
|
||||
}
|
||||
|
@ -573,7 +573,7 @@ namespace LibHac.Fs.Fsa
|
||||
rc = fileSystem.OpenDirectory(ref accessor.Ref(), subPath, mode);
|
||||
Tick end = fs.Hos.Os.GetSystemTick();
|
||||
|
||||
fs.Impl.OutputAccessLog(rc, start, end, accessor, new U8Span(logBuffer));
|
||||
fs.Impl.OutputAccessLog(rc, start, end, accessor.Get, new U8Span(logBuffer));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,9 +1,10 @@
|
||||
using LibHac.Common;
|
||||
using System;
|
||||
using LibHac.Common;
|
||||
using LibHac.FsSrv.Sf;
|
||||
|
||||
namespace LibHac.Fs.Shim
|
||||
{
|
||||
internal struct FileSystemProxyServiceObjectGlobals
|
||||
internal struct FileSystemProxyServiceObjectGlobals : IDisposable
|
||||
{
|
||||
public nint FileSystemProxyServiceObjectInitGuard;
|
||||
public SharedRef<IFileSystemProxy> FileSystemProxyServiceObject;
|
||||
@ -15,6 +16,20 @@ namespace LibHac.Fs.Shim
|
||||
public SharedRef<IProgramRegistry> ProgramRegistryServiceObject;
|
||||
|
||||
public SharedRef<IFileSystemProxy> DfcFileSystemProxyServiceObject;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
FileSystemProxyServiceObject.Destroy();
|
||||
FileSystemProxyServiceObjectInitGuard = default;
|
||||
|
||||
FileSystemProxyForLoaderServiceObject.Destroy();
|
||||
FileSystemProxyForLoaderServiceObjectInitGuard = default;
|
||||
|
||||
ProgramRegistryServiceObject.Destroy();
|
||||
ProgramRegistryServiceObjectInitGuard = default;
|
||||
|
||||
DfcFileSystemProxyServiceObject.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
public static class FileSystemProxyServiceObject
|
||||
|
@ -180,9 +180,13 @@ namespace LibHac.FsSrv
|
||||
{
|
||||
private Configuration _config;
|
||||
|
||||
// LibHac addition
|
||||
private SharedRef<IDeviceOperator> _deviceOperator;
|
||||
|
||||
public BaseStorageServiceImpl(in Configuration configuration)
|
||||
{
|
||||
_config = configuration;
|
||||
_deviceOperator = new SharedRef<IDeviceOperator>(configuration.DeviceOperator);
|
||||
}
|
||||
|
||||
public struct Configuration
|
||||
@ -193,7 +197,7 @@ namespace LibHac.FsSrv
|
||||
// LibHac additions
|
||||
public FileSystemServer FsServer;
|
||||
// Todo: The DeviceOperator in FS uses mostly global state. Decide how to handle this.
|
||||
public SharedRef<IDeviceOperator> DeviceOperator;
|
||||
public IDeviceOperator DeviceOperator;
|
||||
}
|
||||
|
||||
internal Result GetProgramInfo(out ProgramInfo programInfo, ulong processId)
|
||||
@ -232,7 +236,7 @@ namespace LibHac.FsSrv
|
||||
internal Result OpenDeviceOperator(ref SharedRef<IDeviceOperator> outDeviceOperator,
|
||||
AccessControl accessControl)
|
||||
{
|
||||
outDeviceOperator.SetByCopy(ref _config.DeviceOperator);
|
||||
outDeviceOperator.SetByCopy(ref _deviceOperator);
|
||||
return Result.Success;
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ namespace LibHac.FsSrv
|
||||
baseStorageConfig.BisStorageCreator = config.FsCreators.BuiltInStorageCreator;
|
||||
baseStorageConfig.GameCardStorageCreator = config.FsCreators.GameCardStorageCreator;
|
||||
baseStorageConfig.FsServer = server;
|
||||
baseStorageConfig.DeviceOperator = new SharedRef<IDeviceOperator>(config.DeviceOperator);
|
||||
baseStorageConfig.DeviceOperator = config.DeviceOperator;
|
||||
var baseStorageService = new BaseStorageServiceImpl(in baseStorageConfig);
|
||||
|
||||
var timeService = new TimeServiceImpl(server);
|
||||
|
@ -14,7 +14,7 @@ namespace LibHac.FsSrv.Impl
|
||||
protected DeepRetryFileSystem(ref SharedRef<IFileSystem> baseFileSystem,
|
||||
ref SharedRef<IRomFileSystemAccessFailureManager> accessFailureManager) : base(ref baseFileSystem)
|
||||
{
|
||||
_accessFailureManager = Shared.Move(ref accessFailureManager);
|
||||
_accessFailureManager = SharedRef<IRomFileSystemAccessFailureManager>.CreateMove(ref accessFailureManager);
|
||||
}
|
||||
|
||||
public static SharedRef<IFileSystem> CreateShared(ref SharedRef<IFileSystem> baseFileSystem,
|
||||
|
@ -60,7 +60,7 @@ namespace LibHac.FsSrv.Impl
|
||||
while (currentEntry is not null)
|
||||
{
|
||||
ref Cache entry = ref currentEntry.ValueRef;
|
||||
_accessorList.Remove(entry);
|
||||
_accessorList.Remove(currentEntry);
|
||||
entry.Dispose();
|
||||
|
||||
currentEntry = _accessorList.First;
|
||||
@ -69,15 +69,15 @@ namespace LibHac.FsSrv.Impl
|
||||
_accessorList.Clear();
|
||||
}
|
||||
|
||||
public Result Register(ref SharedRef<ISaveDataExtraDataAccessor> accessor,
|
||||
SaveDataSpaceId spaceId, ulong saveDataId)
|
||||
public Result Register(ref SharedRef<ISaveDataExtraDataAccessor> accessor, SaveDataSpaceId spaceId,
|
||||
ulong saveDataId)
|
||||
{
|
||||
var cache = new Cache(ref accessor, spaceId, saveDataId);
|
||||
var node = new LinkedListNode<Cache>(new Cache(ref accessor, spaceId, saveDataId));
|
||||
|
||||
using (ScopedLock.Lock(ref _mutex))
|
||||
{
|
||||
UnregisterImpl(spaceId, saveDataId);
|
||||
_accessorList.AddLast(cache);
|
||||
_accessorList.AddLast(node);
|
||||
}
|
||||
|
||||
return Result.Success;
|
||||
|
@ -155,7 +155,7 @@ namespace LibHac.FsSrv
|
||||
{
|
||||
if (type == FileSystemProxyType.Package)
|
||||
{
|
||||
outFileSystem = nspFileSystem;
|
||||
outFileSystem.SetByMove(ref nspFileSystem.Ref());
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
@ -649,7 +649,7 @@ namespace LibHac.FsSrv
|
||||
switch (fsType)
|
||||
{
|
||||
case FileSystemProxyType.Package:
|
||||
outFileSystem = baseFileSystem;
|
||||
outFileSystem.SetByMove(ref baseFileSystem);
|
||||
return Result.Success;
|
||||
|
||||
case FileSystemProxyType.Code:
|
||||
|
@ -386,8 +386,7 @@ namespace LibHac.FsSrv
|
||||
{
|
||||
Assert.SdkRequires(Globals.Mutex.IsLockedByCurrentThread());
|
||||
|
||||
var entry = new Entry(ref storage, spaceId, saveDataId);
|
||||
_entryList.AddLast(entry);
|
||||
_entryList.AddLast(new Entry(ref storage, spaceId, saveDataId));
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ using LibHac.Sm;
|
||||
|
||||
namespace LibHac
|
||||
{
|
||||
public class HorizonClient
|
||||
public class HorizonClient : IDisposable
|
||||
{
|
||||
// ReSharper disable once UnusedAutoPropertyAccessor.Local
|
||||
private Horizon Horizon { get; }
|
||||
@ -37,6 +37,12 @@ namespace LibHac
|
||||
ArpLazy = new Lazy<ArpClient>(InitArpClient, true);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Fs.Dispose();
|
||||
Lr.Dispose();
|
||||
}
|
||||
|
||||
private ArpClient InitArpClient()
|
||||
{
|
||||
return new ArpClient(this);
|
||||
|
@ -18,7 +18,7 @@ namespace LibHac.Lr
|
||||
}
|
||||
}
|
||||
|
||||
internal struct LrClientGlobals
|
||||
internal struct LrClientGlobals : IDisposable
|
||||
{
|
||||
public HorizonClient Hos;
|
||||
public LrServiceGlobals LrService;
|
||||
|
@ -1,11 +1,12 @@
|
||||
using LibHac.Common;
|
||||
using System;
|
||||
using LibHac.Common;
|
||||
using LibHac.Diag;
|
||||
using LibHac.Ncm;
|
||||
using LibHac.Os;
|
||||
|
||||
namespace LibHac.Lr
|
||||
{
|
||||
internal struct LrServiceGlobals
|
||||
internal struct LrServiceGlobals : IDisposable
|
||||
{
|
||||
public SharedRef<ILocationResolverManager> LocationResolver;
|
||||
public SdkMutexType InitializationMutex;
|
||||
|
Loading…
x
Reference in New Issue
Block a user