[#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.");
|
"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) {
|
} catch (Throwable t) {
|
||||||
|
@ -90,29 +90,32 @@ public abstract class AbstractOioByteChannel extends AbstractOioChannel {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (byteBuf.isWritable()) {
|
if (!byteBuf.isWritable()) {
|
||||||
continue;
|
final int capacity = byteBuf.capacity();
|
||||||
}
|
final int maxCapacity = byteBuf.maxCapacity();
|
||||||
|
if (capacity == maxCapacity) {
|
||||||
final int capacity = byteBuf.capacity();
|
if (read) {
|
||||||
final int maxCapacity = byteBuf.maxCapacity();
|
read = false;
|
||||||
if (capacity == maxCapacity) {
|
pipeline.fireInboundBufferUpdated();
|
||||||
if (read) {
|
if (!byteBuf.isWritable()) {
|
||||||
read = false;
|
throw new IllegalStateException(
|
||||||
pipeline.fireInboundBufferUpdated();
|
"an inbound handler whose buffer is full must consume at " +
|
||||||
if (!byteBuf.isWritable()) {
|
"least one byte.");
|
||||||
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 (!config().isAutoRead()) {
|
||||||
if (writerIndex + available > maxCapacity) {
|
// stop reading until next Channel.read() call
|
||||||
byteBuf.capacity(maxCapacity);
|
// See https://github.com/netty/netty/issues/1363
|
||||||
} else {
|
break;
|
||||||
byteBuf.ensureWritable(available);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user