Skip to content

Commit 7db9993

Browse files
committed
MDEV-20183 data race at safe_mutex_lock()
fix is simple: just move mp->file under mp->global protection
1 parent 51d58f5 commit 7db9993

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mysys/thr_mutex.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ int safe_mutex_lock(safe_mutex_t *mp, myf my_flags, const char *file,
237237
int error;
238238
DBUG_PRINT("mutex", ("%s (0x%lx) locking", mp->name ? mp->name : "Null",
239239
(ulong) mp));
240+
241+
pthread_mutex_lock(&mp->global);
240242
if (!mp->file)
241243
{
242244
fprintf(stderr,
@@ -245,8 +247,6 @@ int safe_mutex_lock(safe_mutex_t *mp, myf my_flags, const char *file,
245247
fflush(stderr);
246248
abort();
247249
}
248-
249-
pthread_mutex_lock(&mp->global);
250250
if (mp->count > 0)
251251
{
252252
/*

0 commit comments

Comments
 (0)