Home / Function/ connectionRecv() — netty Function Reference

connectionRecv() — netty Function Reference

Architecture documentation for the connectionRecv() function in QuicheQuicChannel.java from the netty codebase.

Function java Buffer Allocators calls 7 called by 1

Entity Profile

Dependency Diagram

graph TD
  c4a3c3a8_c9a0_f1c5_a6e4_d976b89450ea["connectionRecv()"]
  981bac79_4fa5_9e57_50c8_e12d0b35f6d4["QuicChannelUnsafe"]
  c4a3c3a8_c9a0_f1c5_a6e4_d976b89450ea -->|defined in| 981bac79_4fa5_9e57_50c8_e12d0b35f6d4
  8694896e_30ff_0192_2de2_f7fc29767efb["recv()"]
  8694896e_30ff_0192_2de2_f7fc29767efb -->|calls| c4a3c3a8_c9a0_f1c5_a6e4_d976b89450ea
  ae06f64f_455f_edc7_057f_27f8e23a5b93["tryFailConnectPromise()"]
  c4a3c3a8_c9a0_f1c5_a6e4_d976b89450ea -->|calls| ae06f64f_455f_edc7_057f_27f8e23a5b93
  df3e43f0_4607_0b84_f830_a8655804f40e["fireExceptionEvents()"]
  c4a3c3a8_c9a0_f1c5_a6e4_d976b89450ea -->|calls| df3e43f0_4607_0b84_f830_a8655804f40e
  cf241bdc_17de_d59f_740a_78af39289ce8["runTasksDirectly()"]
  c4a3c3a8_c9a0_f1c5_a6e4_d976b89450ea -->|calls| cf241bdc_17de_d59f_740a_78af39289ce8
  8fc73c0a_1c83_08e3_9486_c99948586794["run()"]
  c4a3c3a8_c9a0_f1c5_a6e4_d976b89450ea -->|calls| 8fc73c0a_1c83_08e3_9486_c99948586794
  4cae79d3_92ee_29bb_03d0_6a120cc97031["processReceived()"]
  c4a3c3a8_c9a0_f1c5_a6e4_d976b89450ea -->|calls| 4cae79d3_92ee_29bb_03d0_6a120cc97031
  a8038ede_896d_5400_e9da_e2e5c976508f["runAllTaskRecv()"]
  c4a3c3a8_c9a0_f1c5_a6e4_d976b89450ea -->|calls| a8038ede_896d_5400_e9da_e2e5c976508f
  8694896e_30ff_0192_2de2_f7fc29767efb["recv()"]
  c4a3c3a8_c9a0_f1c5_a6e4_d976b89450ea -->|calls| 8694896e_30ff_0192_2de2_f7fc29767efb
  style c4a3c3a8_c9a0_f1c5_a6e4_d976b89450ea fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicChannel.java lines 1596–1681

        void connectionRecv(InetSocketAddress sender, InetSocketAddress recipient, ByteBuf buffer) {
            QuicheQuicConnection conn = QuicheQuicChannel.this.connection;
            if (conn.isFreed()) {
                return;
            }
            int bufferReadable = buffer.readableBytes();
            if (bufferReadable == 0) {
                // Nothing to do here. Just return...
                // See also https://github.com/cloudflare/quiche/issues/817
                return;
            }

            reantranceGuard |= IN_RECV;
            boolean close = false;
            try {
                ByteBuf tmpBuffer = null;
                // We need to make a copy if the buffer is read only as recv(...) may modify the input buffer as well.
                // See https://docs.rs/quiche/0.6.0/quiche/struct.Connection.html#method.recv
                if (buffer.isReadOnly()) {
                    tmpBuffer = alloc().directBuffer(buffer.readableBytes());
                    tmpBuffer.writeBytes(buffer);
                    buffer = tmpBuffer;
                }
                long memoryAddress = Quiche.readerMemoryAddress(buffer);

                ByteBuffer recvInfo = conn.nextRecvInfo();
                QuicheRecvInfo.setRecvInfo(recvInfo, sender, recipient);

                remote = sender;
                local = recipient;

                try {
                    do  {
                        // Call quiche_conn_recv(...) until we consumed all bytes or we did receive some error.
                        int res = Quiche.quiche_conn_recv(conn.address(), memoryAddress, bufferReadable,
                                Quiche.memoryAddressWithPosition(recvInfo));
                        final boolean done;
                        if (res < 0) {
                            done = true;
                            if (res != Quiche.QUICHE_ERR_DONE) {
                                close = Quiche.shouldClose(res);
                                Exception e = Quiche.convertToException(res);
                                if (tryFailConnectPromise(e)) {
                                    break;
                                }
                                fireExceptionEvents(conn, e);
                            }
                        } else {
                            done = false;
                        }
                        // Process / schedule all tasks that were created.
                        Runnable task = conn.sslTask();
                        if (task != null) {
                            if (runTasksDirectly()) {
                                // Consume all tasks
                                do {
                                    task.run();
                                } while ((task = conn.sslTask()) != null);
                                processReceived(conn);
                            } else {
                                runAllTaskRecv(conn, task);
                            }
                        } else {
                            processReceived(conn);
                        }

                        if (done) {
                            break;
                        }
                        memoryAddress += res;
                        bufferReadable -= res;
                    } while (bufferReadable > 0 && !conn.isFreed());
                } finally {
                    buffer.skipBytes((int) (memoryAddress - Quiche.readerMemoryAddress(buffer)));
                    if (tmpBuffer != null) {
                        tmpBuffer.release();
                    }
                }
                if (close) {
                    // Let's close now as there is no way to recover
                    unsafe().close(newPromise());

Domain

Subdomains

Called By

Frequently Asked Questions

What does connectionRecv() do?
connectionRecv() is a function in the netty codebase, defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicChannel.java.
Where is connectionRecv() defined?
connectionRecv() is defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicChannel.java at line 1596.
What does connectionRecv() call?
connectionRecv() calls 7 function(s): fireExceptionEvents, processReceived, recv, run, runAllTaskRecv, runTasksDirectly, tryFailConnectPromise.
What calls connectionRecv()?
connectionRecv() is called by 1 function(s): recv.

Analyze Your Own Codebase

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

Try Supermodel Free