diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-10-01 21:07:06 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-10-01 21:07:06 +0000 |
commit | 84fc2a4c0fbde326472741b289ebab952d631f3d (patch) | |
tree | be5e818c458a90a2951f9890e321f780ec9b5911 /include/asterisk | |
parent | 662cae0c397d15d9d4f5ec30099fb07e711a7f26 (diff) |
Fulfull a feature request from Qwell on the "core show locks" output. It will
now note the lock type for each lock that a thread holds.
(mutex, rdlock, or wrlock)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@84271 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include/asterisk')
-rw-r--r-- | include/asterisk/lock.h | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h index a0d1542e1..d80726f5a 100644 --- a/include/asterisk/lock.h +++ b/include/asterisk/lock.h @@ -126,6 +126,12 @@ typedef pthread_cond_t ast_cond_t; static pthread_mutex_t empty_mutex; +enum ast_lock_type { + AST_MUTEX, + AST_RDLOCK, + AST_WRLOCK, +}; + /*! * \brief Store lock info for the current thread * @@ -134,8 +140,8 @@ static pthread_mutex_t empty_mutex; * 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. */ -void ast_store_lock_info(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); /*! * \brief Mark the last lock as acquired @@ -249,7 +255,7 @@ static inline int __ast_pthread_mutex_lock(const char *filename, int lineno, con int canlog = strcmp(filename, "logger.c"); if (t->track) - ast_store_lock_info(filename, lineno, func, mutex_name, &t->mutex); + ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex); #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { @@ -333,7 +339,7 @@ static inline int __ast_pthread_mutex_trylock(const char *filename, int lineno, #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ if (t->track) - ast_store_lock_info(filename, lineno, func, mutex_name, &t->mutex); + ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex); if (!(res = pthread_mutex_trylock(&t->mutex))) { if (t->track) @@ -469,7 +475,7 @@ static inline int __ast_cond_wait(const char *filename, int lineno, const char * DO_THREAD_CRASH; } else { if (t->track) - ast_store_lock_info(filename, lineno, func, mutex_name, &t->mutex); + ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex); if (t->reentrancy < AST_MAX_REENTRANCY) { t->file[t->reentrancy] = filename; @@ -530,7 +536,7 @@ static inline int __ast_cond_timedwait(const char *filename, int lineno, const c DO_THREAD_CRASH; } else { if (t->track) - ast_store_lock_info(filename, lineno, func, mutex_name, &t->mutex); + ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex); if (t->reentrancy < AST_MAX_REENTRANCY) { t->file[t->reentrancy] = filename; @@ -722,7 +728,7 @@ static inline int _ast_rwlock_rdlock(ast_rwlock_t *lock, const char *name, const char *file, int line, const char *func) { int res; - ast_store_lock_info(file, line, func, name, lock); + ast_store_lock_info(AST_RDLOCK, file, line, func, name, lock); res = pthread_rwlock_rdlock(lock); if (!res) ast_mark_lock_acquired(); @@ -738,7 +744,7 @@ static inline int _ast_rwlock_wrlock(ast_rwlock_t *lock, const char *name, const char *file, int line, const char *func) { int res; - ast_store_lock_info(file, line, func, name, lock); + ast_store_lock_info(AST_WRLOCK, file, line, func, name, lock); res = pthread_rwlock_wrlock(lock); if (!res) ast_mark_lock_acquired(); @@ -754,7 +760,7 @@ static inline int _ast_rwlock_tryrdlock(ast_rwlock_t *lock, const char *name, const char *file, int line, const char *func) { int res; - ast_store_lock_info(file, line, func, name, lock); + ast_store_lock_info(AST_RDLOCK, file, line, func, name, lock); res = pthread_rwlock_tryrdlock(lock); if (!res) ast_mark_lock_acquired(); @@ -770,7 +776,7 @@ static inline int _ast_rwlock_trywrlock(ast_rwlock_t *lock, const char *name, const char *file, int line, const char *func) { int res; - ast_store_lock_info(file, line, func, name, lock); + ast_store_lock_info(AST_WRLOCK, file, line, func, name, lock); res = pthread_rwlock_trywrlock(lock); if (!res) ast_mark_lock_acquired(); @@ -780,6 +786,7 @@ static inline int _ast_rwlock_trywrlock(ast_rwlock_t *lock, const char *name, } #else + static inline int ast_rwlock_unlock(ast_rwlock_t *prwlock) { return pthread_rwlock_unlock(prwlock); |