Permalink
Browse files

Revert " Make sure calling ExecutionHandler.releaseExternalResource()…

… does not lead to a dead-lock when calling from a ChannelEventRunnable. See #200"

This reverts commit 7800187.
  • Loading branch information...
1 parent 9d9f96b commit a77e4b041e342deb2b455268b21508688724374a @normanmaurer normanmaurer committed Jun 1, 2012
View
9 src/main/java/org/jboss/netty/handler/execution/ChannelDownstreamEventRunnable.java
@@ -16,8 +16,6 @@
package org.jboss.netty.handler.execution;
-import java.util.concurrent.Executor;
-
import org.jboss.netty.channel.ChannelEvent;
import org.jboss.netty.channel.ChannelHandlerContext;
@@ -26,15 +24,14 @@
*/
public class ChannelDownstreamEventRunnable extends ChannelEventRunnable {
- public ChannelDownstreamEventRunnable(ChannelHandlerContext ctx, ChannelEvent e, Executor executor) {
- super(ctx, e, executor);
+ public ChannelDownstreamEventRunnable(ChannelHandlerContext ctx, ChannelEvent e) {
+ super(ctx, e);
}
/**
* Send the {@link ChannelEvent} downstream
*/
- @Override
- public void runTask() {
+ public void run() {
ctx.sendDownstream(e);
}
}
View
22 src/main/java/org/jboss/netty/handler/execution/ChannelEventRunnable.java
@@ -15,28 +15,23 @@
*/
package org.jboss.netty.handler.execution;
-import java.util.concurrent.Executor;
-
import org.jboss.netty.channel.ChannelEvent;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.util.EstimatableObjectWrapper;
-import org.jboss.netty.util.internal.DeadLockProofWorker;
public abstract class ChannelEventRunnable implements Runnable, EstimatableObjectWrapper {
protected final ChannelHandlerContext ctx;
protected final ChannelEvent e;
int estimatedSize;
- private final Executor executor;
/**
* Creates a {@link Runnable} which sends the specified {@link ChannelEvent}
* upstream via the specified {@link ChannelHandlerContext}.
*/
- public ChannelEventRunnable(ChannelHandlerContext ctx, ChannelEvent e, Executor executor) {
+ public ChannelEventRunnable(ChannelHandlerContext ctx, ChannelEvent e) {
this.ctx = ctx;
this.e = e;
- this.executor = executor;
}
/**
@@ -57,19 +52,4 @@ public ChannelEvent getEvent() {
public Object unwrap() {
return e;
}
-
- public final void run() {
- try {
- DeadLockProofWorker.PARENT.set(executor);
- runTask();
- } finally {
- DeadLockProofWorker.PARENT.remove();
- }
-
- }
-
- /**
- * Run the task
- */
- protected abstract void runTask();
}
View
7 src/main/java/org/jboss/netty/handler/execution/ChannelUpstreamEventRunnable.java
@@ -32,16 +32,15 @@
* Creates a {@link Runnable} which sends the specified {@link ChannelEvent}
* upstream via the specified {@link ChannelHandlerContext}.
*/
- public ChannelUpstreamEventRunnable(ChannelHandlerContext ctx, ChannelEvent e, Executor executor) {
- super(ctx, e, executor);
+ public ChannelUpstreamEventRunnable(ChannelHandlerContext ctx, ChannelEvent e) {
+ super(ctx, e);
}
/**
* Sends the event upstream.
*/
- @Override
- protected void runTask() {
+ public void run() {
ctx.sendUpstream(e);
}
}
View
9 src/main/java/org/jboss/netty/handler/execution/ExecutionHandler.java
@@ -169,12 +169,7 @@ public void releaseExternalResources() {
public void handleUpstream(
ChannelHandlerContext context, ChannelEvent e) throws Exception {
if (handleUpstream) {
- try {
- executor.execute(new ChannelUpstreamEventRunnable(context, e, executor));
-
- } finally {
-
- }
+ executor.execute(new ChannelUpstreamEventRunnable(context, e));
} else {
context.sendUpstream(e);
}
@@ -185,7 +180,7 @@ public void handleDownstream(
// check if the read was suspend
if (!handleReadSuspend(ctx, e)) {
if (handleDownstream) {
- executor.execute(new ChannelDownstreamEventRunnable(ctx, e, executor));
+ executor.execute(new ChannelDownstreamEventRunnable(ctx, e));
} else {
ctx.sendDownstream(e);
}
View
8 src/main/java/org/jboss/netty/handler/execution/MemoryAwareThreadPoolExecutor.java
@@ -45,7 +45,6 @@
import org.jboss.netty.util.DefaultObjectSizeEstimator;
import org.jboss.netty.util.ObjectSizeEstimator;
import org.jboss.netty.util.internal.ConcurrentIdentityHashMap;
-import org.jboss.netty.util.internal.DeadLockProofWorker;
import org.jboss.netty.util.internal.QueueFactory;
import org.jboss.netty.util.internal.SharedResourceMisuseDetector;
@@ -442,12 +441,7 @@ protected void doExecute(Runnable task) {
* Executes the specified task without maintaining the event order.
*/
protected final void doUnorderedExecute(Runnable task) {
- try {
- DeadLockProofWorker.PARENT.set(this);
- super.execute(task);
- } finally {
- DeadLockProofWorker.PARENT.remove();
- }
+ super.execute(task);
}
@Override
View
4 src/main/java/org/jboss/netty/handler/execution/OrderedMemoryAwareThreadPoolExecutor.java
@@ -31,7 +31,6 @@
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.util.ObjectSizeEstimator;
import org.jboss.netty.util.internal.ConcurrentIdentityWeakKeyHashMap;
-import org.jboss.netty.util.internal.DeadLockProofWorker;
import org.jboss.netty.util.internal.QueueFactory;
/**
@@ -303,7 +302,6 @@ public void run() {
acquired = true;
try {
Thread thread = Thread.currentThread();
- DeadLockProofWorker.PARENT.set(OrderedMemoryAwareThreadPoolExecutor.this);
for (;;) {
final Runnable task = tasks.poll();
// if the task is null we should exit the loop
@@ -325,8 +323,6 @@ public void run() {
}
}
} finally {
- DeadLockProofWorker.PARENT.remove();
-
// set it back to not running
isRunning.set(false);
}

0 comments on commit a77e4b0

Please sign in to comment.