From 3317dd7bffc9f4c50606420313ccb9675d89f423 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Sun, 4 Mar 2012 18:49:01 +0100 Subject: [PATCH] Make sure we don't try to use Channel.setReadable(true) if it was not set by the threadpool itself. See #215 --- .../execution/MemoryAwareThreadPoolExecutor.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/handler/src/main/java/io/netty/handler/execution/MemoryAwareThreadPoolExecutor.java b/handler/src/main/java/io/netty/handler/execution/MemoryAwareThreadPoolExecutor.java index 7d6589b10d..e78200ff99 100644 --- a/handler/src/main/java/io/netty/handler/execution/MemoryAwareThreadPoolExecutor.java +++ b/handler/src/main/java/io/netty/handler/execution/MemoryAwareThreadPoolExecutor.java @@ -419,10 +419,18 @@ public class MemoryAwareThreadPoolExecutor extends ThreadPoolExecutor { //System.out.println("READABLE"); ChannelHandlerContext ctx = eventTask.getContext(); if (ctx.getHandler() instanceof ExecutionHandler) { - // readSuspended = false; - ctx.setAttachment(null); + // check if the attachment was set as this means that we suspend the channel from reads. This only works when + // this pool is used with ExecutionHandler but I guess thats good enough for us. + // + // See #215 + if (ctx.getAttachment() != null) { + // readSuspended = false; + ctx.setAttachment(null); + channel.setReadable(true); + } + } else { + channel.setReadable(true); } - channel.setReadable(true); } } }