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
This commit is contained in:
Corey Farrell
2017-10-23 01:55:18 -04:00
parent 0b05dafc89
commit 569e9a8391
6 changed files with 16 additions and 129 deletions

View File

@@ -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 */