EpollStreamUnsafe Class — netty Architecture
Architecture documentation for the EpollStreamUnsafe class in AbstractEpollStreamChannel.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 72ebf1b5_495b_1c86_5feb_799c19e065e3["EpollStreamUnsafe"] 70734405_31fd_71db_63bc_2114f3b39591["AbstractEpollStreamChannel.java"] 72ebf1b5_495b_1c86_5feb_799c19e065e3 -->|defined in| 70734405_31fd_71db_63bc_2114f3b39591 84341735_5c1a_48bf_4206_dbe8582ba505["Executor()"] 72ebf1b5_495b_1c86_5feb_799c19e065e3 -->|method| 84341735_5c1a_48bf_4206_dbe8582ba505 13ded924_af0b_a7c0_afbc_d26699c3f7a3["handleReadException()"] 72ebf1b5_495b_1c86_5feb_799c19e065e3 -->|method| 13ded924_af0b_a7c0_afbc_d26699c3f7a3 0c64f740_c4a8_6f44_b952_50064bc97fa7["EpollRecvByteAllocatorHandle()"] 72ebf1b5_495b_1c86_5feb_799c19e065e3 -->|method| 0c64f740_c4a8_6f44_b952_50064bc97fa7 7df0a4ff_9721_6d9a_87c1_13687d3d7428["epollInReady()"] 72ebf1b5_495b_1c86_5feb_799c19e065e3 -->|method| 7df0a4ff_9721_6d9a_87c1_13687d3d7428
Relationship Graph
Source Code
transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java lines 713–843
class EpollStreamUnsafe extends AbstractEpollUnsafe {
// Overridden here just to be able to access this method from AbstractEpollStreamChannel
@Override
protected Executor prepareToClose() {
return super.prepareToClose();
}
private void handleReadException(ChannelPipeline pipeline, ByteBuf byteBuf, Throwable cause,
boolean allDataRead, EpollRecvByteAllocatorHandle allocHandle) {
if (byteBuf != null) {
if (byteBuf.isReadable()) {
readPending = false;
pipeline.fireChannelRead(byteBuf);
} else {
byteBuf.release();
}
}
allocHandle.readComplete();
pipeline.fireChannelReadComplete();
pipeline.fireExceptionCaught(cause);
// If oom will close the read event, release connection.
// See https://github.com/netty/netty/issues/10434
if (allDataRead ||
cause instanceof OutOfMemoryError ||
cause instanceof LeakPresenceDetector.AllocationProhibitedException ||
cause instanceof IOException) {
shutdownInput(true);
}
}
@Override
EpollRecvByteAllocatorHandle newEpollHandle(RecvByteBufAllocator.ExtendedHandle handle) {
return new EpollRecvByteAllocatorStreamingHandle(handle);
}
@Override
void epollInReady() {
final ChannelConfig config = config();
if (shouldBreakEpollInReady(config)) {
clearEpollIn0();
return;
}
final EpollRecvByteAllocatorHandle allocHandle = recvBufAllocHandle();
final ChannelPipeline pipeline = pipeline();
final ByteBufAllocator allocator = config.getAllocator();
allocHandle.reset(config);
ByteBuf byteBuf = null;
boolean allDataRead = false;
Queue<SpliceInTask> sQueue = null;
try {
do {
if (sQueue != null || (sQueue = spliceQueue) != null) {
SpliceInTask spliceTask = sQueue.peek();
if (spliceTask != null) {
boolean spliceInResult = spliceTask.spliceIn(allocHandle);
if (allocHandle.isReceivedRdHup()) {
shutdownInput(false);
}
if (spliceInResult) {
// We need to check if it is still active as if not we removed all SpliceTasks in
// doClose(...)
if (isActive()) {
sQueue.remove();
}
continue;
} else {
break;
}
}
}
// we use a direct buffer here as the native implementations only be able
// to handle direct buffers.
byteBuf = allocHandle.allocate(allocator);
allocHandle.lastBytesRead(doReadBytes(byteBuf));
if (allocHandle.lastBytesRead() <= 0) {
// nothing was read, release the buffer.
byteBuf.release();
Defined In
Source
Frequently Asked Questions
What is the EpollStreamUnsafe class?
EpollStreamUnsafe is a class in the netty codebase, defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java.
Where is EpollStreamUnsafe defined?
EpollStreamUnsafe is defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java at line 713.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free