Allow to adjust timeout of Selector.select(timeout) via org.jboss.netty.selectTimeout property. See #568
This commit is contained in:
parent
5d07dea3b7
commit
8b4f593397
@ -21,12 +21,15 @@ import java.nio.channels.Selector;
|
||||
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
import org.jboss.netty.util.internal.SystemPropertyUtil;
|
||||
|
||||
final class SelectorUtil {
|
||||
private static final InternalLogger logger =
|
||||
InternalLoggerFactory.getInstance(SelectorUtil.class);
|
||||
|
||||
static final int DEFAULT_IO_THREADS = Runtime.getRuntime().availableProcessors() * 2;
|
||||
static final long DEFAULT_SELECT_TIMEOUT = 10;
|
||||
static final long SELECT_TIMEOUT;
|
||||
|
||||
// Workaround for JDK NIO bug.
|
||||
//
|
||||
@ -45,11 +48,20 @@ final class SelectorUtil {
|
||||
logger.debug("Unable to get/set System Property '" + key + "'", e);
|
||||
}
|
||||
}
|
||||
long selectTimeout;
|
||||
try {
|
||||
selectTimeout = Long.parseLong(SystemPropertyUtil.get("org.jboss.netty.selectTimeout",
|
||||
String.valueOf(DEFAULT_SELECT_TIMEOUT)));
|
||||
} catch (NumberFormatException e) {
|
||||
selectTimeout = DEFAULT_SELECT_TIMEOUT;
|
||||
}
|
||||
SELECT_TIMEOUT = selectTimeout;
|
||||
logger.debug("Using select timeout of " + SELECT_TIMEOUT);
|
||||
}
|
||||
|
||||
static void select(Selector selector) throws IOException {
|
||||
try {
|
||||
selector.select(10);
|
||||
selector.select(SELECT_TIMEOUT);
|
||||
} catch (CancelledKeyException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(
|
||||
|
Loading…
Reference in New Issue
Block a user