fix(twincat): retract the fresh ADS notification when unsubscribe raced the replay (05/STAB-17)
This commit is contained in:
@@ -878,6 +878,15 @@ public sealed class TwinCATDriver : IDriver, IReadable, IWritable, ITagDiscovery
|
||||
_options.NotificationMaxDelayMs, reg.OnChange, ct).ConfigureAwait(false);
|
||||
var old = reg.SwapHandle(newHandle);
|
||||
try { old?.Dispose(); } catch { /* dead handle from the disposed client */ }
|
||||
// 05/STAB-17: an UnsubscribeAsync (gate-free) can race this replay — if it removed the
|
||||
// registration between the intents snapshot and this swap, the fresh handle is
|
||||
// ownerless. Retract it immediately so the ADS notification isn't leaked live.
|
||||
if (!device.NativeRegistrations.ContainsKey(reg.Id))
|
||||
{
|
||||
var orphan = reg.MarkHandleDead();
|
||||
try { orphan?.Dispose(); } catch { /* best-effort */ }
|
||||
continue;
|
||||
}
|
||||
replayed++;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user