A workaround for 100% CPU consumption issue in NIO selectors, suggested by David M. Lloyd
This commit is contained in:
parent
dabea9dfff
commit
52221931d5
@ -339,7 +339,7 @@ class NioDatagramWorker implements Runnable {
|
|||||||
i.remove();
|
i.remove();
|
||||||
try {
|
try {
|
||||||
int readyOps = k.readyOps();
|
int readyOps = k.readyOps();
|
||||||
if ((readyOps & SelectionKey.OP_READ) != 0) {
|
if ((readyOps & SelectionKey.OP_READ) != 0 || readyOps == 0) {
|
||||||
if (!read(k)) {
|
if (!read(k)) {
|
||||||
// Connection already closed - no need to handle write.
|
// Connection already closed - no need to handle write.
|
||||||
continue;
|
continue;
|
||||||
|
@ -271,7 +271,7 @@ class NioWorker implements Runnable {
|
|||||||
i.remove();
|
i.remove();
|
||||||
try {
|
try {
|
||||||
int readyOps = k.readyOps();
|
int readyOps = k.readyOps();
|
||||||
if ((readyOps & SelectionKey.OP_READ) != 0) {
|
if ((readyOps & SelectionKey.OP_READ) != 0 || readyOps == 0) {
|
||||||
if (!read(k)) {
|
if (!read(k)) {
|
||||||
// Connection already closed - no need to handle write.
|
// Connection already closed - no need to handle write.
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user