diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/DataSubscriptionSession.Conditions.cs b/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/DataSubscriptionSession.Conditions.cs index 7911ec200..c09756647 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/DataSubscriptionSession.Conditions.cs +++ b/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/DataSubscriptionSession.Conditions.cs @@ -237,13 +237,13 @@ internal sealed partial class DataSubscriptionSession private Task StartWait(ChannelReader reader, CancellationToken token) { - Interlocked.Increment(ref _conditionWaitsStarted); + if (!ReferenceEquals(reader, _outbound.Reader)) Interlocked.Increment(ref _conditionWaitsStarted); return reader.WaitToReadAsync(token).AsTask(); } private int _conditionWaitsStarted; - /// Test seam (N5): how many channel waits the delivery loop has registered. + /// Test seam (N5): how many waits on the CONDITION queue the delivery loop has registered. internal int ConditionWaitsStartedForTests => Volatile.Read(ref _conditionWaitsStarted); /// Test seam: the stream has processed its Open. diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/DataConnections/GrpcDataConditionStreamTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/DataConnections/GrpcDataConditionStreamTests.cs index f9e89f9f6..b78739672 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/DataConnections/GrpcDataConditionStreamTests.cs +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/DataConnections/GrpcDataConditionStreamTests.cs @@ -274,8 +274,8 @@ public sealed class GrpcDataConditionStreamTests await stream.Session.EnqueueValueProbeForTests(); (await next).ShouldNotBeNull(); } - // Each value wakes the loop once; the idle condition wait must be reused, not re-registered every pass. - (stream.Session.ConditionWaitsStartedForTests - before).ShouldBeLessThan(50); + // Values wake the loop; the idle condition queue's wait must be reused, not re-registered on every pass. + (stream.Session.ConditionWaitsStartedForTests - before).ShouldBeLessThanOrEqualTo(1); } [Fact]