From 0a6e1adfbf4c905f92c98c4c9bb49ac3950a3aa7 Mon Sep 17 00:00:00 2001 From: J Reece Wilson Date: Wed, 13 Apr 2022 16:06:26 +0100 Subject: [PATCH] [*] Update UNIX mutex primitive --- Source/Threading/Primitives/Mutex.Unix.cpp | 24 ++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Source/Threading/Primitives/Mutex.Unix.cpp b/Source/Threading/Primitives/Mutex.Unix.cpp index 6d4b124b..c65d05ec 100644 --- a/Source/Threading/Primitives/Mutex.Unix.cpp +++ b/Source/Threading/Primitives/Mutex.Unix.cpp @@ -69,13 +69,25 @@ namespace Aurora::Threading::Primitives struct timespec tspec; Time::ms2tsabs(&tspec, timeout); - auto ret = pthread_mutex_timedlock(&value_, &tspec); - if (ret != 0) - { - SysAssert(ret == ETIMEDOUT, "mutex timed lock failed"); - return false; - } + int ret {}; + do + { + ret = pthread_mutex_timedlock(&value_, &tspec); + + if (ret == 0) + { + return true; + } + + if (ret == ETIMEDOUT) + { + return false; + } + + } while (ret == EINTR); + + SysPanic("mutex timed lock failed {}", ret); return true; } }