Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont keep the endpoint reference to clean client resources #13755

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -460,13 +460,15 @@ public void connectionRemoved(Connection connection) {
}

String localMemberUuid = node.getThisUuid();
String ownerUuid = ownershipMappings.get(endpoint.getUuid());
final String clientUuid = endpoint.getUuid();
String ownerUuid = ownershipMappings.get(clientUuid);
if (localMemberUuid.equals(ownerUuid)) {
final long authenticationCorrelationId = endpoint.getAuthenticationCorrelationId();
try {
nodeEngine.getExecutionService().schedule(new Runnable() {
@Override
public void run() {
callDisconnectionOperation(endpoint);
callDisconnectionOperation(clientUuid, authenticationCorrelationId);
}
}, endpointRemoveDelaySeconds, TimeUnit.SECONDS);
} catch (RejectedExecutionException e) {
Expand All @@ -477,19 +479,18 @@ public void run() {
}
}

private void callDisconnectionOperation(ClientEndpointImpl endpoint) {
private void callDisconnectionOperation(String clientUuid, long authenticationCorrelationId) {
Collection<Member> memberList = nodeEngine.getClusterService().getMembers();
OperationService operationService = nodeEngine.getOperationService();
String memberUuid = getLocalMember().getUuid();
String clientUuid = endpoint.getUuid();

String ownerMember = ownershipMappings.get(clientUuid);
if (!memberUuid.equals(ownerMember)) {
// do nothing if the owner already changed (double checked locking)
return;
}

if (lastAuthenticationCorrelationIds.get(clientUuid).get() > endpoint.getAuthenticationCorrelationId()) {
if (lastAuthenticationCorrelationIds.get(clientUuid).get() > authenticationCorrelationId) {
//a new authentication already made for that client. This check is needed to detect
// "a disconnected client is reconnected back to same node"
return;
Expand Down