From edf9aa5917666815ba4c08cedf7a565627e2d6b3 Mon Sep 17 00:00:00 2001 From: yomnes0 Date: Wed, 31 Jul 2024 09:49:26 +0200 Subject: [PATCH] [core] Add a mutable qualifier to m_Mutex from SharedMutex Add a lock to getReaderCount --- srtcore/sync.cpp | 1 + srtcore/sync.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/srtcore/sync.cpp b/srtcore/sync.cpp index e5ecbf5aa..eff84feda 100644 --- a/srtcore/sync.cpp +++ b/srtcore/sync.cpp @@ -453,5 +453,6 @@ void srt::sync::SharedMutex::unlock_shared() int srt::sync::SharedMutex::getReaderCount() const { + ScopedLock lk(m_Mutex); return m_iCountRead; } \ No newline at end of file diff --git a/srtcore/sync.h b/srtcore/sync.h index 61dcece9a..c8ee88cce 100644 --- a/srtcore/sync.h +++ b/srtcore/sync.h @@ -956,7 +956,7 @@ class SharedMutex Condition m_LockWriteCond; Condition m_LockReadCond; - Mutex m_Mutex; + mutable Mutex m_Mutex; int m_iCountRead; bool m_bWriterLocked;