cf171ff525 Close Regression

Motivation:
cf171ff525 introduced a change in behavior when dealing with closing channel in the read loop. This changed behavior may use stale state to determine if a channel should be shutdown and may be incorrect.

Modifications:
- Revert the usage of potentially stale state

Result:
Closing a channel in the read loop is based upon current state instead of potentially stale state.
This commit is contained in:
Scott Mitchell 2016-03-24 12:08:37 -07:00
parent 15f3b69b9e
commit 99c85ef4f5
2 changed files with 4 additions and 3 deletions

View File

@ -884,7 +884,6 @@ public abstract class AbstractEpollStreamChannel extends AbstractEpollChannel im
if (close) {
shutdownInput();
close = false;
}
} catch (Throwable t) {
handleReadException(pipeline, byteBuf, t, close, allocHandle);

View File

@ -105,6 +105,7 @@ public abstract class AbstractNioByteChannel extends AbstractNioChannel {
allocHandle.reset(config);
ByteBuf byteBuf = null;
boolean close = false;
try {
boolean needReadPendingReset = true;
do {
@ -114,6 +115,7 @@ public abstract class AbstractNioByteChannel extends AbstractNioChannel {
// nothing was read. release the buffer.
byteBuf.release();
byteBuf = null;
close = allocHandle.lastBytesRead() < 0;
break;
}
@ -129,11 +131,11 @@ public abstract class AbstractNioByteChannel extends AbstractNioChannel {
allocHandle.readComplete();
pipeline.fireChannelReadComplete();
if (allocHandle.lastBytesRead() < 0) {
if (close) {
closeOnRead(pipeline);
}
} catch (Throwable t) {
handleReadException(pipeline, byteBuf, t, allocHandle.lastBytesRead() < 0, allocHandle);
handleReadException(pipeline, byteBuf, t, close, allocHandle);
} finally {
// Check if there is a readPending which was not processed yet.
// This could be for two reasons: