Skip to content

Commit

Permalink
Improve LiveLibraryInfo#connectionFinishesConnecting to handle async …
Browse files Browse the repository at this point in the history
…race where mid-connection disconnect can occur while a session is being handed over
  • Loading branch information
marc-adaptive committed Jan 24, 2025
1 parent 5e98841 commit 887d5e6
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1374,10 +1374,11 @@ public Action onInitiateConnection(
channelSupplier.open(address,
(channel, ex) ->
{
library.connectionFinishesConnecting(correlationId);

if (ex != null)
{
fixContexts.onDisconnect(sessionContext.sessionId());
library.connectionFinishesConnecting(correlationId);
saveError(UNABLE_TO_CONNECT, libraryId, correlationId, ex);
return;
}
Expand All @@ -1403,6 +1404,7 @@ public Action onInitiateConnection(
}
catch (final Exception ex)
{
library.connectionFinishesConnecting(correlationId);
fixContexts.onDisconnect(sessionContext.sessionId());
return saveError(UNABLE_TO_CONNECT, libraryId, correlationId, ex);
}
Expand Down Expand Up @@ -3709,7 +3711,6 @@ private boolean checkDisconnectDuringHandover()
{
// Need to notify the library because it doesn't know about the session yet and it will
// have a reply object corresponding to the initiate() method call.
library.connectionFinishesConnecting(correlationId);
saveError(UNABLE_TO_CONNECT, libraryId, correlationId,
"Disconnected before session active");
}
Expand Down Expand Up @@ -3765,7 +3766,6 @@ private long saveManageSessionInbound()
final long position = saveManageSession(inboundPublication);
if (position > 0)
{
library.connectionFinishesConnecting(correlationId);
gatewaySession.play();
}

Expand Down

0 comments on commit 887d5e6

Please sign in to comment.