Skip to content

Display and control your Android device

Assert non-recursive usage of mutexes

Romain Vimontc53bd4d8b68d
diff --git a/app/src/util/thread.c b/app/src/util/thread.c
index fa774cfe..a0a99f20 100644
--- a/app/src/util/thread.c
+++ b/app/src/util/thread.c
@@ -43,6 +43,8 @@ sc_mutex_destroy(sc_mutex *mutex) {
void
sc_mutex_lock(sc_mutex *mutex) {
+ // SDL mutexes are recursive, but we don't want to use recursive mutexes
+ assert(!sc_mutex_held(mutex));
int r = SDL_LockMutex(mutex->mutex);
#ifndef NDEBUG
if (r) {
@@ -59,6 +61,7 @@ sc_mutex_lock(sc_mutex *mutex) {
void
sc_mutex_unlock(sc_mutex *mutex) {
#ifndef NDEBUG
+ assert(sc_mutex_held(mutex));
mutex->locker = 0;
#endif
int r = SDL_UnlockMutex(mutex->mutex);