From d68b104969470dfd5f95594be4f83bab126246d8 Mon Sep 17 00:00:00 2001 From: norman Date: Tue, 20 Mar 2012 15:18:33 +0100 Subject: [PATCH] Make sure AbstractNioWorker.setInterestOps(..) will notify the future and the handlers in all cases. See #238 --- .../channel/socket/nio/AbstractNioWorker.java | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/transport/src/main/java/io/netty/channel/socket/nio/AbstractNioWorker.java b/transport/src/main/java/io/netty/channel/socket/nio/AbstractNioWorker.java index af779c8b20..79ee9ed6bb 100644 --- a/transport/src/main/java/io/netty/channel/socket/nio/AbstractNioWorker.java +++ b/transport/src/main/java/io/netty/channel/socket/nio/AbstractNioWorker.java @@ -702,17 +702,31 @@ abstract class AbstractNioWorker implements Worker { Selector selector = this.selector; SelectionKey key = channel.channel.keyFor(selector); - if (key == null || selector == null) { - // Not registered to the worker yet. - // Set the rawInterestOps immediately; RegisterTask will pick it up. - channel.setRawInterestOpsNow(interestOps); - return; - } - // Override OP_WRITE flag - a user cannot change this flag. interestOps &= ~Channel.OP_WRITE; interestOps |= channel.getRawInterestOps() & Channel.OP_WRITE; - + + if (key == null || selector == null) { + if (channel.getRawInterestOps() != interestOps) { + changed = true; + } + + // Not registered to the worker yet. + // Set the rawInterestOps immediately; RegisterTask will pick it up. + channel.setRawInterestOpsNow(interestOps); + + future.setSuccess(); + if (changed) { + if (iothread) { + fireChannelInterestChanged(channel); + } else { + fireChannelInterestChangedLater(channel); + } + } + + return; + } + switch (CONSTRAINT_LEVEL) { case 0: if (channel.getRawInterestOps() != interestOps) {