From: Alex Deryskyba Date: Wed, 16 Dec 2020 11:49:19 +0000 (+0200) Subject: Fix possible deadlock when using tvh_mutex_trylock() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52b255940f9eb71904b9ac01c733cad090cd061a;p=thirdparty%2Ftvheadend.git Fix possible deadlock when using tvh_mutex_trylock() 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. --- diff --git a/src/tvh_thread.h b/src/tvh_thread.h index d3a01f18d..c7baa4812 100644 --- a/src/tvh_thread.h +++ b/src/tvh_thread.h @@ -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);