doRead() — netty Function Reference
Architecture documentation for the doRead() function in AbstractOioMessageChannel.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 654f6259_3abd_002a_bdf7_32613ed60eb2["doRead()"] 05d0e1d1_041f_3bb0_1b63_cf10f9ca30d5["AbstractOioMessageChannel"] 654f6259_3abd_002a_bdf7_32613ed60eb2 -->|defined in| 05d0e1d1_041f_3bb0_1b63_cf10f9ca30d5 17a6299a_a14f_2e88_94f3_ebcb9fe2d898["doReadMessages()"] 654f6259_3abd_002a_bdf7_32613ed60eb2 -->|calls| 17a6299a_a14f_2e88_94f3_ebcb9fe2d898 style 654f6259_3abd_002a_bdf7_32613ed60eb2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
transport/src/main/java/io/netty/channel/oio/AbstractOioMessageChannel.java lines 41–107
@Override
protected void doRead() {
if (!readPending) {
// We have to check readPending here because the Runnable to read could have been scheduled and later
// during the same read loop readPending was set to false.
return;
}
// In OIO we should set readPending to false even if the read was not successful so we can schedule
// another read on the event loop if no reads are done.
readPending = false;
final ChannelConfig config = config();
final ChannelPipeline pipeline = pipeline();
final RecvByteBufAllocator.Handle allocHandle = unsafe().recvBufAllocHandle();
allocHandle.reset(config);
boolean closed = false;
Throwable exception = null;
try {
do {
// Perform a read.
int localRead = doReadMessages(readBuf);
if (localRead == 0) {
break;
}
if (localRead < 0) {
closed = true;
break;
}
allocHandle.incMessagesRead(localRead);
} while (allocHandle.continueReading());
} catch (Throwable t) {
exception = t;
}
boolean readData = false;
int size = readBuf.size();
if (size > 0) {
readData = true;
for (int i = 0; i < size; i++) {
readPending = false;
pipeline.fireChannelRead(readBuf.get(i));
}
readBuf.clear();
allocHandle.readComplete();
pipeline.fireChannelReadComplete();
}
if (exception != null) {
if (exception instanceof IOException) {
closed = true;
}
pipeline.fireExceptionCaught(exception);
}
if (closed) {
if (isOpen()) {
unsafe().close(unsafe().voidPromise());
}
} else if (readPending || config.isAutoRead() || !readData && isActive()) {
// Reading 0 bytes could mean there is a SocketTimeout and no data was actually read, so we
// should execute read() again because no data may have been read.
read();
}
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does doRead() do?
doRead() is a function in the netty codebase, defined in transport/src/main/java/io/netty/channel/oio/AbstractOioMessageChannel.java.
Where is doRead() defined?
doRead() is defined in transport/src/main/java/io/netty/channel/oio/AbstractOioMessageChannel.java at line 41.
What does doRead() call?
doRead() calls 1 function(s): doReadMessages.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free