in csharp/NativeUtils/ResourceLoader.cs [1047:1117]
private void LoadAt(string deploymentPath)
{
if (null == _resources)
throw new Exception("No resources to deploy");
Opt options = _deploymentOptions;
if (!Path.IsPathRooted(deploymentPath))
throw new Exception($"Deployment path can't be relative: {deploymentPath}");
if (!Directory.Exists(deploymentPath))
Directory.CreateDirectory(deploymentPath);
if (_retryTimeoutMs < 0)
_retryTimeoutMs = (int)(_totalResourceLength / 4000 + 4000); // 4 MB/s + 4 sec
// Update period fixed to be frequent enough to not cause _any_ concurrent processes to timeout
// regardless of how big _their_ files are
// It is guaranteed to be <= _retryTimeoutMs / 2
_lockUpdatePeriodMs = 2000;
Dbg("dep.retryTimeoutMs", _retryTimeoutMs);
Dbg("dep.lockUpdatePeriodMs", _lockUpdatePeriodMs);
if (!OS.IsWindows)
options |= Opt.KeepDllsLocked;
Log($"RetryTimeout:{_retryTimeoutMs}, LockUpdatePeriod: {_lockUpdatePeriodMs}"
+ (options.HasFlag(Opt.KeepDllsLocked) ? ", KeepDllsLocked=1" : ""));
Dbg("dep.alwaysOverwrite", options.HasFlag(Opt.AlwaysOverwrite));
Dbg("dep.reusePartiallyDeployed", options.HasFlag(Opt.ReusePartiallyDeployed));
Dbg("dep.keepDllsLocked", options.HasFlag(Opt.KeepDllsLocked));
try
{
VerifyOrDeployResources(deploymentPath, options);
if (_shouldLoadDlls)
{
Log("loading libs..");
DbgLast("triedLoadingLibs", true);
LoadDynamicLibraries(deploymentPath);
if (options.HasFlag(Opt.KeepDllsLocked))
KeepDllFileHandles();
}
}
catch
{
if (_shouldLoadDlls)
{
// If some libs were already loaded before throwing, unload. All libs must be only loaded from a single deployment path.
Log("UNloading libs..");
UnloadDynamicLibraries();
// If failed to load libs, always drop file locks
DisposeResourceFiles();
}
LockFile = null;
throw;
}
finally
{
// Ensure all resource files are closed
Log("Dropping resource file locks..");
DisposeResourceFiles();
// If lock file existed, update the last time before deletion
if (null != _lockFile)
LockFileWatchdogUpdate(true);
LockFile = null;
}
}