Single API for ast_store_lock_info and ast_remove_lock_info.

This makes the 'bt' parameter unconditional for ast_store_lock_info and
ast_remove_lock_info.  The 'bt' parameter is unused when HAVE_BKTR is
undefined.

Change-Id: Ieced0e920928b735a39c3b5952b806c473d67453
pull/9/head
Corey Farrell 8 years ago
parent 0b05dafc89
commit 569e9a8391

@ -240,13 +240,8 @@ enum ast_lock_type {
* lock info struct. The lock is marked as pending as the thread is waiting
* on the lock. ast_mark_lock_acquired() will mark it as held by this thread.
*/
#ifdef HAVE_BKTR
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr, struct ast_bt *bt);
#else
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr);
#endif /* HAVE_BKTR */
/*!
* \brief Mark the last lock as acquired
@ -264,11 +259,7 @@ void ast_mark_lock_failed(void *lock_addr);
* this gets called by ast_mutex_unlock so that information on the lock can
* be removed from the current thread's lock info struct.
*/
#ifdef HAVE_BKTR
void ast_remove_lock_info(void *lock_addr, struct ast_bt *bt);
#else
void ast_remove_lock_info(void *lock_addr);
#endif /* HAVE_BKTR */
void ast_suspend_lock_info(void *lock_addr);
void ast_restore_lock_info(void *lock_addr);

