Skip to content

Commit

Permalink
[core] Put the use of m_bGCStatus under m_InitLock
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikolaj Malecki authored and maxsharabayko committed Jul 29, 2024
1 parent 84d18ec commit bc2f48e
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions srtcore/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"))
Expand Down Expand Up @@ -3390,8 +3389,7 @@ int srt::CUDT::cleanup()

SRTSOCKET srt::CUDT::socket()
{
if (!uglobal().m_bGCStatus)
uglobal().startup();
uglobal().startup();

try
{
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit bc2f48e

Please sign in to comment.