Fix #204 - Increate the granularity of connect timeout in NIO
* Changed the Selector timeout from 500 to 10 so that the timeout is checked every 10 milliseconds
This commit is contained in:
parent
2b9df060dd
commit
4612568687
@ -262,7 +262,7 @@ class SctpClientPipelineSink extends AbstractChannelSink {
|
||||
wakenUp.set(false);
|
||||
|
||||
try {
|
||||
int selectedKeyCount = selector.select(500);
|
||||
int selectedKeyCount = selector.select(10);
|
||||
|
||||
// 'wakenUp.compareAndSet(false, true)' is always evaluated
|
||||
// before calling 'selector.wakeup()' to reduce the wake-up
|
||||
@ -302,9 +302,9 @@ class SctpClientPipelineSink extends AbstractChannelSink {
|
||||
processSelectedKeys(selector.selectedKeys());
|
||||
}
|
||||
|
||||
// Handle connection timeout every 0.5 seconds approximately.
|
||||
// Handle connection timeout every 10 milliseconds approximately.
|
||||
long currentTimeNanos = System.nanoTime();
|
||||
if (currentTimeNanos - lastConnectTimeoutCheckTimeNanos >= 500 * 1000000L) {
|
||||
if (currentTimeNanos - lastConnectTimeoutCheckTimeNanos >= 10 * 1000000L) {
|
||||
lastConnectTimeoutCheckTimeNanos = currentTimeNanos;
|
||||
processConnectTimeout(selector.keys(), currentTimeNanos);
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ class NioClientSocketPipelineSink extends AbstractChannelSink {
|
||||
wakenUp.set(false);
|
||||
|
||||
try {
|
||||
int selectedKeyCount = selector.select(500);
|
||||
int selectedKeyCount = selector.select(10);
|
||||
|
||||
// 'wakenUp.compareAndSet(false, true)' is always evaluated
|
||||
// before calling 'selector.wakeup()' to reduce the wake-up
|
||||
@ -282,9 +282,9 @@ class NioClientSocketPipelineSink extends AbstractChannelSink {
|
||||
processSelectedKeys(selector.selectedKeys());
|
||||
}
|
||||
|
||||
// Handle connection timeout every 0.5 seconds approximately.
|
||||
// Handle connection timeout every 10 milliseconds approximately.
|
||||
long currentTimeNanos = System.nanoTime();
|
||||
if (currentTimeNanos - lastConnectTimeoutCheckTimeNanos >= 500 * 1000000L) {
|
||||
if (currentTimeNanos - lastConnectTimeoutCheckTimeNanos >= 10 * 1000000L) {
|
||||
lastConnectTimeoutCheckTimeNanos = currentTimeNanos;
|
||||
processConnectTimeout(selector.keys(), currentTimeNanos);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user