|
|
@ -540,7 +540,7 @@ struct thr_lock_info {
|
|
|
|
int times_locked;
|
|
|
|
int times_locked;
|
|
|
|
enum ast_lock_type type;
|
|
|
|
enum ast_lock_type type;
|
|
|
|
/*! This thread is waiting on this lock */
|
|
|
|
/*! This thread is waiting on this lock */
|
|
|
|
unsigned int pending:1;
|
|
|
|
int pending:2;
|
|
|
|
} locks[AST_MAX_LOCKS];
|
|
|
|
} locks[AST_MAX_LOCKS];
|
|
|
|
/*! This is the number of locks currently held by this thread.
|
|
|
|
/*! This is the number of locks currently held by this thread.
|
|
|
|
* The index (num_locks - 1) has the info on the last one in the
|
|
|
|
* The index (num_locks - 1) has the info on the last one in the
|
|
|
@ -636,6 +636,19 @@ void ast_mark_lock_acquired(void)
|
|
|
|
pthread_mutex_unlock(&lock_info->lock);
|
|
|
|
pthread_mutex_unlock(&lock_info->lock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ast_mark_lock_failed(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
struct thr_lock_info *lock_info;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!(lock_info = ast_threadstorage_get(&thread_lock_info, sizeof(*lock_info))))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pthread_mutex_lock(&lock_info->lock);
|
|
|
|
|
|
|
|
lock_info->locks[lock_info->num_locks - 1].pending = -1;
|
|
|
|
|
|
|
|
lock_info->locks[lock_info->num_locks - 1].times_locked--;
|
|
|
|
|
|
|
|
pthread_mutex_unlock(&lock_info->lock);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ast_remove_lock_info(void *lock_addr)
|
|
|
|
void ast_remove_lock_info(void *lock_addr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct thr_lock_info *lock_info;
|
|
|
|
struct thr_lock_info *lock_info;
|
|
|
@ -708,7 +721,7 @@ static int handle_show_locks(int fd, int argc, char *argv[])
|
|
|
|
pthread_mutex_lock(&lock_info->lock);
|
|
|
|
pthread_mutex_lock(&lock_info->lock);
|
|
|
|
for (i = 0; i < lock_info->num_locks; i++) {
|
|
|
|
for (i = 0; i < lock_info->num_locks; i++) {
|
|
|
|
ast_cli(fd, "=== ---> %sLock #%d (%s): %s %d %s %s %p (%d)\n",
|
|
|
|
ast_cli(fd, "=== ---> %sLock #%d (%s): %s %d %s %s %p (%d)\n",
|
|
|
|
lock_info->locks[i].pending ? "Waiting for " : "", i,
|
|
|
|
lock_info->locks[i].pending > 0 ? "Waiting for " : lock_info->locks[i].pending < 0 ? "Tried and failed to get " : "", i,
|
|
|
|
lock_info->locks[i].file,
|
|
|
|
lock_info->locks[i].file,
|
|
|
|
locktype2str(lock_info->locks[i].type),
|
|
|
|
locktype2str(lock_info->locks[i].type),
|
|
|
|
lock_info->locks[i].line_num,
|
|
|
|
lock_info->locks[i].line_num,
|
|
|
|