Skip to content

Commit ed166f5

Browse files
kevgssvoj
authored andcommitted
MDEV-18043 data race in os_event
os_event::is_set(): protect os_event::m_set with os_event::mutex
1 parent b7a9563 commit ed166f5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

storage/innobase/os/os0event.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ struct os_event {
126126
/** @return true if the event is in the signalled state. */
127127
bool is_set() const UNIV_NOTHROW
128128
{
129-
return(m_set);
129+
mutex.enter();
130+
bool is_set = m_set;
131+
mutex.exit();
132+
return is_set;
130133
}
131134

132135
private:
@@ -224,7 +227,7 @@ struct os_event {
224227
int64_t signal_count; /*!< this is incremented
225228
each time the event becomes
226229
signaled */
227-
EventMutex mutex; /*!< this mutex protects
230+
mutable EventMutex mutex; /*!< this mutex protects
228231
the next fields */
229232

230233

0 commit comments

Comments
 (0)