@ -245,9 +245,7 @@ int __ast_pthread_mutex_lock(const char *filename, int lineno, const char *func,
#ifdef DEBUG_THREADS
struct ast_lock_track *lt = NULL;
int canlog = t->tracking && strcmp(filename, "logger.c");
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
#endif
if (t->tracking) {
lt = ast_get_reentrancy(&t->track);
@ -268,11 +266,8 @@ int __ast_pthread_mutex_lock(const char *filename, int lineno, const char *func,
bt = &lt->backtrace[lt->reentrancy];
}
ast_reentrancy_unlock(lt);
ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t, bt);
#else
ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t);
#endif
ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t, bt);
}
#endif /* DEBUG_THREADS */
@ -346,10 +341,8 @@ int __ast_pthread_mutex_lock(const char *filename, int lineno, const char *func,
} else {
bt = NULL;
}
ast_remove_lock_info(t, bt);
#else
ast_remove_lock_info(t);
#endif
ast_remove_lock_info(t, bt);
}
if (res) {
__ast_mutex_logger("%s line %d (%s): Error obtaining mutex: %s\n",
@ -369,9 +362,7 @@ int __ast_pthread_mutex_trylock(const char *filename, int lineno, const char *fu
#ifdef DEBUG_THREADS
struct ast_lock_track *lt = NULL;
int canlog = t->tracking && strcmp(filename, "logger.c");
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
#endif
if (t->tracking) {
lt = ast_get_reentrancy(&t->track);
@ -392,11 +383,8 @@ int __ast_pthread_mutex_trylock(const char *filename, int lineno, const char *fu
bt = &lt->backtrace[lt->reentrancy];
}
ast_reentrancy_unlock(lt);
ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t, bt);
#else
ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t);
#endif
ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t, bt);
}
#endif /* DEBUG_THREADS */
@ -433,9 +421,7 @@ int __ast_pthread_mutex_unlock(const char *filename, int lineno, const char *fun
#ifdef DEBUG_THREADS
struct ast_lock_track *lt = NULL;
int canlog = t->tracking && strcmp(filename, "logger.c");
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
#endif
#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
@ -483,11 +469,7 @@ int __ast_pthread_mutex_unlock(const char *filename, int lineno, const char *fun
#endif
ast_reentrancy_unlock(lt);
#ifdef HAVE_BKTR
ast_remove_lock_info(t, bt);
#else
ast_remove_lock_info(t);
#endif
}
#endif /* DEBUG_THREADS */
@ -773,9 +755,7 @@ int __ast_rwlock_unlock(const char *filename, int line, const char *func, ast_rw
#ifdef DEBUG_THREADS
struct ast_lock_track *lt = NULL;
int canlog = t->tracking && strcmp(filename, "logger.c");
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
#endif
int lock_found = 0;
#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
@ -825,11 +805,7 @@ int __ast_rwlock_unlock(const char *filename, int line, const char *func, ast_rw
ast_reentrancy_unlock(lt);
#ifdef HAVE_BKTR
ast_remove_lock_info(t, bt);
#else
ast_remove_lock_info(t);
#endif
}
#endif /* DEBUG_THREADS */
@ -853,9 +829,7 @@ int __ast_rwlock_rdlock(const char *filename, int line, const char *func, ast_rw
#ifdef DEBUG_THREADS
struct ast_lock_track *lt = NULL;
int canlog = t->tracking && strcmp(filename, "logger.c");
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
#endif
if (t->tracking) {
lt = ast_get_reentrancy(&t->track);
@ -876,11 +850,8 @@ int __ast_rwlock_rdlock(const char *filename, int line, const char *func, ast_rw
bt = &lt->backtrace[lt->reentrancy];
}
ast_reentrancy_unlock(lt);
ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t, bt);
#else
ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t);
#endif
ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t, bt);
}
#endif /* DEBUG_THREADS */
@ -939,10 +910,8 @@ int __ast_rwlock_rdlock(const char *filename, int line, const char *func, ast_rw
} else {
bt = NULL;
}
ast_remove_lock_info(t, bt);
#else
ast_remove_lock_info(t);
#endif
ast_remove_lock_info(t, bt);
}
if (res) {
@ -962,9 +931,7 @@ int __ast_rwlock_wrlock(const char *filename, int line, const char *func, ast_rw
#ifdef DEBUG_THREADS
struct ast_lock_track *lt = NULL;
int canlog = t->tracking && strcmp(filename, "logger.c");
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
#endif
if (t->tracking) {
lt = ast_get_reentrancy(&t->track);
@ -985,11 +952,8 @@ int __ast_rwlock_wrlock(const char *filename, int line, const char *func, ast_rw
bt = &lt->backtrace[lt->reentrancy];
}
ast_reentrancy_unlock(lt);
ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt);
#else
ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t);
#endif
ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt);
}
#endif /* DEBUG_THREADS */
@ -1048,10 +1012,8 @@ int __ast_rwlock_wrlock(const char *filename, int line, const char *func, ast_rw
} else {
bt = NULL;
}
ast_remove_lock_info(t, bt);
#else
ast_remove_lock_info(t);
#endif
ast_remove_lock_info(t, bt);
}
if (res) {
__ast_mutex_logger("%s line %d (%s): Error obtaining write lock: %s\n",
@ -1071,9 +1033,7 @@ int __ast_rwlock_timedrdlock(const char *filename, int line, const char *func, a
#ifdef DEBUG_THREADS
struct ast_lock_track *lt = NULL;
int canlog = t->tracking && strcmp(filename, "logger.c");
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
#endif
if (t->tracking) {
lt = ast_get_reentrancy(&t->track);
@ -1094,11 +1054,8 @@ int __ast_rwlock_timedrdlock(const char *filename, int line, const char *func, a
bt = &lt->backtrace[lt->reentrancy];
}
ast_reentrancy_unlock(lt);
ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt);
#else
ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t);
#endif
ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt);
}
#endif /* DEBUG_THREADS */
@ -1141,10 +1098,8 @@ int __ast_rwlock_timedrdlock(const char *filename, int line, const char *func, a
} else {
bt = NULL;
}
ast_remove_lock_info(t, bt);
#else
ast_remove_lock_info(t);
#endif
ast_remove_lock_info(t, bt);
}
if (res) {
__ast_mutex_logger("%s line %d (%s): Error obtaining read lock: %s\n",
@ -1164,9 +1119,7 @@ int __ast_rwlock_timedwrlock(const char *filename, int line, const char *func, a
#ifdef DEBUG_THREADS
struct ast_lock_track *lt = NULL;
int canlog = t->tracking && strcmp(filename, "logger.c");
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
#endif
if (t->tracking) {
lt = ast_get_reentrancy(&t->track);
@ -1187,11 +1140,8 @@ int __ast_rwlock_timedwrlock(const char *filename, int line, const char *func, a
bt = &lt->backtrace[lt->reentrancy];
}
ast_reentrancy_unlock(lt);
ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt);
#else
ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t);
#endif
ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt);
}
#endif /* DEBUG_THREADS */
@ -1234,10 +1184,8 @@ int __ast_rwlock_timedwrlock(const char *filename, int line, const char *func, a
} else {
bt = NULL;
}
ast_remove_lock_info(t, bt);
#else
ast_remove_lock_info(t);
#endif
ast_remove_lock_info(t, bt);
}
if (res) {
__ast_mutex_logger("%s line %d (%s): Error obtaining read lock: %s\n",
@ -1255,9 +1203,7 @@ int __ast_rwlock_tryrdlock(const char *filename, int line, const char *func, ast
#ifdef DEBUG_THREADS
struct ast_lock_track *lt = NULL;
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
#endif
if (t->tracking) {
lt = ast_get_reentrancy(&t->track);
@ -1278,11 +1224,8 @@ int __ast_rwlock_tryrdlock(const char *filename, int line, const char *func, ast
bt = &lt->backtrace[lt->reentrancy];
}
ast_reentrancy_unlock(lt);
ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t, bt);
#else
ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t);
#endif
ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t, bt);
}
#endif /* DEBUG_THREADS */
@ -1314,9 +1257,7 @@ int __ast_rwlock_trywrlock(const char *filename, int line, const char *func, ast
#ifdef DEBUG_THREADS
struct ast_lock_track *lt = NULL;
#ifdef HAVE_BKTR
struct ast_bt *bt = NULL;
#endif
if (t->tracking) {
lt = ast_get_reentrancy(&t->track);
@ -1337,11 +1278,8 @@ int __ast_rwlock_trywrlock(const char *filename, int line, const char *func, ast
bt = &lt->backtrace[lt->reentrancy];
}
ast_reentrancy_unlock(lt);
ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt);
#else
ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t);
#endif
ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt);
}
#endif /* DEBUG_THREADS */

