aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcdr.c2
-rwxr-xr-xdevicestate.c2
-rwxr-xr-xinclude/asterisk/lock.h18
3 files changed, 19 insertions, 3 deletions
diff --git a/cdr.c b/cdr.c
index 64e2aaeaa..ee20c6cc6 100755
--- a/cdr.c
+++ b/cdr.c
@@ -1021,7 +1021,7 @@ static void *do_cdr(void *data)
timeout.tv_nsec = (now.tv_usec * 1000) + ((schedms % 1000) * 1000);
/* prevent stuff from clobbering cdr_pending_cond, then wait on signals sent to it until the timeout expires */
ast_mutex_lock(&cdr_pending_lock);
- pthread_cond_timedwait(&cdr_pending_cond, &cdr_pending_lock, &timeout);
+ ast_pthread_cond_timedwait(&cdr_pending_cond, &cdr_pending_lock, &timeout);
numevents = ast_sched_runq(sched);
ast_mutex_unlock(&cdr_pending_lock);
if (option_debug > 1)
diff --git a/devicestate.c b/devicestate.c
index f79cd1190..c3e7c52d0 100755
--- a/devicestate.c
+++ b/devicestate.c
@@ -228,7 +228,7 @@ static void *do_devstate_changes(void *data)
} else {
/* there was no entry, so atomically unlock the list and wait for
the condition to be signalled (returns with the lock held) */
- pthread_cond_wait(&change_pending, &state_changes.lock);
+ ast_pthread_cond_wait(&change_pending, &state_changes.lock);
}
}
diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h
index 6a0126ea4..ce9a84350 100755
--- a/include/asterisk/lock.h
+++ b/include/asterisk/lock.h
@@ -293,6 +293,17 @@ static inline int __ast_pthread_mutex_unlock(const char *filename, int lineno, c
return res;
}
+static inline int ast_pthread_cond_wait(pthread_cond_t *cond, ast_mutex_t *ast_mutex)
+{
+ return pthread_cond_wait(cond, &ast_mutex->mutex);
+}
+
+static inline int ast_pthread_cond_timedwait(pthread_cond_t *cond, ast_mutex_t *ast_mutex,
+ const struct timespec *abstime)
+{
+ return pthread_cond_timedwait(cond, &ast_mutex->mutex, abstime);
+}
+
#define ast_mutex_unlock(a) __ast_pthread_mutex_unlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a)
#define pthread_mutex_t use_ast_mutex_t_instead_of_pthread_mutex_t
@@ -301,6 +312,8 @@ static inline int __ast_pthread_mutex_unlock(const char *filename, int lineno, c
#define pthread_mutex_trylock use_ast_mutex_trylock_instead_of_pthread_mutex_trylock
#define pthread_mutex_init use_ast_pthread_mutex_init_instead_of_pthread_mutex_init
#define pthread_mutex_destroy use_ast_pthread_mutex_destroy_instead_of_pthread_mutex_destroy
+#define pthread_cond_wait use_ast_pthread_cond_wait_instead_of_pthread_cond_wait
+#define pthread_cond_timedwait use_ast_pthread_cond_wait_instead_of_pthread_cond_timedwait
#else /* !DEBUG_THREADS */
@@ -366,7 +379,10 @@ static inline int ast_mutex_trylock(ast_mutex_t *pmutex)
#define ast_mutex_trylock(pmutex) pthread_mutex_trylock(pmutex)
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
-#endif /* DEBUG_THREADS */
+#define ast_pthread_cond_wait pthread_cond_wait
+#define ast_pthread_cond_timedwait pthread_cond_timedwait
+
+#endif /* !DEBUG_THREADS */
#define AST_MUTEX_DEFINE_STATIC(mutex) __AST_MUTEX_DEFINE(static,mutex)
#define AST_MUTEX_DEFINE_EXPORTED(mutex) __AST_MUTEX_DEFINE(/**/,mutex)