A workaround for 100% CPU consumption issue in NIO selectors, suggested by David M. Lloyd

This commit is contained in:
Trustin Lee 2009-10-26 16:41:56 +00:00
parent dabea9dfff
commit 52221931d5
2 changed files with 2 additions and 2 deletions

View File

@ -339,7 +339,7 @@ class NioDatagramWorker implements Runnable {
i.remove();
try {
int readyOps = k.readyOps();
if ((readyOps & SelectionKey.OP_READ) != 0) {
if ((readyOps & SelectionKey.OP_READ) != 0 || readyOps == 0) {
if (!read(k)) {
// Connection already closed - no need to handle write.
continue;

View File

@ -271,7 +271,7 @@ class NioWorker implements Runnable {
i.remove();
try {
int readyOps = k.readyOps();
if ((readyOps & SelectionKey.OP_READ) != 0) {
if ((readyOps & SelectionKey.OP_READ) != 0 || readyOps == 0) {
if (!read(k)) {
// Connection already closed - no need to handle write.
continue;