From bc2f48e057644ab9d057690b776a576304bb2c03 Mon Sep 17 00:00:00 2001 From: Mikolaj Malecki Date: Fri, 26 Jul 2024 16:11:23 +0200 Subject: [PATCH] [core] Put the use of m_bGCStatus under m_InitLock --- srtcore/api.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/srtcore/api.cpp b/srtcore/api.cpp index 665593c39..7eda3f2bf 100644 --- a/srtcore/api.cpp +++ b/srtcore/api.cpp @@ -236,6 +236,8 @@ string srt::CUDTUnited::CONID(SRTSOCKET sock) int srt::CUDTUnited::startup() { ScopedLock gcinit(m_InitLock); + if (m_bGCStatus) + return 1; if (m_iInstanceCount++ > 0) return 1; @@ -254,9 +256,6 @@ int srt::CUDTUnited::startup() PacketFilter::globalInit(); - if (m_bGCStatus) - return 1; - m_bClosing = false; if (!StartThread(m_GCThread, garbageCollect, this, "SRT:GC")) @@ -3390,8 +3389,7 @@ int srt::CUDT::cleanup() SRTSOCKET srt::CUDT::socket() { - if (!uglobal().m_bGCStatus) - uglobal().startup(); + uglobal().startup(); try { @@ -3441,8 +3439,7 @@ srt::CUDTGroup& srt::CUDT::newGroup(const int type) SRTSOCKET srt::CUDT::createGroup(SRT_GROUP_TYPE gt) { // Doing the same lazy-startup as with srt_create_socket() - if (!uglobal().m_bGCStatus) - uglobal().startup(); + uglobal().startup(); try {