Skip to content

TransportImpl::sendNextFrameToMediaTxSocket schedules callback without checking for work #430

@thirtytwobits

Description

@thirtytwobits
            auto* const send_failure = cetl::get_if<ITxSocket::SendResult::Failure>(&send_result);
            if (nullptr == send_failure)
            {

here we've successfully sent a frame. The next clause handles what to do next...

                const auto sent = cetl::get<ITxSocket::SendResult::Success>(send_result);
                if (sent.is_accepted)
                {
                    popAndFreeUdpardTxItem(&media.udpard_tx(), tx_item, false /* single frame */);

In this condition the transfer was accepted and so removed from the tx queue.

                }

                // If needed schedule (recursively!) next frame for sending.
                // Already existing callback will be called by executor when TX socket is ready to send more.
                //
                if (!media.txSocketState().callback)
                {

If we get here we are supposing there's more to transmit but we haven't checked. We could be scheduling more work without any work to do.

If we haven't gotten here (if the callback was still set) what does this mean? We haven't rescheduled anything so is this callback going to fester in the schedule?

                    media.txSocketState().callback =
                        tx_socket.registerCallback([this, &media, &tx_socket](const auto&) {
                            //
                            sendNextFrameToMediaTxSocket(media, tx_socket);
                        });
                }
                return;
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions