|
|
@ -198,13 +198,15 @@ static inline int __ast_pthread_mutex_lock(char *filename, int lineno, char *fun
|
|
|
|
#endif /* definded(AST_MUTEX_INIT_W_CONSTRUCTORS) || defined(AST_MUTEX_INIT_ON_FIRST_USE) */
|
|
|
|
#endif /* definded(AST_MUTEX_INIT_W_CONSTRUCTORS) || defined(AST_MUTEX_INIT_ON_FIRST_USE) */
|
|
|
|
#ifdef DETECT_DEADLOCKS
|
|
|
|
#ifdef DETECT_DEADLOCKS
|
|
|
|
{
|
|
|
|
{
|
|
|
|
time_t seconds seconds = time(NULL);
|
|
|
|
time_t seconds = time(NULL);
|
|
|
|
|
|
|
|
time_t current;
|
|
|
|
do {
|
|
|
|
do {
|
|
|
|
res = pthread_mutex_trylock(&t->mutex);
|
|
|
|
res = pthread_mutex_trylock(&t->mutex);
|
|
|
|
if (res == EBUSY) {
|
|
|
|
if (res == EBUSY) {
|
|
|
|
if ((time(NULL) - seconds) % 5) {
|
|
|
|
current = time(NULL);
|
|
|
|
|
|
|
|
if ((current - seconds) && (!((current - seconds) % 5))) {
|
|
|
|
fprintf(stderr, "%s line %d (%s): Deadlock? waited %d sec for mutex '%s'?\n",
|
|
|
|
fprintf(stderr, "%s line %d (%s): Deadlock? waited %d sec for mutex '%s'?\n",
|
|
|
|
filename, lineno, func, (time(NULL) - seconds), mutex_name);
|
|
|
|
filename, lineno, func, (int)(current - seconds), mutex_name);
|
|
|
|
fprintf(stderr, "%s line %d (%s): '%s' was locked here.\n",
|
|
|
|
fprintf(stderr, "%s line %d (%s): '%s' was locked here.\n",
|
|
|
|
t->file, t->lineno, t->func, mutex_name);
|
|
|
|
t->file, t->lineno, t->func, mutex_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|