Home / Class/ EpollDomainUnsafe Class — netty Architecture

EpollDomainUnsafe Class — netty Architecture

Architecture documentation for the EpollDomainUnsafe class in EpollDomainSocketChannel.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  84db7f91_bd76_2d86_db56_3c4ee63848b2["EpollDomainUnsafe"]
  b7581c9c_c732_6192_ad19_22dfd8e46afd["EpollDomainSocketChannel.java"]
  84db7f91_bd76_2d86_db56_3c4ee63848b2 -->|defined in| b7581c9c_c732_6192_ad19_22dfd8e46afd
  8afbdf19_902e_f963_7c70_1aba7dfac97f["epollInReady()"]
  84db7f91_bd76_2d86_db56_3c4ee63848b2 -->|method| 8afbdf19_902e_f963_7c70_1aba7dfac97f
  4c0d9ed1_84da_87d1_a80e_6113c2fde7e3["epollInReadFd()"]
  84db7f91_bd76_2d86_db56_3c4ee63848b2 -->|method| 4c0d9ed1_84da_87d1_a80e_6113c2fde7e3

Relationship Graph

Source Code

transport-classes-epoll/src/main/java/io/netty/channel/epoll/EpollDomainSocketChannel.java lines 133–191

    private final class EpollDomainUnsafe extends EpollStreamUnsafe {
        @Override
        void epollInReady() {
            switch (config().getReadMode()) {
                case BYTES:
                    super.epollInReady();
                    break;
                case FILE_DESCRIPTORS:
                    epollInReadFd();
                    break;
                default:
                    throw new Error("Unexpected read mode: " + config().getReadMode());
            }
        }

        private void epollInReadFd() {
            if (socket.isInputShutdown()) {
                clearEpollIn0();
                return;
            }
            final ChannelConfig config = config();
            final EpollRecvByteAllocatorHandle allocHandle = recvBufAllocHandle();

            final ChannelPipeline pipeline = pipeline();
            allocHandle.reset(config);

            try {
                readLoop: do {
                    // lastBytesRead represents the fd. We use lastBytesRead because it must be set so that the
                    // EpollRecvByteAllocatorHandle knows if it should try to read again or not when autoRead is
                    // enabled.
                    allocHandle.lastBytesRead(socket.recvFd());
                    switch(allocHandle.lastBytesRead()) {
                    case 0:
                        break readLoop;
                    case -1:
                        close(voidPromise());
                        return;
                    default:
                        allocHandle.incMessagesRead(1);
                        readPending = false;
                        pipeline.fireChannelRead(new FileDescriptor(allocHandle.lastBytesRead()));
                        break;
                    }
                } while (allocHandle.continueReading());

                allocHandle.readComplete();
                pipeline.fireChannelReadComplete();
            } catch (Throwable t) {
                allocHandle.readComplete();
                pipeline.fireChannelReadComplete();
                pipeline.fireExceptionCaught(t);
            } finally {
                if (shouldStopReading(config)) {
                    clearEpollIn();
                }
            }
        }
    }

Frequently Asked Questions

What is the EpollDomainUnsafe class?
EpollDomainUnsafe is a class in the netty codebase, defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/EpollDomainSocketChannel.java.
Where is EpollDomainUnsafe defined?
EpollDomainUnsafe is defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/EpollDomainSocketChannel.java at line 133.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free