Skip to content

Commit

Permalink
[Java] Use nextSmDeadlineNs instead of lastSmTimeNs as the code is si…
Browse files Browse the repository at this point in the history
…mpler and safer.
  • Loading branch information
mikeb01 committed Nov 8, 2024
1 parent 5315439 commit 6f7e6a1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions aeron-driver/src/main/java/io/aeron/driver/PublicationImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ enum State
private long lastSmChangeNumber;
private long lastSmPosition;
private long lastOverrunThreshold;
private long timeOfLastSmNs;
private long nextSmDeadlineNs;
private final long smTimeoutNs;
private final long maxReceiverWindowLength;

Expand Down Expand Up @@ -494,7 +494,7 @@ void deactivate()

if (isSendingEosSm)
{
timeOfLastSmNs = nowNs - smTimeoutNs - 1;
nextSmDeadlineNs = nowNs - 1;
}

state(State.DRAINING);
Expand Down Expand Up @@ -705,7 +705,7 @@ void checkEosForDrainTransition(final long nowNs)
timeOfLastStateChangeNs = nowNs;

isSendingEosSm = true;
timeOfLastSmNs = nowNs - smTimeoutNs - 1;
nextSmDeadlineNs = nowNs - 1;
state(State.DRAINING);
}
}
Expand All @@ -721,7 +721,7 @@ int sendPendingStatusMessage(final long nowNs)
{
int workCount = 0;
final long changeNumber = (long)END_SM_CHANGE_VH.getAcquire(this);
final boolean hasSmTimedOut = (nowNs - smTimeoutNs) > timeOfLastSmNs;
final boolean hasSmTimedOut = nowNs > nextSmDeadlineNs;

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

timeOfLastSmNs = nowNs;
nextSmDeadlineNs = nowNs + smTimeoutNs;
workCount++;
}

Expand Down Expand Up @@ -765,7 +765,7 @@ int sendPendingStatusMessage(final long nowNs)
lastSmPosition = smPosition;
lastOverrunThreshold = smPosition + (termLength >> 1);
lastSmChangeNumber = changeNumber;
timeOfLastSmNs = nowNs;
nextSmDeadlineNs = nowNs + smTimeoutNs;

updateActiveTransportCount();
}
Expand Down Expand Up @@ -943,7 +943,7 @@ void stopStatusMessagesIfNotActive()
{
if (State.ACTIVE != state)
{
timeOfLastSmNs = Long.MAX_VALUE;
nextSmDeadlineNs = Long.MAX_VALUE;
}
}

Expand Down

0 comments on commit 6f7e6a1

Please sign in to comment.