[asterisk-commits] mmichelson: trunk r116089 - in /trunk: ./ include/asterisk/lock.h main/channel.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 13 18:54:01 CDT 2008


Author: mmichelson
Date: Tue May 13 18:54:01 2008
New Revision: 116089

URL: http://svn.digium.com/view/asterisk?view=rev&rev=116089
Log:
Merged revisions 116088 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r116088 | mmichelson | 2008-05-13 18:47:49 -0500 (Tue, 13 May 2008) | 12 lines

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.


........

Modified:
    trunk/   (props changed)
    trunk/include/asterisk/lock.h
    trunk/main/channel.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/lock.h?view=diff&rev=116089&r1=116088&r2=116089
==============================================================================
--- trunk/include/asterisk/lock.h (original)
+++ trunk/include/asterisk/lock.h Tue May 13 18:54:01 2008
@@ -1217,18 +1217,21 @@
 #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 */

Modified: trunk/main/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/main/channel.c?view=diff&rev=116089&r1=116088&r2=116089
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Tue May 13 18:54:01 2008
@@ -4957,7 +4957,7 @@
 /*! \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 @@
 		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 @@
 
 /*! \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 @@
 
 /*! \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




More information about the asterisk-commits mailing list