diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h index f352a2d7dccc948057be172e567121c1a75a2bd8..cbc2926b36017f346e41020ffe28e88cf7dc72fb 100644 --- a/include/asterisk/lock.h +++ b/include/asterisk/lock.h @@ -1217,18 +1217,21 @@ AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p), #define ast_channel_trylock(x) ast_mutex_trylock(&x->lock_dont_use) #else +#define ast_channel_lock(a) __ast_channel_lock(a, __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! \brief Lock AST channel (and print debugging output) \note You need to enable DEBUG_CHANNEL_LOCKS for this function */ -int ast_channel_lock(struct ast_channel *chan); +int __ast_channel_lock(struct ast_channel *chan, const char *file, int lineno, const char *func); +#define ast_channel_unlock(a) __ast_channel_unlock(a, __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! \brief Unlock AST channel (and print debugging output) \note You need to enable DEBUG_CHANNEL_LOCKS for this function */ -int ast_channel_unlock(struct ast_channel *chan); +int __ast_channel_unlock(struct ast_channel *chan, const char *file, int lineno, const char *func); +#define ast_channel_trylock(a) __ast_channel_trylock(a, __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! \brief Lock AST channel (and print debugging output) \note You need to enable DEBUG_CHANNEL_LOCKS for this function */ -int ast_channel_trylock(struct ast_channel *chan); +int __ast_channel_trylock(struct ast_channel *chan, const char *file, int lineno, const char *func); #endif #endif /* _ASTERISK_LOCK_H */ diff --git a/main/channel.c b/main/channel.c index 2cb2bc3365260efb2a29ddea322a77c9901c4b5b..099924470a6a224688efd88c7098b0a0cf685bb5 100644 --- a/main/channel.c +++ b/main/channel.c @@ -4957,7 +4957,7 @@ const char *channelreloadreason2txt(enum channelreloadreason reason) /*! \brief Unlock AST channel (and print debugging output) \note You need to enable DEBUG_CHANNEL_LOCKS for this function */ -int ast_channel_unlock(struct ast_channel *chan) +int __ast_channel_unlock(struct ast_channel *chan, const char *filename, int lineno, const char *func) { int res = 0; ast_debug(3, "::::==== Unlocking AST channel %s\n", chan->name); @@ -4966,8 +4966,11 @@ int ast_channel_unlock(struct ast_channel *chan) ast_debug(1, "::::==== Unlocking non-existing channel \n"); return 0; } - +#ifdef DEBUG_THREADS + res = __ast_pthread_mutex_unlock(filename, lineno, func, "(channel lock)", &chan->lock_dont_use); +#else res = ast_mutex_unlock(&chan->lock_dont_use); +#endif if (option_debug > 2) { #ifdef DEBUG_THREADS @@ -4991,13 +4994,17 @@ int ast_channel_unlock(struct ast_channel *chan) /*! \brief Lock AST channel (and print debugging output) \note You need to enable DEBUG_CHANNEL_LOCKS for this function */ -int ast_channel_lock(struct ast_channel *chan) +int __ast_channel_lock(struct ast_channel *chan, const char *filename, int lineno, const char *func) { int res; ast_debug(4, "====:::: Locking AST channel %s\n", chan->name); +#ifdef DEBUG_THREADS + res = __ast_pthread_mutex_lock(filename, lineno, func, "(channel lock)", &chan->lock_dont_use); +#else res = ast_mutex_lock(&chan->lock_dont_use); +#endif if (option_debug > 3) { #ifdef DEBUG_THREADS @@ -5020,13 +5027,16 @@ int ast_channel_lock(struct ast_channel *chan) /*! \brief Lock AST channel (and print debugging output) \note You need to enable DEBUG_CHANNEL_LOCKS for this function */ -int ast_channel_trylock(struct ast_channel *chan) +int __ast_channel_trylock(struct ast_channel *chan, const char *filename, int lineno, const char *func) { int res; ast_debug(3, "====:::: Trying to lock AST channel %s\n", chan->name); - +#ifdef DEBUG_THREADS + res = __ast_pthread_mutex_trylock(filename, lineno, func, "(channel lock)", &chan->lock_dont_use); +#else res = ast_mutex_trylock(&chan->lock_dont_use); +#endif if (option_debug > 2) { #ifdef DEBUG_THREADS