Home / Class/ AbstractEpollUnsafe Class — netty Architecture

AbstractEpollUnsafe Class — netty Architecture

Architecture documentation for the AbstractEpollUnsafe class in AbstractEpollChannel.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  48a4b0f2_9a93_c0ec_29eb_423e8fb5ce85["AbstractEpollUnsafe"]
  132fd5c4_77ce_b469_aad1_27fa2fbb41de["AbstractEpollChannel.java"]
  48a4b0f2_9a93_c0ec_29eb_423e8fb5ce85 -->|defined in| 132fd5c4_77ce_b469_aad1_27fa2fbb41de
  bfa0df08_db5f_2204_12fc_ff532e62e90f["Channel()"]
  48a4b0f2_9a93_c0ec_29eb_423e8fb5ce85 -->|method| bfa0df08_db5f_2204_12fc_ff532e62e90f
  756e0774_76c6_a919_641a_add92f8b58bf["FileDescriptor()"]
  48a4b0f2_9a93_c0ec_29eb_423e8fb5ce85 -->|method| 756e0774_76c6_a919_641a_add92f8b58bf
  d9ab1040_9ace_496a_a503_4d950b47fbce["close()"]
  48a4b0f2_9a93_c0ec_29eb_423e8fb5ce85 -->|method| d9ab1040_9ace_496a_a503_4d950b47fbce
  2ab93c32_441f_8b46_a20b_b284364fb016["handle()"]
  48a4b0f2_9a93_c0ec_29eb_423e8fb5ce85 -->|method| 2ab93c32_441f_8b46_a20b_b284364fb016
  4bcd90db_c084_162b_2a7a_36770794a97d["epollInReady()"]
  48a4b0f2_9a93_c0ec_29eb_423e8fb5ce85 -->|method| 4bcd90db_c084_162b_2a7a_36770794a97d
  79fa9e79_7cee_d3a0_2104_e37cb65f90fb["shouldStopReading()"]
  48a4b0f2_9a93_c0ec_29eb_423e8fb5ce85 -->|method| 79fa9e79_7cee_d3a0_2104_e37cb65f90fb
  d090690c_ba63_7842_6536_a467e153f1b2["epollRdHupReady()"]
  48a4b0f2_9a93_c0ec_29eb_423e8fb5ce85 -->|method| d090690c_ba63_7842_6536_a467e153f1b2
  58b9aeb2_5343_e611_e004_2c5a523f6624["clearEpollRdHup()"]
  48a4b0f2_9a93_c0ec_29eb_423e8fb5ce85 -->|method| 58b9aeb2_5343_e611_e004_2c5a523f6624
  0f938c96_9ae0_6ccc_0306_33c0df2458f1["shutdownInput()"]
  48a4b0f2_9a93_c0ec_29eb_423e8fb5ce85 -->|method| 0f938c96_9ae0_6ccc_0306_33c0df2458f1
  6f55cbec_9a52_e47a_1d73_fecef5eb8c03["fireEventAndClose()"]
  48a4b0f2_9a93_c0ec_29eb_423e8fb5ce85 -->|method| 6f55cbec_9a52_e47a_1d73_fecef5eb8c03
  d598f65c_421c_5857_8620_fb50eb0214d0["EpollRecvByteAllocatorHandle()"]
  48a4b0f2_9a93_c0ec_29eb_423e8fb5ce85 -->|method| d598f65c_421c_5857_8620_fb50eb0214d0
  3ff443da_072e_9dbd_b6e0_a9c6efcb2f13["flush0()"]
  48a4b0f2_9a93_c0ec_29eb_423e8fb5ce85 -->|method| 3ff443da_072e_9dbd_b6e0_a9c6efcb2f13
  0ff6908a_e49f_b5f9_0eaa_0238ef0f2863["epollOutReady()"]
  48a4b0f2_9a93_c0ec_29eb_423e8fb5ce85 -->|method| 0ff6908a_e49f_b5f9_0eaa_0238ef0f2863

Relationship Graph

Source Code

transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollChannel.java lines 434–776

    protected abstract class AbstractEpollUnsafe extends AbstractUnsafe implements EpollIoHandle {
        boolean readPending;
        private EpollRecvByteAllocatorHandle allocHandle;

        Channel channel() {
            return AbstractEpollChannel.this;
        }

        @Override
        public FileDescriptor fd() {
            return AbstractEpollChannel.this.fd();
        }

        @Override
        public void close() {
            close(voidPromise());
        }

        @Override
        public void handle(IoRegistration registration, IoEvent event) {
            EpollIoEvent epollEvent = (EpollIoEvent) event;
            int ops = epollEvent.ops().value;

            // Don't change the ordering of processing EPOLLOUT | EPOLLRDHUP / EPOLLIN if you're not 100%
            // sure about it!
            // Re-ordering can easily introduce bugs and bad side-effects, as we found out painfully in the
            // past.

            // First check for EPOLLOUT as we may need to fail the connect ChannelPromise before try
            // to read from the file descriptor.
            // See https://github.com/netty/netty/issues/3785
            //
            // It is possible for an EPOLLOUT or EPOLLERR to be generated when a connection is refused.
            // In either case epollOutReady() will do the correct thing (finish connecting, or fail
            // the connection).
            // See https://github.com/netty/netty/issues/3848
            if ((ops & EPOLL_ERR_OUT_MASK) != 0) {
                // Force flush of data as the epoll is writable again
                epollOutReady();
            }

            // Check EPOLLIN before EPOLLRDHUP to ensure all data is read before shutting down the input.
            // See https://github.com/netty/netty/issues/4317.
            //
            // If EPOLLIN or EPOLLERR was received and the channel is still open call epollInReady(). This will
            // try to read from the underlying file descriptor and so notify the user about the error.
            if ((ops & EPOLL_ERR_IN_MASK) != 0) {
                // The Channel is still open and there is something to read. Do it now.
                epollInReady();
            }

            // Check if EPOLLRDHUP was set, this will notify us for connection-reset in which case
            // we may close the channel directly or try to read more data depending on the state of the
            // Channel and als depending on the AbstractEpollChannel subtype.
            if ((ops & EPOLL_RDHUP_MASK) != 0) {
                epollRdHupReady();
            }
        }

        /**
         * Called once EPOLLIN event is ready to be processed
         */
        abstract void epollInReady();

        final boolean shouldStopReading(ChannelConfig config) {
            // Check if there is a readPending which was not processed yet.
            // This could be for two reasons:
            // * The user called Channel.read() or ChannelHandlerContext.read() in channelRead(...) method
            // * The user called Channel.read() or ChannelHandlerContext.read() in channelReadComplete(...) method
            //
            // See https://github.com/netty/netty/issues/2254
            return !readPending && !config.isAutoRead();
        }

        /**
         * Called once EPOLLRDHUP event is ready to be processed
         */
        final void epollRdHupReady() {
            // This must happen before we attempt to read. This will ensure reading continues until an error occurs.
            recvBufAllocHandle().receivedRdHup();

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free