Potential fix for NETTY-52 (IllegalArgumentException when trying to change the current interestOps)

This commit is contained in:
Trustin Lee 2008-10-01 05:25:01 +00:00
parent 731ab2a0eb
commit cfa6794292
3 changed files with 12 additions and 6 deletions

View File

@ -628,7 +628,7 @@ public class Channels {
*/
public static ChannelFuture setInterestOps(Channel channel, int interestOps) {
validateInterestOps(interestOps);
validateDownstreamInterestOps(channel, interestOps);
interestOps = filterDownstreamInterestOps(interestOps);
ChannelFuture future = future(channel);
channel.getPipeline().sendDownstream(new DefaultChannelStateEvent(
@ -650,7 +650,7 @@ public class Channels {
ChannelHandlerContext ctx, Channel channel,
ChannelFuture future, int interestOps) {
validateInterestOps(interestOps);
validateDownstreamInterestOps(channel, interestOps);
interestOps = filterDownstreamInterestOps(interestOps);
ctx.sendDownstream(
new DefaultChannelStateEvent(
@ -733,10 +733,8 @@ public class Channels {
}
}
private static void validateDownstreamInterestOps(Channel channel, int interestOps) {
if (((channel.getInterestOps() ^ interestOps) & Channel.OP_WRITE) != 0) {
throw new IllegalArgumentException("OP_WRITE can't be modified by user.");
}
private static int filterDownstreamInterestOps(int interestOps) {
return interestOps & ~Channel.OP_WRITE;
}
private Channels() {

View File

@ -763,6 +763,10 @@ class NioWorker implements Runnable {
fireExceptionCaught(channel, cause);
}
// Override OP_WRITE flag - a user cannot change this flag.
interestOps &= ~Channel.OP_WRITE;
interestOps |= channel.getInterestOps() & Channel.OP_WRITE;
boolean changed = false;
try {
switch (CONSTRAINT_LEVEL) {

View File

@ -126,6 +126,10 @@ class OioWorker implements Runnable {
static void setInterestOps(
OioSocketChannel channel, ChannelFuture future, int interestOps) {
// Override OP_WRITE flag - a user cannot change this flag.
interestOps &= ~Channel.OP_WRITE;
interestOps |= channel.getInterestOps() & Channel.OP_WRITE;
boolean changed = false;
try {
if (channel.getInterestOps() != interestOps) {