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
a0f9afb1eb
commit
714ec984dd
@ -246,7 +246,7 @@ class NioClientSocketPipelineSink extends AbstractChannelSink {
|
|||||||
wakenUp.set(false);
|
wakenUp.set(false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int selectedKeyCount = selector.select(500);
|
int selectedKeyCount = selector.select(10);
|
||||||
|
|
||||||
// 'wakenUp.compareAndSet(false, true)' is always evaluated
|
// 'wakenUp.compareAndSet(false, true)' is always evaluated
|
||||||
// before calling 'selector.wakeup()' to reduce the wake-up
|
// before calling 'selector.wakeup()' to reduce the wake-up
|
||||||
@ -286,9 +286,9 @@ class NioClientSocketPipelineSink extends AbstractChannelSink {
|
|||||||
processSelectedKeys(selector.selectedKeys());
|
processSelectedKeys(selector.selectedKeys());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle connection timeout every 0.5 seconds approximately.
|
// Handle connection timeout every 10 milliseconds approximately.
|
||||||
long currentTimeNanos = System.nanoTime();
|
long currentTimeNanos = System.nanoTime();
|
||||||
if (currentTimeNanos - lastConnectTimeoutCheckTimeNanos >= 500 * 1000000L) {
|
if (currentTimeNanos - lastConnectTimeoutCheckTimeNanos >= 10 * 1000000L) {
|
||||||
lastConnectTimeoutCheckTimeNanos = currentTimeNanos;
|
lastConnectTimeoutCheckTimeNanos = currentTimeNanos;
|
||||||
processConnectTimeout(selector.keys(), currentTimeNanos);
|
processConnectTimeout(selector.keys(), currentTimeNanos);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user