From 54fab912e0160431a59e158ff1ac208f0c9c2565 Mon Sep 17 00:00:00 2001 From: Mikolaj Malecki Date: Wed, 26 Jun 2024 15:15:23 +0200 Subject: [PATCH] [core] Fixed broadcast group: cut failed links on partial sending success --- srtcore/group.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/srtcore/group.cpp b/srtcore/group.cpp index 3e57ef5df..d2d275bf6 100644 --- a/srtcore/group.cpp +++ b/srtcore/group.cpp @@ -1501,7 +1501,10 @@ int CUDTGroup::sendBroadcast(const char* buf, int len, SRT_MSGCTRL& w_mc) int ercode = 0; - if (was_blocked) + // This block causes waiting for any socket to accept the payload. + // This should be done only in blocking mode and only if no other socket + // accepted the payload. + if (was_blocked && none_succeeded && m_bSynSending) { m_Global.m_EPoll.update_events(id(), m_sPollID, SRT_EPOLL_OUT, false); if (!m_bSynSending) @@ -1648,6 +1651,19 @@ int CUDTGroup::sendBroadcast(const char* buf, int len, SRT_MSGCTRL& w_mc) throw CUDTException(major, minor, 0); } + for (vector::iterator is = sendstates.begin(); is != sendstates.end(); ++is) + { + // Here we have a situation that at least 1 link successfully sent a packet. + // All links for which sending has failed must be closed. + if (is->stat == -1) + { + // This only sets the state to the socket; the GC process should + // pick it up at the next time. + HLOGC(gslog.Debug, log << "grp/sendBroadcast: per PARTIAL SUCCESS, closing failed @" << is->id); + is->mb->ps->setBrokenClosed(); + } + } + // Now that at least one link has succeeded, update sending stats. m_stats.sent.count(len);