Skip to content

Commit

Permalink
Fixed bug: send when pending in backup groups reports correct error
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikolaj Malecki committed Dec 5, 2024
1 parent 1e26e79 commit 4a85e10
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions srtcore/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ int CUDTGroup::sendBroadcast(const char* buf, int len, SRT_MSGCTRL& w_mc)

if (!pendingSockets.empty() || nblocked)
{
HLOGC(gslog.Debug, log << "grp/sendBroadcast: found pending sockets, polling them.");
HLOGC(gslog.Debug, log << "grp/sendBroadcast: found pending sockets (blocked: " << nblocked << "), polling them.");

// These sockets if they are in pending state, they should be added to m_SndEID
// at the connecting stage.
Expand Down Expand Up @@ -3449,11 +3449,13 @@ void CUDTGroup::sendBackup_RetryWaitBlocked(SendBackupCtx& w_sendBackupCtx
// Note: A link is added in unstableLinks if sending has failed with SRT_ESYNCSND.
const unsigned num_unstable = w_sendBackupCtx.countMembersByState(BKUPST_ACTIVE_UNSTABLE);
const unsigned num_wary = w_sendBackupCtx.countMembersByState(BKUPST_ACTIVE_UNSTABLE_WARY);
if ((num_unstable + num_wary == 0) || !w_none_succeeded)
const unsigned num_pending = w_sendBackupCtx.countMembersByState(BKUPST_PENDING);
if ((num_unstable + num_wary + num_pending == 0) || !w_none_succeeded)
return;

HLOGC(gslog.Debug, log << "grp/sendBackup: no successfull sending: "
<< (num_unstable + num_wary) << " unstable links - waiting to retry sending...");
<< (num_unstable + num_wary) << " unstable links, "
<< num_pending << " pending - waiting to retry sending...");

// Note: GroupLock is set already, skip locks and checks
getGroupData_LOCKED((w_mc.grpdata), (&w_mc.grpdata_size));
Expand Down
4 changes: 4 additions & 0 deletions test/test_bonding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,8 @@ TEST(Bonding, ConnectNonBlocking)
auto acthr = std::thread([&lsn_eid]() {
SRT_EPOLL_EVENT ev[3];

ThreadName::set("TEST_A");

cout << "[A] Waiting for accept\n";

// This can wait in infinity; worst case it will be killed in process.
Expand Down Expand Up @@ -814,7 +816,9 @@ TEST(Bonding, ConnectNonBlocking)
int result = srt_connect_group(ss, cc, 2);
ASSERT_EQ(result, 0);
char data[4] = { 1, 2, 3, 4};
cout << "Sending...\n";
int wrong_send = srt_send(ss, data, sizeof data);
cout << "Getting error...\n";
int errorcode = srt_getlasterror(NULL);
EXPECT_EQ(wrong_send, -1);
EXPECT_EQ(errorcode, SRT_EASYNCSND) << "REAL ERROR: " << srt_getlasterror_str();
Expand Down

0 comments on commit 4a85e10

Please sign in to comment.