diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-08-14 13:26:40 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-08-14 13:26:40 +1000 |
commit | 10c4cff2edfbfbb8ca2c142bd4b3c7780904ab0c (patch) | |
tree | b6d79a2aed0bbd045bd4c9875c8198575187c1c9 /source/core/StarThread_unix.cpp | |
parent | cadd5b32ff17bd4fd996099e810b65dd1fd8be0e (diff) |
Update StarThread_unix.cpp
Diffstat (limited to 'source/core/StarThread_unix.cpp')
-rw-r--r-- | source/core/StarThread_unix.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/source/core/StarThread_unix.cpp b/source/core/StarThread_unix.cpp index 7fbf279..6d1b173 100644 --- a/source/core/StarThread_unix.cpp +++ b/source/core/StarThread_unix.cpp @@ -131,7 +131,13 @@ struct MutexImpl { } void lock() { - pthread_mutex_lock(&mutex); + timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += 60; + if (pthread_mutex_timedlock(&mutex, &ts) != 0) { + Logger::warn("Mutex lock is taking too long. Stack:\n{}", outputStack(captureStack()); + pthread_mutex_lock(&mutex); + } } void unlock() { @@ -199,7 +205,13 @@ struct RecursiveMutexImpl { } void lock() { - pthread_mutex_lock(&mutex); + timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += 60; + if (pthread_mutex_timedlock(&mutex, &ts) != 0) { + Logger::warn("RecursiveMutex lock is taking too long. Stack:\n{}", outputStack(captureStack()); + pthread_mutex_lock(&mutex); + } } void unlock() { |