Skip to content

Commit

Permalink
[Java] Linger resources on close to mitigate against unmapping. Issue #…
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpt777 committed Jul 3, 2017
1 parent 0ce9b6a commit 578f5dd
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions aeron-client/src/main/java/io/aeron/ClientConductor.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,12 @@ public void onClose()
{
isClosed = true;

for (final ExclusivePublication publication : activeExclusivePublications.values())
forceClosePublicationsAndSubscriptions();

if (lingeringResources.size() > 0)
{
publication.forceClose();
sleep(1);
}
activeExclusivePublications.clear();

activePublications.close();
activeSubscriptions.close();

Thread.yield();

for (int i = 0, size = lingeringResources.size(); i < size; i++)
{
Expand Down Expand Up @@ -502,6 +498,12 @@ private int onCheckTimeouts()

if (nowNs > (timeOfLastWorkNs + interServiceTimeoutNs))
{
forceClosePublicationsAndSubscriptions();
if (lingeringResources.size() > 0)
{
sleep(1000);
}

onClose();

throw new ConductorServiceTimeoutException(
Expand Down Expand Up @@ -558,4 +560,16 @@ private void checkDriverHeartbeat()
}
}
}

private void forceClosePublicationsAndSubscriptions()
{
for (final ExclusivePublication publication : activeExclusivePublications.values())
{
publication.forceClose();
}
activeExclusivePublications.clear();

activePublications.close();
activeSubscriptions.close();
}
}

0 comments on commit 578f5dd

Please sign in to comment.