mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2025-05-23 19:34:05 +02:00
Fix missing disposal of instances in the Agent
This commit is contained in:
parent
07eed8b689
commit
4c66193b6e
Agent/Phantom.Agent.Services
@ -33,6 +33,8 @@ public sealed class AgentServices {
|
|||||||
Logger.Information("Stopping services...");
|
Logger.Information("Stopping services...");
|
||||||
|
|
||||||
await InstanceSessionManager.StopAll();
|
await InstanceSessionManager.StopAll();
|
||||||
|
InstanceSessionManager.Dispose();
|
||||||
|
|
||||||
await TaskManager.Stop();
|
await TaskManager.Stop();
|
||||||
|
|
||||||
Logger.Information("Services stopped.");
|
Logger.Information("Services stopped.");
|
||||||
|
@ -174,10 +174,10 @@ sealed class Instance : IDisposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
|
stateTransitioningActionSemaphore.Dispose();
|
||||||
|
|
||||||
if (currentState is IDisposable disposable) {
|
if (currentState is IDisposable disposable) {
|
||||||
disposable.Dispose();
|
disposable.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
stateTransitioningActionSemaphore.Dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,15 +138,24 @@ sealed class InstanceSessionManager : IDisposable {
|
|||||||
await semaphore.WaitAsync(CancellationToken.None);
|
await semaphore.WaitAsync(CancellationToken.None);
|
||||||
try {
|
try {
|
||||||
await Task.WhenAll(instances.Values.Select(static instance => instance.StopAndWait(TimeSpan.FromSeconds(30))));
|
await Task.WhenAll(instances.Values.Select(static instance => instance.StopAndWait(TimeSpan.FromSeconds(30))));
|
||||||
instances.Clear();
|
DisposeAllInstances();
|
||||||
} finally {
|
} finally {
|
||||||
semaphore.Release();
|
semaphore.Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
|
DisposeAllInstances();
|
||||||
minecraftServerExecutables.Dispose();
|
minecraftServerExecutables.Dispose();
|
||||||
shutdownCancellationTokenSource.Dispose();
|
shutdownCancellationTokenSource.Dispose();
|
||||||
semaphore.Dispose();
|
semaphore.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DisposeAllInstances() {
|
||||||
|
foreach (var (_, instance) in instances) {
|
||||||
|
instance.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
instances.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user