Skip to content

Commit

Permalink
ensure that the library id of initiated connections is correctly trac…
Browse files Browse the repository at this point in the history
…ked along with their disconnects
  • Loading branch information
RichardWarburton committed Jan 10, 2022
1 parent 6eea544 commit 0869fb4
Showing 1 changed file with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,7 @@ private void onFixConnectionOpen(
sendRedundantResendRequests,
enableLastMsgSeqNumProcessed,
fixDictionary);
gatewaySession.libraryId(libraryId);
gatewaySession.lastSequenceResetTime(sessionContext.lastSequenceResetTime());
gatewaySession.lastLogonTime(sessionContext.lastLogonTimeInNs());
library.addSession(gatewaySession);
Expand Down Expand Up @@ -1833,8 +1834,7 @@ public Action onLibraryConnect(
{
existingLibrary.onHeartbeat(epochClock.time());

return Pressure.apply(inboundPublication.saveControlNotification(
libraryId, initialAcceptedSessionOwner, existingLibrary.sessions(), NO_DISCONNECTED_SESSIONS));
return saveControlNotification(libraryId, existingLibrary.sessions()) ? CONTINUE : ABORT;
}

if (soleLibraryMode)
Expand All @@ -1851,17 +1851,10 @@ public Action onLibraryConnect(
}

// Send an empty control notification if you've never seen this library before
final LongHashSet disconnectedSessions = gatewaySessions.findDisconnectedSessions(libraryId);
if (Pressure.isBackPressured(
inboundPublication.saveControlNotification(
libraryId, initialAcceptedSessionOwner, Collections.emptyList(), disconnectedSessions)))
if (!saveControlNotification(libraryId, Collections.emptyList()))
{
return ABORT;
}
else
{
gatewaySessions.removeDisconnectedSessions(disconnectedSessions);
}

final List<Continuation> unitsOfWork = new ArrayList<>();
unitsOfWork.add(() ->
Expand Down Expand Up @@ -1908,6 +1901,22 @@ public Action onLibraryConnect(
return retryManager.firstAttempt(correlationId, new UnitOfWork(unitsOfWork));
}

private boolean saveControlNotification(final int libraryId, final List<?> sessions)
{
final LongHashSet disconnectedSessions = gatewaySessions.findDisconnectedSessions(libraryId);
if (Pressure.isBackPressured(
inboundPublication.saveControlNotification(
libraryId, initialAcceptedSessionOwner, sessions, disconnectedSessions)))
{
return false;
}
else
{
gatewaySessions.removeDisconnectedSessions(disconnectedSessions);
return true;
}
}

private void soleLibraryModeBind()
{
if (shouldBind)
Expand Down

0 comments on commit 0869fb4

Please sign in to comment.