Skip to content
This repository
Browse code

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...
commit a77e4b041e342deb2b455268b21508688724374a 1 parent 9d9f96b
Norman Maurer authored June 01, 2012
9  src/main/java/org/jboss/netty/handler/execution/ChannelDownstreamEventRunnable.java
@@ -16,8 +16,6 @@
16 16
 package org.jboss.netty.handler.execution;
17 17
 
18 18
 
19  
-import java.util.concurrent.Executor;
20  
-
21 19
 import org.jboss.netty.channel.ChannelEvent;
22 20
 import org.jboss.netty.channel.ChannelHandlerContext;
23 21
 
@@ -26,15 +24,14 @@
26 24
  */
27 25
 public class ChannelDownstreamEventRunnable extends ChannelEventRunnable {
28 26
 
29  
-    public ChannelDownstreamEventRunnable(ChannelHandlerContext ctx, ChannelEvent e, Executor executor) {
30  
-        super(ctx, e, executor);
  27
+    public ChannelDownstreamEventRunnable(ChannelHandlerContext ctx, ChannelEvent e) {
  28
+        super(ctx, e);
31 29
     }
32 30
 
33 31
     /**
34 32
      * Send the {@link ChannelEvent} downstream
35 33
      */
36  
-    @Override
37  
-    public void runTask() {
  34
+    public void run() {
38 35
         ctx.sendDownstream(e);
39 36
     }
40 37
 }
22  src/main/java/org/jboss/netty/handler/execution/ChannelEventRunnable.java
@@ -15,28 +15,23 @@
15 15
  */
16 16
 package org.jboss.netty.handler.execution;
17 17
 
18  
-import java.util.concurrent.Executor;
19  
-
20 18
 import org.jboss.netty.channel.ChannelEvent;
21 19
 import org.jboss.netty.channel.ChannelHandlerContext;
22 20
 import org.jboss.netty.util.EstimatableObjectWrapper;
23  
-import org.jboss.netty.util.internal.DeadLockProofWorker;
24 21
 
25 22
 public abstract class ChannelEventRunnable implements Runnable, EstimatableObjectWrapper {
26 23
 
27 24
     protected final ChannelHandlerContext ctx;
28 25
     protected final ChannelEvent e;
29 26
     int estimatedSize;
30  
-    private final Executor executor;
31 27
 
32 28
     /**
33 29
      * Creates a {@link Runnable} which sends the specified {@link ChannelEvent}
34 30
      * upstream via the specified {@link ChannelHandlerContext}.
35 31
      */
36  
-    public ChannelEventRunnable(ChannelHandlerContext ctx, ChannelEvent e, Executor executor) {
  32
+    public ChannelEventRunnable(ChannelHandlerContext ctx, ChannelEvent e) {
37 33
         this.ctx = ctx;
38 34
         this.e = e;
39  
-        this.executor = executor;
40 35
     }
41 36
 
42 37
     /**
@@ -57,19 +52,4 @@ public ChannelEvent getEvent() {
57 52
     public Object unwrap() {
58 53
         return e;
59 54
     }
60  
-
61  
-    public final void run() {
62  
-        try {
63  
-            DeadLockProofWorker.PARENT.set(executor);
64  
-            runTask();
65  
-        } finally {
66  
-            DeadLockProofWorker.PARENT.remove();
67  
-        }
68  
-
69  
-    }
70  
-    
71  
-    /**
72  
-     * Run the task
73  
-     */
74  
-    protected abstract void runTask();
75 55
 }
7  src/main/java/org/jboss/netty/handler/execution/ChannelUpstreamEventRunnable.java
@@ -32,16 +32,15 @@
32 32
      * Creates a {@link Runnable} which sends the specified {@link ChannelEvent}
33 33
      * upstream via the specified {@link ChannelHandlerContext}.
34 34
      */
35  
-    public ChannelUpstreamEventRunnable(ChannelHandlerContext ctx, ChannelEvent e, Executor executor) {
36  
-        super(ctx, e, executor);
  35
+    public ChannelUpstreamEventRunnable(ChannelHandlerContext ctx, ChannelEvent e) {
  36
+        super(ctx, e);
37 37
     }
38 38
 
39 39
 
40 40
     /**
41 41
      * Sends the event upstream.
42 42
      */
43  
-    @Override
44  
-    protected void runTask() {
  43
+    public void run() {
45 44
         ctx.sendUpstream(e);
46 45
     }
47 46
 }
9  src/main/java/org/jboss/netty/handler/execution/ExecutionHandler.java
@@ -169,12 +169,7 @@ public void releaseExternalResources() {
169 169
     public void handleUpstream(
170 170
             ChannelHandlerContext context, ChannelEvent e) throws Exception {
171 171
         if (handleUpstream) {
172  
-            try {
173  
-                executor.execute(new ChannelUpstreamEventRunnable(context, e, executor));
174  
-
175  
-            } finally {
176  
-                
177  
-            }
  172
+            executor.execute(new ChannelUpstreamEventRunnable(context, e));
178 173
         } else {
179 174
             context.sendUpstream(e);
180 175
         }
@@ -185,7 +180,7 @@ public void handleDownstream(
185 180
         // check if the read was suspend
186 181
         if (!handleReadSuspend(ctx, e)) {
187 182
             if (handleDownstream) {
188  
-                executor.execute(new ChannelDownstreamEventRunnable(ctx, e, executor));
  183
+                executor.execute(new ChannelDownstreamEventRunnable(ctx, e));
189 184
             } else {
190 185
                 ctx.sendDownstream(e);
191 186
             }
8  src/main/java/org/jboss/netty/handler/execution/MemoryAwareThreadPoolExecutor.java
@@ -45,7 +45,6 @@
45 45
 import org.jboss.netty.util.DefaultObjectSizeEstimator;
46 46
 import org.jboss.netty.util.ObjectSizeEstimator;
47 47
 import org.jboss.netty.util.internal.ConcurrentIdentityHashMap;
48  
-import org.jboss.netty.util.internal.DeadLockProofWorker;
49 48
 import org.jboss.netty.util.internal.QueueFactory;
50 49
 import org.jboss.netty.util.internal.SharedResourceMisuseDetector;
51 50
 
@@ -442,12 +441,7 @@ protected void doExecute(Runnable task) {
442 441
      * Executes the specified task without maintaining the event order.
443 442
      */
444 443
     protected final void doUnorderedExecute(Runnable task) {
445  
-        try {
446  
-            DeadLockProofWorker.PARENT.set(this);
447  
-            super.execute(task);
448  
-        } finally {
449  
-            DeadLockProofWorker.PARENT.remove();
450  
-        }
  444
+        super.execute(task);
451 445
     }
452 446
 
453 447
     @Override
4  src/main/java/org/jboss/netty/handler/execution/OrderedMemoryAwareThreadPoolExecutor.java
@@ -31,7 +31,6 @@
31 31
 import org.jboss.netty.channel.ChannelStateEvent;
32 32
 import org.jboss.netty.util.ObjectSizeEstimator;
33 33
 import org.jboss.netty.util.internal.ConcurrentIdentityWeakKeyHashMap;
34  
-import org.jboss.netty.util.internal.DeadLockProofWorker;
35 34
 import org.jboss.netty.util.internal.QueueFactory;
36 35
 
37 36
 /**
@@ -303,7 +302,6 @@ public void run() {
303 302
                 acquired = true;
304 303
                 try {
305 304
                     Thread thread = Thread.currentThread();
306  
-                    DeadLockProofWorker.PARENT.set(OrderedMemoryAwareThreadPoolExecutor.this);
307 305
                     for (;;) {
308 306
                         final Runnable task = tasks.poll();
309 307
                         // if the task is null we should exit the loop
@@ -325,8 +323,6 @@ public void run() {
325 323
                         }
326 324
                     }
327 325
                 } finally {
328  
-                    DeadLockProofWorker.PARENT.remove();
329  
-
330 326
                     // set it back to not running
331 327
                     isRunning.set(false);
332 328
                 }

0 notes on commit a77e4b0

Please sign in to comment.
Something went wrong with that request. Please try again.