diff options
author | Tilghman Lesher <tilghman@meg.abyt.es> | 2008-06-25 02:34:11 +0000 |
---|---|---|
committer | Tilghman Lesher <tilghman@meg.abyt.es> | 2008-06-25 02:34:11 +0000 |
commit | 94c4089f4eebc7c28346f97265119d238a92afbe (patch) | |
tree | 5b9f31de4abfe65b58eab4424d3e6556492634ee /include | |
parent | 15093f2a63eb32e45ce42b6e00b14211d611e999 (diff) |
More expansion of the deadlock avoidance macro, including a macro to do locking
of the channel lock
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@125020 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/lock.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h index 3f261c6a3..4122978fb 100644 --- a/include/asterisk/lock.h +++ b/include/asterisk/lock.h @@ -289,6 +289,21 @@ int ast_find_lock_info(void *lock_addr, const char **filename, int *lineno, cons } \ } while (0) +#define DLA_UNLOCK(lock) \ + do { \ + const char *__filename, *__func, *__mutex_name; \ + int __lineno; \ + int __res = ast_find_lock_info(lock, &__filename, &__lineno, &__func, &__mutex_name); \ + ast_mutex_unlock(lock); + +#define DLA_LOCK(lock) \ + if (__res < 0) { /* Shouldn't ever happen, but just in case... */ \ + ast_mutex_lock(lock); \ + } else { \ + __ast_pthread_mutex_lock(__filename, __lineno, __func, __mutex_name, lock); \ + } \ + } while (0) + static inline void ast_reentrancy_lock(struct ast_lock_track *lt) { pthread_mutex_lock(<->reentr_mutex); @@ -1429,6 +1444,10 @@ static inline int _ast_rwlock_trywrlock(ast_rwlock_t *t, const char *name, usleep(1); \ ast_mutex_unlock(lock); +#define DLA_UNLOCK(lock) ast_mutex_unlock(lock) + +#define DLA_LOCK(lock) ast_mutex_lock(lock) + typedef pthread_mutex_t ast_mutex_t; #define AST_MUTEX_INIT_VALUE ((ast_mutex_t) PTHREAD_MUTEX_INIT_VALUE) |