mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Fix a bug in TcpReplicator -- didn't schedule to connect to an endpoint later, when channel.socket().setTcpNoDelay(true) throws an exception
This commit is contained in:
@@ -451,7 +451,12 @@ final class TcpReplicator<K, V> extends AbstractChannelReplicator implements Clo
|
||||
if (!channel.finishConnect()) {
|
||||
return;
|
||||
}
|
||||
} catch (SocketException e) {
|
||||
|
||||
channel.configureBlocking(false);
|
||||
channel.socket().setTcpNoDelay(true);
|
||||
channel.socket().setSoTimeout(0);
|
||||
channel.socket().setSoLinger(false, 0);
|
||||
} catch (IOException e) {
|
||||
quietClose(key, e);
|
||||
|
||||
// when node discovery is used ( by nodes broadcasting out their host:port over UDP ),
|
||||
@@ -473,11 +478,6 @@ final class TcpReplicator<K, V> extends AbstractChannelReplicator implements Clo
|
||||
LOG.debug("successfully connected to {}, local-id={}",
|
||||
channel.socket().getInetAddress(), localIdentifier);
|
||||
|
||||
channel.configureBlocking(false);
|
||||
channel.socket().setTcpNoDelay(true);
|
||||
channel.socket().setSoTimeout(0);
|
||||
channel.socket().setSoLinger(false, 0);
|
||||
|
||||
attached.entryReader = new TcpSocketChannelEntryReader();
|
||||
attached.entryWriter = new TcpSocketChannelEntryWriter();
|
||||
|
||||
@@ -1028,6 +1028,7 @@ final class TcpReplicator<K, V> extends AbstractChannelReplicator implements Clo
|
||||
} catch (ClosedChannelException e) {
|
||||
if (socketChannel.isOpen())
|
||||
LOG.error("", e);
|
||||
onFail(socketChannel);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1037,20 +1038,25 @@ final class TcpReplicator<K, V> extends AbstractChannelReplicator implements Clo
|
||||
return socketChannel;
|
||||
} finally {
|
||||
if (!success) {
|
||||
try {
|
||||
try {
|
||||
socketChannel.socket().close();
|
||||
} catch (Exception e) {
|
||||
LOG.error("", e);
|
||||
}
|
||||
socketChannel.close();
|
||||
} catch (IOException e) {
|
||||
LOG.error("", e);
|
||||
}
|
||||
this.connectLater();
|
||||
onFail(socketChannel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onFail(SocketChannel socketChannel) {
|
||||
try {
|
||||
try {
|
||||
socketChannel.socket().close();
|
||||
} catch (Exception e) {
|
||||
LOG.error("", e);
|
||||
}
|
||||
socketChannel.close();
|
||||
} catch (IOException e) {
|
||||
LOG.error("", e);
|
||||
} finally {
|
||||
this.connectLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user