Commit 1812b425 authored by Marton Balint's avatar Marton Balint

avutil/thread: fix strict_pthread_cond_timedwait

Timeout error was assumed to be fatal which it is not.
Signed-off-by: 's avatarMarton Balint <cus@passwd.hu>
parent 4b4bcb12
...@@ -33,16 +33,19 @@ ...@@ -33,16 +33,19 @@
#include "log.h" #include "log.h"
#define ASSERT_PTHREAD_NORET(func, ...) do { \ #define ASSERT_PTHREAD_ABORT(func, ret) do { \
int ret = func(__VA_ARGS__); \
if (ret) { \
char errbuf[AV_ERROR_MAX_STRING_SIZE] = ""; \ char errbuf[AV_ERROR_MAX_STRING_SIZE] = ""; \
av_log(NULL, AV_LOG_FATAL, AV_STRINGIFY(func) \ av_log(NULL, AV_LOG_FATAL, AV_STRINGIFY(func) \
" failed with error: %s\n", \ " failed with error: %s\n", \
av_make_error_string(errbuf, AV_ERROR_MAX_STRING_SIZE, \ av_make_error_string(errbuf, AV_ERROR_MAX_STRING_SIZE, \
AVERROR(ret))); \ AVERROR(ret))); \
abort(); \ abort(); \
} \ } while (0)
#define ASSERT_PTHREAD_NORET(func, ...) do { \
int ret = func(__VA_ARGS__); \
if (ret) \
ASSERT_PTHREAD_ABORT(func, ret); \
} while (0) } while (0)
#define ASSERT_PTHREAD(func, ...) do { \ #define ASSERT_PTHREAD(func, ...) do { \
...@@ -112,7 +115,10 @@ static inline int strict_pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t ...@@ -112,7 +115,10 @@ static inline int strict_pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t
static inline int strict_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, static inline int strict_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
const struct timespec *abstime) const struct timespec *abstime)
{ {
ASSERT_PTHREAD(pthread_cond_timedwait, cond, mutex, abstime); int ret = pthread_cond_timedwait(cond, mutex, abstime);
if (ret && ret != ETIMEDOUT)
ASSERT_PTHREAD_ABORT(pthread_cond_timedwait, ret);
return ret;
} }
static inline int strict_pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) static inline int strict_pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment