Skip to content

Commit 6f7e6a1

Browse files
committed
[Java] Use nextSmDeadlineNs instead of lastSmTimeNs as the code is simpler and safer.
1 parent 5315439 commit 6f7e6a1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

aeron-driver/src/main/java/io/aeron/driver/PublicationImage.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ enum State
145145
private long lastSmChangeNumber;
146146
private long lastSmPosition;
147147
private long lastOverrunThreshold;
148-
private long timeOfLastSmNs;
148+
private long nextSmDeadlineNs;
149149
private final long smTimeoutNs;
150150
private final long maxReceiverWindowLength;
151151

@@ -494,7 +494,7 @@ void deactivate()
494494

495495
if (isSendingEosSm)
496496
{
497-
timeOfLastSmNs = nowNs - smTimeoutNs - 1;
497+
nextSmDeadlineNs = nowNs - 1;
498498
}
499499

500500
state(State.DRAINING);
@@ -705,7 +705,7 @@ void checkEosForDrainTransition(final long nowNs)
705705
timeOfLastStateChangeNs = nowNs;
706706

707707
isSendingEosSm = true;
708-
timeOfLastSmNs = nowNs - smTimeoutNs - 1;
708+
nextSmDeadlineNs = nowNs - 1;
709709
state(State.DRAINING);
710710
}
711711
}
@@ -721,7 +721,7 @@ int sendPendingStatusMessage(final long nowNs)
721721
{
722722
int workCount = 0;
723723
final long changeNumber = (long)END_SM_CHANGE_VH.getAcquire(this);
724-
final boolean hasSmTimedOut = (nowNs - smTimeoutNs) > timeOfLastSmNs;
724+
final boolean hasSmTimedOut = nowNs > nextSmDeadlineNs;
725725

726726
if (null != rejectionReason)
727727
{
@@ -730,7 +730,7 @@ int sendPendingStatusMessage(final long nowNs)
730730
channelEndpoint.sendErrorFrame(
731731
imageConnections, sessionId, streamId, GENERIC_ERROR.value(), rejectionReason);
732732

733-
timeOfLastSmNs = nowNs;
733+
nextSmDeadlineNs = nowNs + smTimeoutNs;
734734
workCount++;
735735
}
736736

@@ -765,7 +765,7 @@ int sendPendingStatusMessage(final long nowNs)
765765
lastSmPosition = smPosition;
766766
lastOverrunThreshold = smPosition + (termLength >> 1);
767767
lastSmChangeNumber = changeNumber;
768-
timeOfLastSmNs = nowNs;
768+
nextSmDeadlineNs = nowNs + smTimeoutNs;
769769

770770
updateActiveTransportCount();
771771
}
@@ -943,7 +943,7 @@ void stopStatusMessagesIfNotActive()
943943
{
944944
if (State.ACTIVE != state)
945945
{
946-
timeOfLastSmNs = Long.MAX_VALUE;
946+
nextSmDeadlineNs = Long.MAX_VALUE;
947947
}
948948
}
949949

0 commit comments

Comments
 (0)