summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2007-10-22 21:37:58 +0000
committerRussell Bryant <russell@russellbryant.com>2007-10-22 21:37:58 +0000
commit8bf796ec101c3bb96814fcf470e146f971ae6c61 (patch)
tree088ab6ff2f15a45741d675f0fd56bcbdd02b63b2 /include
parent39ce390203bf15ce4b3fe8cfb25c621a2299a2f5 (diff)
Merged revisions 86836 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r86836 | russell | 2007-10-22 16:36:12 -0500 (Mon, 22 Oct 2007) | 9 lines If lock tracking is not enabled, then we can not attempt to log any mutex failures. If so, we could end up in infinite recursion. The only lock that is affected by this is a mutex in astmm.c used when MALLOC_DEBUG is enabled. (closes issue #11044) Reported by: ys Patches: lock.h.diff uploaded by ys (license 281) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@86839 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/lock.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h
index e355dcb74..03bbea325 100644
--- a/include/asterisk/lock.h
+++ b/include/asterisk/lock.h
@@ -206,15 +206,19 @@ static inline int __ast_pthread_mutex_init_attr(int track, const char *filename,
const char *mutex_name, ast_mutex_t *t,
pthread_mutexattr_t *attr)
{
+
#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
- int canlog = strcmp(filename, "logger.c");
+ int canlog = strcmp(filename, "logger.c") && track;
if ((t->mutex) != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
if ((t->mutex) != (empty_mutex)) {
__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is already initialized.\n",
filename, lineno, func, mutex_name);
- __ast_mutex_logger("%s line %d (%s): Error: previously initialization of mutex '%s'.\n",
+ /* Don't print track info about nontracked mutex */
+ if (track) {
+ __ast_mutex_logger("%s line %d (%s): Error: previously initialization of mutex '%s'.\n",
t->file[0], t->lineno[0], t->func[0], mutex_name);
+ }
DO_THREAD_CRASH;
return 0;
}
@@ -248,9 +252,11 @@ static inline int __ast_pthread_mutex_destroy(const char *filename, int lineno,
int canlog = strcmp(filename, "logger.c");
#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+ canlog &= t->track;
if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
filename, lineno, func, mutex_name);
+ return 0; /* mutex is uninitialized */
}
#endif
@@ -302,10 +308,13 @@ static inline int __ast_pthread_mutex_lock(const char *filename, int lineno, con
ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex);
#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS)
+ canlog &= t->track;
+
if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
filename, lineno, func, mutex_name);
- ast_mutex_init(t);
+ __ast_pthread_mutex_init(t->track, filename, lineno, func, mutex_name, t);
+
}
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
@@ -379,10 +388,12 @@ static inline int __ast_pthread_mutex_trylock(const char *filename, int lineno,
int canlog = strcmp(filename, "logger.c");
#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS)
+ canlog &= t->track;
+
if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
filename, lineno, func, mutex_name);
- ast_mutex_init(t);
+ __ast_pthread_mutex_init(t->track, filename, lineno, func, mutex_name, t);
}
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
@@ -418,6 +429,8 @@ static inline int __ast_pthread_mutex_unlock(const char *filename, int lineno, c
int canlog = strcmp(filename, "logger.c");
#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+ canlog &= t->track;
+
if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
filename, lineno, func, mutex_name);
@@ -491,6 +504,7 @@ static inline int __ast_cond_wait(const char *filename, int lineno, const char *
int canlog = strcmp(filename, "logger.c");
#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+ canlog &= t->track;
if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
filename, lineno, func, mutex_name);
@@ -556,6 +570,7 @@ static inline int __ast_cond_timedwait(const char *filename, int lineno, const c
int canlog = strcmp(filename, "logger.c");
#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+ canlog &= t->track;
if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
filename, lineno, func, mutex_name);