netty: move startWriteQueue right after channel is constructed

Now that the commit 65e4d9f has split the channel instantiation and `connect()`, we can `startWriteQueue()` even earlier.
This commit is contained in:
ZHANG Dapeng 2017-03-20 11:54:57 -07:00 committed by GitHub
parent 82bdf53cd3
commit a14689eff8
1 changed files with 2 additions and 2 deletions

View File

@ -190,6 +190,8 @@ class NettyClientTransport implements ConnectionClientTransport {
*/ */
b.handler(negotiationHandler); b.handler(negotiationHandler);
channel = b.register().channel(); channel = b.register().channel();
// Start the write queue as soon as the channel is constructed
handler.startWriteQueue(channel);
// Start the connection operation to the server. // Start the connection operation to the server.
channel.connect(address).addListener(new ChannelFutureListener() { channel.connect(address).addListener(new ChannelFutureListener() {
@Override @Override
@ -206,8 +208,6 @@ class NettyClientTransport implements ConnectionClientTransport {
} }
} }
}); });
// Start the write queue as soon as the channel is constructed
handler.startWriteQueue(channel);
// This write will have no effect, yet it will only complete once the negotiationHandler // This write will have no effect, yet it will only complete once the negotiationHandler
// flushes any pending writes. // flushes any pending writes.
channel.write(NettyClientHandler.NOOP_MESSAGE).addListener(new ChannelFutureListener() { channel.write(NettyClientHandler.NOOP_MESSAGE).addListener(new ChannelFutureListener() {