Skip to content

Commit

Permalink
Handle ping correctly in NioTransport (#25462)
Browse files Browse the repository at this point in the history
Our current TCPTransport logic assumes that we do not pass pings to
the TCPTransport level.

This commit fixes an issue where NioTransport was passing pings to
TCPTransport and leading to exceptions.
  • Loading branch information
Tim-Brooks committed Jun 29, 2017
1 parent acade2b commit 6c58f0c
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public int read() throws IOException {

BytesReference message;

// Frame decoder will throw an exception if the message is improperly formatted, the header is incorrect,
// or the message is corrupted
while ((message = frameDecoder.decode(createCompositeBuffer(), rawBytesCount)) != null) {
int messageLengthWithHeader = message.length();
NetworkBytesReference.vectorizedIncrementReadIndexes(references, messageLengthWithHeader);
Expand All @@ -75,7 +77,11 @@ public int read() throws IOException {

try {
BytesReference messageWithoutHeader = message.slice(6, message.length() - 6);
handler.handleMessage(messageWithoutHeader, channel, channel.getProfile(), messageWithoutHeader.length());

// A message length of 6 bytes it is just a ping. Ignore for now.
if (messageLengthWithHeader != 6) {
handler.handleMessage(messageWithoutHeader, channel, channel.getProfile(), messageWithoutHeader.length());
}
} catch (Exception e) {
handler.handleException(channel, e);
}
Expand Down

0 comments on commit 6c58f0c

Please sign in to comment.