From 59c2fd881318b5c421983881e68889225e0a4d18 Mon Sep 17 00:00:00 2001 From: bgallagher Date: Fri, 9 Aug 2013 16:24:14 -0400 Subject: [PATCH] [#1723] invoke close in eventloop --- .../channel/DefaultChannelHandlerContext.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java b/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java index 1a8e079760..6ec99eae56 100644 --- a/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java +++ b/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java @@ -498,22 +498,25 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements public ChannelFuture disconnect(final ChannelPromise promise) { validatePromise(promise, false); - // Translate disconnect to close if the channel has no notion of disconnect-reconnect. - // So far, UDP/IP is the only transport that has such behavior. - if (!channel().metadata().hasDisconnect()) { - findContextOutbound().invokeClose(promise); - return promise; - } - final DefaultChannelHandlerContext next = findContextOutbound(); EventExecutor executor = next.executor(); if (executor.inEventLoop()) { - next.invokeDisconnect(promise); + // Translate disconnect to close if the channel has no notion of disconnect-reconnect. + // So far, UDP/IP is the only transport that has such behavior. + if (!channel().metadata().hasDisconnect()) { + next.invokeClose(promise); + } else { + next.invokeDisconnect(promise); + } } else { executor.execute(new Runnable() { @Override public void run() { - next.invokeDisconnect(promise); + if (!channel().metadata().hasDisconnect()) { + next.invokeClose(promise); + } else { + next.invokeDisconnect(promise); + } } }); }