mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-07-02 10:38:16 +00:00
Fix thread-safety issue in GetRouteToSource - snapshot TieLineCollection before enumeration
Co-authored-by: ngenovese11 <23391587+ngenovese11@users.noreply.github.com>
This commit is contained in:
parent
de70740e3b
commit
6b58dbd7d6
1 changed files with 6 additions and 2 deletions
|
|
@ -339,17 +339,21 @@ namespace PepperDash.Essentials.Core
|
||||||
|
|
||||||
RoutingInputPort goodInputPort = null;
|
RoutingInputPort goodInputPort = null;
|
||||||
|
|
||||||
|
// Take a snapshot to avoid InvalidOperationException if TieLineCollection.Default is
|
||||||
|
// modified concurrently (e.g. NVX tie line registration during route requests).
|
||||||
|
var tieLines = TieLineCollection.Default.ToList();
|
||||||
|
|
||||||
IEnumerable<TieLine> destinationTieLines;
|
IEnumerable<TieLine> destinationTieLines;
|
||||||
TieLine directTie = null;
|
TieLine directTie = null;
|
||||||
|
|
||||||
if (destinationPort == null)
|
if (destinationPort == null)
|
||||||
{
|
{
|
||||||
destinationTieLines = TieLineCollection.Default.Where(t =>
|
destinationTieLines = tieLines.Where(t =>
|
||||||
t.DestinationPort.ParentDevice.Key == destination.Key && (t.Type.HasFlag(signalType) || signalType == eRoutingSignalType.AudioVideo));
|
t.DestinationPort.ParentDevice.Key == destination.Key && (t.Type.HasFlag(signalType) || signalType == eRoutingSignalType.AudioVideo));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
destinationTieLines = TieLineCollection.Default.Where(t => t.DestinationPort.ParentDevice.Key == destination.Key && t.DestinationPort.Key == destinationPort.Key && (t.Type.HasFlag(signalType)));
|
destinationTieLines = tieLines.Where(t => t.DestinationPort.ParentDevice.Key == destination.Key && t.DestinationPort.Key == destinationPort.Key && (t.Type.HasFlag(signalType)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// find the TieLine without a port
|
// find the TieLine without a port
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue