[#1777] Use correct Thread when close per channel

This commit is contained in:
Norman Maurer 2013-08-25 21:22:53 +02:00
parent f76c01c3aa
commit 77d4222db5

View File

@ -198,9 +198,21 @@ public class LocalChannel extends AbstractChannel {
state = 3;
}
LocalChannel peer = this.peer;
final LocalChannel peer = this.peer;
if (peer != null && peer.isActive()) {
peer.unsafe().close(unsafe().voidPromise());
// Need to execute the close in the correct EventLoop
// See https://github.com/netty/netty/issues/1777
EventLoop eventLoop = peer.eventLoop();
if (eventLoop.inEventLoop()) {
peer.unsafe().close(unsafe().voidPromise());
} else {
peer.eventLoop().execute(new Runnable() {
@Override
public void run() {
peer.unsafe().close(unsafe().voidPromise());
}
});
}
this.peer = null;
}
}