Skip to content

Commit

Permalink
solve deadlock occured between foreman and netty threads
Browse files Browse the repository at this point in the history
  • Loading branch information
weijie.tong committed Sep 14, 2017
1 parent 52d7a0b commit 9808a43
Showing 1 changed file with 6 additions and 4 deletions.
Expand Up @@ -17,9 +17,6 @@
*/
package org.apache.drill.exec.rpc;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelFuture;

import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

Expand All @@ -30,6 +27,9 @@
import com.carrotsearch.hppc.procedures.IntObjectProcedure;
import com.google.common.base.Preconditions;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelFuture;

/**
* Manages the creation of rpc futures for a particular socket <--> socket
* connection. Generally speaking, there will be two threads working with this
Expand All @@ -54,10 +54,12 @@ void channelClosed(Throwable ex) {
isOpen.set(false);
if (ex != null) {
final RpcException e = RpcException.mapException(ex);
IntObjectHashMap<RpcOutcome<?>> clonedMap;
synchronized (map) {
map.forEach(new SetExceptionProcedure(e));
clonedMap = map.clone();
map.clear();
}
clonedMap.forEach(new SetExceptionProcedure(e));
}
}

Expand Down

0 comments on commit 9808a43

Please sign in to comment.