Home / Function/ SendResult() — netty Function Reference

SendResult() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  9f9da465_f345_60be_84db_446a37063039["SendResult()"]
  3c534d05_bb5b_c991_5e03_7ec94e739cf7["QuicheQuicChannel"]
  9f9da465_f345_60be_84db_446a37063039 -->|defined in| 3c534d05_bb5b_c991_5e03_7ec94e739cf7
  aec1828e_f262_7e70_41b5_18066d8d1231["calculateSendBufferLength()"]
  9f9da465_f345_60be_84db_446a37063039 -->|calls| aec1828e_f262_7e70_41b5_18066d8d1231
  ae06f64f_455f_edc7_057f_27f8e23a5b93["tryFailConnectPromise()"]
  9f9da465_f345_60be_84db_446a37063039 -->|calls| ae06f64f_455f_edc7_057f_27f8e23a5b93
  df3e43f0_4607_0b84_f830_a8655804f40e["fireExceptionEvents()"]
  9f9da465_f345_60be_84db_446a37063039 -->|calls| df3e43f0_4607_0b84_f830_a8655804f40e
  dc50aa84_201f_62ae_ce2f_e75dc5aa4031["segmentSize()"]
  9f9da465_f345_60be_84db_446a37063039 -->|calls| dc50aa84_201f_62ae_ce2f_e75dc5aa4031
  e06d6e01_48a2_5234_b718_4be9767715c7["writePacket()"]
  9f9da465_f345_60be_84db_446a37063039 -->|calls| e06d6e01_48a2_5234_b718_4be9767715c7
  43aec3ee_7b99_81ef_ef3d_ebff925f4d69["notifyEarlyDataReadyIfNeeded()"]
  9f9da465_f345_60be_84db_446a37063039 -->|calls| 43aec3ee_7b99_81ef_ef3d_ebff925f4d69
  cf241bdc_17de_d59f_740a_78af39289ce8["runTasksDirectly()"]
  9f9da465_f345_60be_84db_446a37063039 -->|calls| cf241bdc_17de_d59f_740a_78af39289ce8
  8fc73c0a_1c83_08e3_9486_c99948586794["run()"]
  9f9da465_f345_60be_84db_446a37063039 -->|calls| 8fc73c0a_1c83_08e3_9486_c99948586794
  d21171a6_3135_05f4_7ac2_3fd3258ddab8["forceFlushParent()"]
  9f9da465_f345_60be_84db_446a37063039 -->|calls| d21171a6_3135_05f4_7ac2_3fd3258ddab8
  02598212_7f8b_2f50_b095_37e1e52dcf04["freeIfClosed()"]
  9f9da465_f345_60be_84db_446a37063039 -->|calls| 02598212_7f8b_2f50_b095_37e1e52dcf04
  782e4700_08d8_8761_73ee_4fa0b1ca2c2d["runAllTaskSend()"]
  9f9da465_f345_60be_84db_446a37063039 -->|calls| 782e4700_08d8_8761_73ee_4fa0b1ca2c2d
  c997df20_22da_3c7d_91cc_a980c6a6738b["scheduleTimeout()"]
  9f9da465_f345_60be_84db_446a37063039 -->|calls| c997df20_22da_3c7d_91cc_a980c6a6738b
  829c18c0_c95f_9ba1_3974_3dc4e619356a["Runnable()"]
  9f9da465_f345_60be_84db_446a37063039 -->|calls| 829c18c0_c95f_9ba1_3974_3dc4e619356a
  style 9f9da465_f345_60be_84db_446a37063039 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicChannel.java lines 1199–1332

    private SendResult connectionSendSegments(QuicheQuicConnection conn,
                                              SegmentedDatagramPacketAllocator segmentedDatagramPacketAllocator) {
        if (conn.isClosed()) {
            return SendResult.NONE;
        }
        List<ByteBuf> bufferList = new ArrayList<>(segmentedDatagramPacketAllocator.maxNumSegments());
        long connAddr = conn.address();
        int maxDatagramSize = Quiche.quiche_conn_max_send_udp_payload_size(connAddr);
        SendResult sendResult = SendResult.NONE;
        boolean close = false;
        try {
            for (;;) {
                int len = calculateSendBufferLength(connAddr, maxDatagramSize);
                ByteBuf out = alloc().directBuffer(len);

                ByteBuffer sendInfo = conn.nextSendInfo();
                InetSocketAddress sendToAddress = this.remote;

                int writerIndex = out.writerIndex();
                int written = Quiche.quiche_conn_send(
                        connAddr, Quiche.writerMemoryAddress(out), out.writableBytes(),
                        Quiche.memoryAddressWithPosition(sendInfo));
                if (written == 0) {
                    out.release();
                    // No need to create a new datagram packet. Just try again.
                    continue;
                }
                final boolean done;
                if (written < 0) {
                    done = true;
                    if (written != Quiche.QUICHE_ERR_DONE) {
                        close = Quiche.shouldClose(written);
                        Exception e = Quiche.convertToException(written);
                        if (!tryFailConnectPromise(e)) {
                            // Only fire through the pipeline if this does not fail the connect promise.
                            fireExceptionEvents(conn, e);
                        }
                    }
                } else {
                    done = false;
                }
                int size = bufferList.size();
                if (done) {
                    // We are done, release the buffer and send what we did build up so far.
                    out.release();

                    switch (size) {
                        case 0:
                            // Nothing more to write.
                            break;
                        case 1:
                            // We can write a normal datagram packet.
                            parent().write(new DatagramPacket(bufferList.get(0), sendToAddress));
                            sendResult = SendResult.SOME;
                            break;
                        default:
                            int segmentSize = segmentSize(bufferList);
                            ByteBuf compositeBuffer = Unpooled.wrappedBuffer(bufferList.toArray(new ByteBuf[0]));
                            // We had more than one buffer, create a segmented packet.
                            parent().write(segmentedDatagramPacketAllocator.newPacket(
                                    compositeBuffer, segmentSize, sendToAddress));
                            sendResult = SendResult.SOME;
                            break;
                    }
                    bufferList.clear();
                    if (close) {
                        sendResult = SendResult.CLOSE;
                    }
                    return sendResult;
                }
                out.writerIndex(writerIndex + written);

                int segmentSize = -1;
                if (conn.isSendInfoChanged()) {
                    // Change the cached address and let the user know there was a connection migration.
                    remote = QuicheSendInfo.getToAddress(sendInfo);
                    local = QuicheSendInfo.getFromAddress(sendInfo);

                    if (size > 0) {
                        // We have something in the out list already, we need to send this now and so we set the
                        // segmentSize.

Domain

Subdomains

Frequently Asked Questions

What does SendResult() do?
SendResult() is a function in the netty codebase, defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicChannel.java.
Where is SendResult() defined?
SendResult() is defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicChannel.java at line 1199.
What does SendResult() call?
SendResult() calls 13 function(s): Runnable, calculateSendBufferLength, fireExceptionEvents, forceFlushParent, freeIfClosed, notifyEarlyDataReadyIfNeeded, run, runAllTaskSend, and 5 more.

Analyze Your Own Codebase

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

Try Supermodel Free