Home / Function/ epollInReady() — netty Function Reference

epollInReady() — netty Function Reference

Architecture documentation for the epollInReady() function in AbstractEpollStreamChannel.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  7df0a4ff_9721_6d9a_87c1_13687d3d7428["epollInReady()"]
  72ebf1b5_495b_1c86_5feb_799c19e065e3["EpollStreamUnsafe"]
  7df0a4ff_9721_6d9a_87c1_13687d3d7428 -->|defined in| 72ebf1b5_495b_1c86_5feb_799c19e065e3
  4c1d928e_3480_799c_0e69_d72066550f4b["doClose()"]
  7df0a4ff_9721_6d9a_87c1_13687d3d7428 -->|calls| 4c1d928e_3480_799c_0e69_d72066550f4b
  13ded924_af0b_a7c0_afbc_d26699c3f7a3["handleReadException()"]
  7df0a4ff_9721_6d9a_87c1_13687d3d7428 -->|calls| 13ded924_af0b_a7c0_afbc_d26699c3f7a3
  style 7df0a4ff_9721_6d9a_87c1_13687d3d7428 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java lines 749–842

        @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();
                        byteBuf = null;
                        allDataRead = allocHandle.lastBytesRead() < 0;
                        if (allDataRead) {
                            // There is nothing left to read as we received an EOF.
                            readPending = false;
                        }
                        break;
                    }
                    allocHandle.incMessagesRead(1);
                    readPending = false;
                    pipeline.fireChannelRead(byteBuf);
                    byteBuf = null;

                    if (shouldBreakEpollInReady(config)) {
                        // We need to do this for two reasons:
                        //
                        // - If the input was shutdown in between (which may be the case when the user did it in the
                        //   fireChannelRead(...) method we should not try to read again to not produce any
                        //   miss-leading exceptions.
                        //
                        // - If the user closes the channel we need to ensure we not try to read from it again as
                        //   the filedescriptor may be re-used already by the OS if the system is handling a lot of
                        //   concurrent connections and so needs a lot of filedescriptors. If not do this we risk
                        //   reading data from a filedescriptor that belongs to another socket then the socket that
                        //   was "wrapped" by this Channel implementation.
                        break;
                    }
                } while (allocHandle.continueReading());

                allocHandle.readComplete();
                pipeline.fireChannelReadComplete();

                if (allDataRead) {
                    shutdownInput(true);
                }
            } catch (Throwable t) {

Domain

Subdomains

Frequently Asked Questions

What does epollInReady() do?
epollInReady() is a function in the netty codebase, defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java.
Where is epollInReady() defined?
epollInReady() is defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java at line 749.
What does epollInReady() call?
epollInReady() calls 2 function(s): doClose, handleReadException.

Analyze Your Own Codebase

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

Try Supermodel Free