Skip to content

[MAINT] Rework queuing functionality around multiplexer and snd/rcv queues #3164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

ethouris
Copy link
Collaborator

@ethouris ethouris commented Apr 10, 2025

The aim of this changeset is to rework the queuing of sent and received packets to allow more flexible send scheduling.

  • 1. Remove the blocking mode connect procedure. That is, all that is done beyond the point where the non-blocking mode connection should be done, is removed, and replaced with the waiting on a m_SendBlockCond CV. This CV has been used because it's not used at the time when the connection is not yet established and it corresponds with the rule that the epoll OUT event is used as a signal for connection readiness.
  • 2. Remove the use of specific queues keeping CUDT pointers and replace with the list of all sockets pinned into the multiplexer, together with its state that should represent the previous case of existence in these queues.
  • 3. Introduce delivery time in the packets stored in the sender buffer. The sender queue should pick up packets and get waiting time basing on the nearest packet ready to be scheduled.
  • 4. Add a special socket option that will require using the declared time in the srt_sendmsg2 call as the sending time.

Further changes embrace: update the tests and testing apps by fixing some problems connected to too early socket closing.

@ethouris ethouris changed the base branch from master to dev April 10, 2025 15:03
@ethouris ethouris changed the title [MAINT] Rework work queuing around multiplexer and snd/rcv queues [MAINT] Rework queuing functionality around multiplexer and snd/rcv queues Apr 11, 2025
Comment on lines 1635 to 1689
/*

int srt::CRcvQueue::recvfrom(SRTSOCKET id, CPacket& w_packet)
{
CUniqueSync buffercond(m_BufferLock, m_BufferCond);

qmap_t::iterator i = m_mBuffer.find(id);

if (i == m_mBuffer.end())
{
THREAD_PAUSED();
buffercond.wait_for(seconds_from(1));
THREAD_RESUMED();

i = m_mBuffer.find(id);
if (i == m_mBuffer.end())
{
w_packet.setLength(-1);
return -1;
}
}

// retrieve the earliest packet
CPacket* newpkt = i->second.front();

if (w_packet.getLength() < newpkt->getLength())
{
w_packet.setLength(-1);
return -1;
}

// copy packet content
// XXX Check if this wouldn't be better done by providing
// copy constructor for DynamicStruct.
// XXX Another thing: this looks wasteful. This expects an already
// allocated memory on the packet, this thing gets the packet,
// copies it into the passed packet and then the source packet
// gets deleted. Why not simply return the originally stored packet,
// without copying, allocation and deallocation?
memcpy((w_packet.m_nHeader), newpkt->m_nHeader, CPacket::HDR_SIZE);
memcpy((w_packet.m_pcData), newpkt->m_pcData, newpkt->getLength());
w_packet.setLength(newpkt->getLength());
w_packet.m_DestAddr = newpkt->m_DestAddr;

delete newpkt;

// remove this message from queue,
// if no more messages left for this socket, release its data structure
i->second.pop();
if (i->second.empty())
m_mBuffer.erase(i);

return (int)w_packet.getLength();
}
*/

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant