]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Fix possible deadlock when using tvh_mutex_trylock()
authorAlex Deryskyba <alex@wetek.com>
Wed, 16 Dec 2020 11:49:19 +0000 (13:49 +0200)
committerFlole998 <Flole998@users.noreply.github.com>
Wed, 16 Dec 2020 12:40:08 +0000 (13:40 +0100)
Fixes possible deadlock when using tvh_mutex_trylock() macro in thread non-debug mode.
The macro expands to call pthread_mutex_lock() instead of pthread_mutex_trylock(),
which most likely is a result of copy/paste.

src/tvh_thread.h

index d3a01f18d08f2e8e8242af1c7429e7d6ced60fac..c7baa4812eae3b3a3c08c952cc9f7fc1141710e9 100644 (file)
@@ -123,7 +123,7 @@ int tvh__mutex_trylock(tvh_mutex_t *mutex, const char *filename, int lineno);
 #define tvh_mutex_trylock(_mutex)                              \
  ({                                                            \
     tvh_thread_debug == 0 ?                                    \
-      pthread_mutex_lock(&(_mutex)->mutex) :                   \
+      pthread_mutex_trylock(&(_mutex)->mutex) :                        \
       tvh__mutex_trylock((_mutex), __FILE__, __LINE__);                \
  })
 int tvh__mutex_unlock(tvh_mutex_t *mutex);