Skip to content

Commit

Permalink
[core] Handle spurious wake up in shared mutex locking functions
Browse files Browse the repository at this point in the history
  • Loading branch information
yomnes0 committed Jul 30, 2024
1 parent deeb9c9 commit 58d575f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions srtcore/sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,12 @@ srt::sync::SharedMutex::~SharedMutex()
void srt::sync::SharedMutex::lock()
{
UniqueLock l1(m_Mutex);
if (m_bWriterLocked)
while (m_bWriterLocked)
m_LockWriteCond.wait(l1);

m_bWriterLocked = true;

if (m_iCountRead)
while (m_iCountRead)
m_LockReadCond.wait(l1);
}

Expand All @@ -418,7 +418,7 @@ void srt::sync::SharedMutex::unlock()
void srt::sync::SharedMutex::lock_shared()
{
UniqueLock lk(m_Mutex);
if (m_bWriterLocked)
while (m_bWriterLocked)
m_LockWriteCond.wait(lk);

m_iCountRead++;
Expand Down

0 comments on commit 58d575f

Please sign in to comment.