From 7cfe12b7e026e396c97c46b83a09c409d0378b93 Mon Sep 17 00:00:00 2001 From: Guangqing Chen Date: Wed, 17 May 2023 19:18:59 +0800 Subject: [PATCH] [core] fix tsbpd() may deadlock with processCtrlShutdown() --- srtcore/core.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/srtcore/core.cpp b/srtcore/core.cpp index bcc105001..2d3189bc9 100644 --- a/srtcore/core.cpp +++ b/srtcore/core.cpp @@ -5456,6 +5456,10 @@ void * srt::CUDT::tsbpd(void* param) tsNextDelivery = steady_clock::time_point(); // Ready to read, nothing to wait for. } + // We may just briefly unlocked the m_RecvLock, so we need to check m_bClosing again to avoid deadlock. + if (self->m_bClosing) + break; + if (!is_zero(tsNextDelivery)) { IF_HEAVY_LOGGING(const steady_clock::duration timediff = tsNextDelivery - tnow);