EpollDatagramChannelUnsafe Class — netty Architecture
Architecture documentation for the EpollDatagramChannelUnsafe class in EpollDatagramChannel.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 16c18e77_27a9_db0d_1655_3af5467ab836["EpollDatagramChannelUnsafe"] b45f5a76_cc28_594a_91e8_cf222446cc84["EpollDatagramChannel.java"] 16c18e77_27a9_db0d_1655_3af5467ab836 -->|defined in| b45f5a76_cc28_594a_91e8_cf222446cc84 0ad4ff23_5654_f57a_1eda_1a36ffc34db3["epollInReady()"] 16c18e77_27a9_db0d_1655_3af5467ab836 -->|method| 0ad4ff23_5654_f57a_1eda_1a36ffc34db3
Relationship Graph
Source Code
transport-classes-epoll/src/main/java/io/netty/channel/epoll/EpollDatagramChannel.java lines 542–613
final class EpollDatagramChannelUnsafe extends AbstractEpollUnsafe {
@Override
void epollInReady() {
assert eventLoop().inEventLoop();
EpollDatagramChannelConfig config = config();
if (shouldBreakEpollInReady(config)) {
clearEpollIn0();
return;
}
final EpollRecvByteAllocatorHandle allocHandle = recvBufAllocHandle();
final ChannelPipeline pipeline = pipeline();
final ByteBufAllocator allocator = config.getAllocator();
allocHandle.reset(config);
Throwable exception = null;
try {
try {
boolean connected = isConnected();
do {
final boolean read;
int datagramSize = config().getMaxDatagramPayloadSize();
ByteBuf byteBuf = allocHandle.allocate(allocator);
// Only try to use recvmmsg if its really supported by the running system.
int numDatagram = Native.IS_SUPPORTING_RECVMMSG ?
datagramSize == 0 ? 1 : byteBuf.writableBytes() / datagramSize :
0;
try {
if (numDatagram <= 1) {
if (!connected || config.isUdpGro()) {
read = recvmsg(allocHandle, cleanDatagramPacketArray(), byteBuf);
} else {
read = connectedRead(allocHandle, byteBuf, datagramSize);
}
} else {
// Try to use scattering reads via recvmmsg(...) syscall.
read = scatteringRead(allocHandle, cleanDatagramPacketArray(),
byteBuf, datagramSize, numDatagram);
}
} catch (NativeIoException e) {
if (connected) {
throw translateForConnected(e);
}
throw e;
}
if (read) {
readPending = false;
} else {
break;
}
// We use the TRUE_SUPPLIER as it is also ok to read less then what we did try to read (as long
// as we read anything).
} while (allocHandle.continueReading(UncheckedBooleanSupplier.TRUE_SUPPLIER));
} catch (Throwable t) {
exception = t;
}
allocHandle.readComplete();
pipeline.fireChannelReadComplete();
if (exception != null) {
pipeline.fireExceptionCaught(exception);
}
} finally {
if (shouldStopReading(config)) {
clearEpollIn();
}
}
}
}
Source
Frequently Asked Questions
What is the EpollDatagramChannelUnsafe class?
EpollDatagramChannelUnsafe is a class in the netty codebase, defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/EpollDatagramChannel.java.
Where is EpollDatagramChannelUnsafe defined?
EpollDatagramChannelUnsafe is defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/EpollDatagramChannel.java at line 542.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free