Home / Function/ recv() — netty Function Reference

recv() — netty Function Reference

Architecture documentation for the recv() function in QuicheQuicStreamChannel.java from the netty codebase.

Function java Buffer Allocators calls 6 called by 2

Entity Profile

Dependency Diagram

graph TD
  08842539_3127_e4fc_3930_f7214f42f664["recv()"]
  77188bb7_e7ad_de01_3b54_5bc50b9e2df1["QuicStreamChannelUnsafe"]
  08842539_3127_e4fc_3930_f7214f42f664 -->|defined in| 77188bb7_e7ad_de01_3b54_5bc50b9e2df1
  cf8b96f4_7e83_fd84_1e70_d4800a7042f8["readable()"]
  cf8b96f4_7e83_fd84_1e70_d4800a7042f8 -->|calls| 08842539_3127_e4fc_3930_f7214f42f664
  71da0969_c1b1_b745_dcbf_503b04d1d4fe["beginRead()"]
  71da0969_c1b1_b745_dcbf_503b04d1d4fe -->|calls| 08842539_3127_e4fc_3930_f7214f42f664
  3945de9a_84d0_4fbf_7e09_189541cf620c["recvBufAllocHandle()"]
  08842539_3127_e4fc_3930_f7214f42f664 -->|calls| 3945de9a_84d0_4fbf_7e09_189541cf620c
  d46e3d31_9ac9_1dec_c60f_c3c77a46395a["streamId()"]
  08842539_3127_e4fc_3930_f7214f42f664 -->|calls| d46e3d31_9ac9_1dec_c60f_c3c77a46395a
  f4e51d31_b8c1_2ecc_6e5f_9e10bd92b1b2["readComplete()"]
  08842539_3127_e4fc_3930_f7214f42f664 -->|calls| f4e51d31_b8c1_2ecc_6e5f_9e10bd92b1b2
  0ba407db_98b9_c902_b664_3b3bfa2bab6f["closeOnRead()"]
  08842539_3127_e4fc_3930_f7214f42f664 -->|calls| 0ba407db_98b9_c902_b664_3b3bfa2bab6f
  af59efb8_dc8a_4d8b_ff8b_642fc3890db5["handleReadException()"]
  08842539_3127_e4fc_3930_f7214f42f664 -->|calls| af59efb8_dc8a_4d8b_ff8b_642fc3890db5
  d8188365_6040_9a5b_54b5_09070a8dbc2a["removeStreamFromParent()"]
  08842539_3127_e4fc_3930_f7214f42f664 -->|calls| d8188365_6040_9a5b_54b5_09070a8dbc2a
  style 08842539_3127_e4fc_3930_f7214f42f664 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicStreamChannel.java lines 950–1048

        void recv() {
            assert eventLoop().inEventLoop();
            if (inRecv) {
                // As the use may call read() we need to guard against reentrancy here as otherwise it could
                // be possible that we re-enter this method while still processing it.
                return;
            }

            inRecv = true;
            try {
                ChannelPipeline pipeline = pipeline();
                QuicheQuicStreamChannelConfig config = (QuicheQuicStreamChannelConfig) config();
                // Directly access the DirectIoByteBufAllocator as we need an direct buffer to read into in all cases
                // even if there is no Unsafe present and the direct buffer is not pooled.
                DirectIoByteBufAllocator allocator = config.allocator;
                @SuppressWarnings("deprecation")
                RecvByteBufAllocator.Handle allocHandle = this.recvBufAllocHandle();
                boolean readFrames = config.isReadFrames();

                // We should loop as long as a read() was requested and there is anything left to read, which means the
                // stream was marked as readable before.
                while (active && readPending && readable) {
                    allocHandle.reset(config);
                    ByteBuf byteBuf = null;
                    QuicheQuicChannel parent = parent();
                    // It's possible that the stream was marked as finish while we iterated over the readable streams
                    // or while we did have auto read disabled. If so we need to ensure we not try to read from it as it
                    // would produce an error.
                    boolean readCompleteNeeded = false;
                    boolean continueReading = true;
                    try {
                        while (!finReceived && continueReading) {
                            byteBuf = allocHandle.allocate(allocator);
                            allocHandle.attemptedBytesRead(byteBuf.writableBytes());
                            QuicheQuicChannel.StreamRecvResult result = parent.streamRecv(streamId(), byteBuf);
                            switch (result) {
                                case DONE:
                                    // Nothing left to read;
                                    readable = false;
                                    break;
                                case FIN:
                                    // If we received a FIN we also should mark the channel as non-readable as
                                    // there is nothing left to read really.
                                    readable = false;
                                    finReceived = true;
                                    inputShutdown = true;
                                    break;
                                case OK:
                                    break;
                                default:
                                    throw new Error("Unexpected StreamRecvResult: " + result);
                            }
                            allocHandle.lastBytesRead(byteBuf.readableBytes());
                            if (allocHandle.lastBytesRead() <= 0) {
                                byteBuf.release();
                                if (finReceived && readFrames) {
                                    // If we read QuicStreamFrames we should fire an frame through the pipeline
                                    // with an empty buffer but the fin flag set to true.
                                    byteBuf = Unpooled.EMPTY_BUFFER;
                                } else {
                                    byteBuf = null;
                                    break;
                                }
                            }
                            // We did read one message.
                            allocHandle.incMessagesRead(1);
                            readCompleteNeeded = true;

                            // It's important that we reset this to false before we call fireChannelRead(...)
                            // as the user may request another read() from channelRead(...) callback.
                            readPending = false;

                            if (readFrames) {
                                pipeline.fireChannelRead(new DefaultQuicStreamFrame(byteBuf, finReceived));
                            } else {
                                pipeline.fireChannelRead(byteBuf);
                            }
                            byteBuf = null;
                            continueReading = allocHandle.continueReading();
                        }

Domain

Subdomains

Frequently Asked Questions

What does recv() do?
recv() is a function in the netty codebase, defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicStreamChannel.java.
Where is recv() defined?
recv() is defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicStreamChannel.java at line 950.
What does recv() call?
recv() calls 6 function(s): closeOnRead, handleReadException, readComplete, recvBufAllocHandle, removeStreamFromParent, streamId.
What calls recv()?
recv() is called by 2 function(s): beginRead, readable.

Analyze Your Own Codebase

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

Try Supermodel Free