[#1363] Make sure ChannnelConfig.setAutoRead(false) will stop read from socket directly
This commit is contained in:
parent
2a7bea2ad3
commit
6942dba855
@ -93,6 +93,11 @@ public abstract class AbstractNioByteChannel extends AbstractNioChannel {
|
||||
"least one byte.");
|
||||
}
|
||||
}
|
||||
if (!config().isAutoRead()) {
|
||||
// stop reading until next Channel.read() call
|
||||
// See https://github.com/netty/netty/issues/1363
|
||||
break loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
|
@ -90,29 +90,32 @@ public abstract class AbstractOioByteChannel extends AbstractOioChannel {
|
||||
break;
|
||||
}
|
||||
|
||||
if (byteBuf.isWritable()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final int capacity = byteBuf.capacity();
|
||||
final int maxCapacity = byteBuf.maxCapacity();
|
||||
if (capacity == maxCapacity) {
|
||||
if (read) {
|
||||
read = false;
|
||||
pipeline.fireInboundBufferUpdated();
|
||||
if (!byteBuf.isWritable()) {
|
||||
throw new IllegalStateException(
|
||||
"an inbound handler whose buffer is full must consume at " +
|
||||
"least one byte.");
|
||||
if (!byteBuf.isWritable()) {
|
||||
final int capacity = byteBuf.capacity();
|
||||
final int maxCapacity = byteBuf.maxCapacity();
|
||||
if (capacity == maxCapacity) {
|
||||
if (read) {
|
||||
read = false;
|
||||
pipeline.fireInboundBufferUpdated();
|
||||
if (!byteBuf.isWritable()) {
|
||||
throw new IllegalStateException(
|
||||
"an inbound handler whose buffer is full must consume at " +
|
||||
"least one byte.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final int writerIndex = byteBuf.writerIndex();
|
||||
if (writerIndex + available > maxCapacity) {
|
||||
byteBuf.capacity(maxCapacity);
|
||||
} else {
|
||||
byteBuf.ensureWritable(available);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final int writerIndex = byteBuf.writerIndex();
|
||||
if (writerIndex + available > maxCapacity) {
|
||||
byteBuf.capacity(maxCapacity);
|
||||
} else {
|
||||
byteBuf.ensureWritable(available);
|
||||
}
|
||||
}
|
||||
if (!config().isAutoRead()) {
|
||||
// stop reading until next Channel.read() call
|
||||
// See https://github.com/netty/netty/issues/1363
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user