mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-30 08:33:19 +01:00
Merge pull request #769 from tgstation/767-DoubleDispose
Prevent InstanceManager.Dispose from being called twice
This commit is contained in:
@@ -49,6 +49,11 @@ namespace Tgstation.Server.Host.Components
|
||||
/// </summary>
|
||||
readonly Dictionary<long, IInstance> instances;
|
||||
|
||||
/// <summary>
|
||||
/// If the <see cref="InstanceManager"/> has been <see cref="Dispose"/>d
|
||||
/// </summary>
|
||||
bool disposed;
|
||||
|
||||
/// <summary>
|
||||
/// Construct an <see cref="InstanceManager"/>
|
||||
/// </summary>
|
||||
@@ -73,6 +78,12 @@ namespace Tgstation.Server.Host.Components
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if (disposed)
|
||||
return;
|
||||
disposed = true;
|
||||
}
|
||||
foreach (var I in instances)
|
||||
I.Value.Dispose();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user