@ -722,13 +722,8 @@ static void lock_info_destroy(void *data)
AST_THREADSTORAGE_CUSTOM(thread_lock_info, NULL, lock_info_destroy);
#endif /* ! LOW_MEMORY */
#ifdef HAVE_BKTR
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr, struct ast_bt *bt)
#else
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr)
#endif
{
#if !defined(LOW_MEMORY)
struct thr_lock_info *lock_info;
@ -910,11 +905,7 @@ void ast_restore_lock_info(void *lock_addr)
}
#ifdef HAVE_BKTR
void ast_remove_lock_info(void *lock_addr, struct ast_bt *bt)
#else
void ast_remove_lock_info(void *lock_addr)
#endif
{
#if !defined(LOW_MEMORY)
struct thr_lock_info *lock_info;

@ -601,7 +601,6 @@ unsigned int ast_hashtab_hash_contexts(const void *obj)
void ast_mark_lock_acquired(void *lock_addr)
{
}
#ifdef HAVE_BKTR
void ast_remove_lock_info(void *lock_addr, struct ast_bt *bt)
{
}
@ -611,6 +610,7 @@ void ast_store_lock_info(enum ast_lock_type type, const char *filename,
{
}
#ifdef HAVE_BKTR
int __ast_bt_get_addresses(struct ast_bt *bt)
{
return 0;
@ -627,15 +627,6 @@ char **__ast_bt_get_symbols(void **addresses, size_t num_frames)
}
return foo;
}
#else
void ast_remove_lock_info(void *lock_addr)
{
}
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr)
{
}
#endif /* HAVE_BKTR */
void ast_suspend_lock_info(void *lock_addr)
{

@ -55,7 +55,6 @@ void * attribute_malloc __ast_calloc(size_t num, size_t len, const char *file, i
#endif
#ifdef DEBUG_THREADS
#ifdef HAVE_BKTR
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr, struct ast_bt *bt);
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
@ -70,6 +69,7 @@ void ast_remove_lock_info(void *lock_addr, struct ast_bt *bt)
/* not a lot to do in a standalone w/o threading! */
}
#ifdef HAVE_BKTR
int __ast_bt_get_addresses(struct ast_bt *bt);
int __ast_bt_get_addresses(struct ast_bt *bt)
{
@ -88,20 +88,6 @@ char **__ast_bt_get_symbols(void **addresses, size_t num_frames)
}
return foo;
}
#else
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr);
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr)
{
/* not a lot to do in a standalone w/o threading! */
}
void ast_remove_lock_info(void *lock_addr);
void ast_remove_lock_info(void *lock_addr)
{
/* not a lot to do in a standalone w/o threading! */
}
#endif /* HAVE_BKTR */
void ast_suspend_lock_info(void *lock_addr)

@ -699,7 +699,6 @@ unsigned int ast_hashtab_hash_contexts(const void *obj)
void ast_mark_lock_acquired(void *lock_addr)
{
}
#ifdef HAVE_BKTR
void ast_remove_lock_info(void *lock_addr, struct ast_bt *bt)
{
}
@ -709,6 +708,7 @@ void ast_store_lock_info(enum ast_lock_type type, const char *filename,
{
}
#ifdef HAVE_BKTR
int __ast_bt_get_addresses(struct ast_bt *bt)
{
return 0;
@ -725,16 +725,6 @@ char **__ast_bt_get_symbols(void **addresses, size_t num_frames)
}
return foo;
}
#else
void ast_remove_lock_info(void *lock_addr)
{
}
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr)
{
}
#endif /* HAVE_BKTR */
void ast_suspend_lock_info(void *lock_addr)
{

Loading…
Cancel
Save