diff options
author | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-05-13 23:47:49 +0000 |
---|---|---|
committer | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-05-13 23:47:49 +0000 |
commit | 3a6b342e1c906933c191b410e9d774fec936c28b (patch) | |
tree | 2734bfb5d029a6ef36dc422c19803fc886f057a5 /main/channel.c | |
parent | cffbde648458383efb0930d428fc72960e0af9d7 (diff) |
A change to the way channel locks are handled when DEBUG_CHANNEL_LOCKS is defined.
After debugging a deadlock, it was noticed that when DEBUG_CHANNEL_LOCKS
is enabled in menuselect, the actual origin of channel locks is obscured
by the fact that all channel locks appear to happen in the function
ast_channel_lock(). This code change redefines ast_channel_lock to be a
macro which maps to __ast_channel_lock(), which then relays the proper
file name, line number, and function name information to the core lock
functions so that this information will be displayed in the case that
there is some sort of locking error or core show locks is issued.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@116088 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/channel.c')
-rw-r--r-- | main/channel.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/main/channel.c b/main/channel.c index f61d365b7..d9ab77c38 100644 --- a/main/channel.c +++ b/main/channel.c @@ -4534,7 +4534,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; if (option_debug > 2) @@ -4545,8 +4545,11 @@ int ast_channel_unlock(struct ast_channel *chan) ast_log(LOG_DEBUG, "::::==== Unlocking non-existing channel \n"); return 0; } - +#ifdef DEBUG_THREADS + res = __ast_pthread_mutex_unlock(filename, lineno, func, "(channel lock)", &chan->lock); +#else res = ast_mutex_unlock(&chan->lock); +#endif if (option_debug > 2) { #ifdef DEBUG_THREADS @@ -4573,14 +4576,18 @@ 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; if (option_debug > 3) ast_log(LOG_DEBUG, "====:::: Locking AST channel %s\n", chan->name); +#ifdef DEBUG_THREADS + res = __ast_pthread_mutex_lock(filename, lineno, func, "(channel lock)", &chan->lock); +#else res = ast_mutex_lock(&chan->lock); +#endif if (option_debug > 3) { #ifdef DEBUG_THREADS @@ -4605,14 +4612,17 @@ 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; if (option_debug > 2) ast_log(LOG_DEBUG, "====:::: Trying to lock AST channel %s\n", chan->name); - +#ifdef DEBUG_THREADS + res = __ast_pthread_mutex_trylock(filename, lineno, func, "(channel lock)", &chan->lock); +#else res = ast_mutex_trylock(&chan->lock); +#endif if (option_debug > 2) { #ifdef DEBUG_THREADS |