Skip to content
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

Refax/postfix: further fixes after last refax changes #2528

Merged
merged 2 commits into from Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 7 additions & 9 deletions srtcore/core.cpp
Expand Up @@ -9669,7 +9669,7 @@ bool srt::CUDT::overrideSndSeqNo(int32_t seq)
return true;
}

int srt::CUDT::checkLazySpawnLatencyThread()
int srt::CUDT::checkLazySpawnTsbPdThread()
{
const bool need_tsbpd = m_bTsbPd || m_bGroupTsbPd;

Expand Down Expand Up @@ -9709,6 +9709,8 @@ int srt::CUDT::handleSocketPacketReception(const vector<CUnit*>& incoming, bool&
{
bool excessive SRT_ATR_UNUSED = true; // stays true unless it was successfully added

w_new_inserted = false;

// Loop over all incoming packets that were filtered out.
// In case when there is no filter, there's just one packet in 'incoming',
// the one that came in the input of this function.
Expand All @@ -9719,7 +9721,6 @@ int srt::CUDT::handleSocketPacketReception(const vector<CUnit*>& incoming, bool&
const int pktrexmitflag = m_bPeerRexmitFlag ? (rpkt.getRexmitFlag() ? 1 : 0) : 2;
const bool retransmitted = pktrexmitflag == 1;

int buffer_add_result;
bool adding_successful = true;

// m_iRcvLastSkipAck is the base sequence number for the receiver buffer.
Expand Down Expand Up @@ -9750,9 +9751,6 @@ int srt::CUDT::handleSocketPacketReception(const vector<CUnit*>& incoming, bool&
continue;
}

// This is executed only when bonding is enabled and only
// with the new buffer (in which case the buffer is in the group).

const int avail_bufsize = (int) getAvailRcvBufferSizeNoLock();

if (offset >= avail_bufsize)
Expand Down Expand Up @@ -9791,10 +9789,11 @@ int srt::CUDT::handleSocketPacketReception(const vector<CUnit*>& incoming, bool&
}
}

buffer_add_result = m_pRcvBuffer->insert(u);
int buffer_add_result = m_pRcvBuffer->insert(u);
if (buffer_add_result < 0)
{
// addData returns -1 if at the m_iLastAckPos+offset position there already is a packet.
// The insert() result is -1 if at the position evaluated from this packet's
// sequence number there already is a packet.
// So this packet is "redundant".
IF_HEAVY_LOGGING(exc_type = "UNACKED");
adding_successful = false;
Expand Down Expand Up @@ -9924,7 +9923,7 @@ int srt::CUDT::processData(CUnit* in_unit)


// We are receiving data, start tsbpd thread if TsbPd is enabled
if (-1 == checkLazySpawnLatencyThread())
if (-1 == checkLazySpawnTsbPdThread())
{
return -1;
}
Expand Down Expand Up @@ -10082,7 +10081,6 @@ int srt::CUDT::processData(CUnit* in_unit)
#endif

// NULL time by default
maxsharabayko marked this conversation as resolved.
Show resolved Hide resolved
time_point next_tsbpd_avail;
bool new_inserted = false;

if (m_PacketFilter)
Expand Down
2 changes: 1 addition & 1 deletion srtcore/core.h
Expand Up @@ -1077,7 +1077,7 @@ class CUDT
time_point getPktTsbPdTime(void* grp, const CPacket& packet);

/// Checks and spawns the TSBPD thread if required.
int checkLazySpawnLatencyThread();
int checkLazySpawnTsbPdThread();
void processClose();

/// Process the request after receiving the handshake from caller.
Expand Down
22 changes: 18 additions & 4 deletions srtcore/packet.cpp
Expand Up @@ -263,7 +263,7 @@ void CPacket::setLength(size_t len, size_t cap)

#if ENABLE_HEAVY_LOGGING
// Debug only
static std::string FormatNumbers(UDTMessageType pkttype, const int32_t* lparam, void* rparam, size_t size)
static std::string FormatNumbers(UDTMessageType pkttype, const int32_t* lparam, void* rparam, const size_t size)
{
// This may be changed over time, so use special interpretation
// only for certain types, and still display all data, no matter
Expand All @@ -288,9 +288,15 @@ static std::string FormatNumbers(UDTMessageType pkttype, const int32_t* lparam,
}

bool interp_as_seq = (pkttype == UMSG_LOSSREPORT || pkttype == UMSG_DROPREQ);
bool display_dec = (pkttype == UMSG_ACK || pkttype == UMSG_ACKACK || pkttype == UMSG_DROPREQ);

out << " [ ";
for (size_t i = 0; i < size; ++i)

// Will be effective only for hex/oct.
out << std::showbase;

const size_t size32 = size/4;
for (size_t i = 0; i < size32; ++i)
{
int32_t val = ((int32_t*)rparam)[i];
if (interp_as_seq)
Expand All @@ -302,8 +308,16 @@ static std::string FormatNumbers(UDTMessageType pkttype, const int32_t* lparam,
}
else
{
out << std::showpos << std::hex << val << "/" << std::dec << val;
if (!display_dec)
{
out << std::hex;
out << val << "/";
out << std::dec;
}
out << val;

}
out << " ";
}

out << "]";
Expand All @@ -315,7 +329,7 @@ void CPacket::pack(UDTMessageType pkttype, const int32_t* lparam, void* rparam,
{
// Set (bit-0 = 1) and (bit-1~15 = type)
setControl(pkttype);
HLOGC(inlog.Debug, log << "pack: type=" << MessageTypeStr(pkttype) << FormatNumbers(pkttype, lparam, rparam, size));
HLOGC(inlog.Debug, log << "pack: type=" << MessageTypeStr(pkttype) << " " << FormatNumbers(pkttype, lparam, rparam, size));

// Set additional information and control information field
switch (pkttype)
Expand Down