Skip to content

Commit

Permalink
If the connection is destroyed and removed from active connections, i…
Browse files Browse the repository at this point in the history
…t should be removed from iobalancer regardless of connection endpoint. Fixes hazelcast#6199
  • Loading branch information
eminn committed Sep 14, 2015
1 parent 0454e62 commit 6a15980
Showing 1 changed file with 22 additions and 17 deletions.
Expand Up @@ -403,33 +403,38 @@ public void destroyConnection(final Connection connection) {
if (logger.isFinestEnabled()) {
log(Level.FINEST, "Destroying " + connection);
}
activeConnections.remove(connection);
if (activeConnections.remove(connection)) {
ioBalancer.connectionRemoved(connection);
}
final Address endPoint = connection.getEndPoint();
if (endPoint != null) {
connectionsInProgress.remove(endPoint);
connectionsMap.remove(endPoint, connection);
ioBalancer.connectionRemoved(connection);
if (live) {
ioService.getEventService().executeEventCallback(new StripedRunnable() {
@Override
public void run() {
for (ConnectionListener listener : connectionListeners) {
listener.connectionRemoved(connection);
}
}

@Override
public int getKey() {
return endPoint.hashCode();
}
});
}
fireConnectionRemovedEvent(connection, endPoint);
}
if (connection.isAlive()) {
connection.close();
}
}

private void fireConnectionRemovedEvent(final Connection connection, final Address endPoint) {
if (live) {
ioService.getEventService().executeEventCallback(new StripedRunnable() {
@Override
public void run() {
for (ConnectionListener listener : connectionListeners) {
listener.connectionRemoved(connection);
}
}

@Override
public int getKey() {
return endPoint.hashCode();
}
});
}
}

protected void initSocket(Socket socket) throws Exception {
if (socketLingerSeconds > 0) {
socket.setSoLinger(true, socketLingerSeconds);
Expand Down

0 comments on commit 6a15980

Please sign in to comment.