[asterisk-commits] murf: branch murf/bug11210 r114039 - in /team/murf/bug11210: include/asterisk...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Apr 10 13:24:37 CDT 2008
Author: murf
Date: Thu Apr 10 13:24:36 2008
New Revision: 114039
URL: http://svn.digium.com/view/asterisk?view=rev&rev=114039
Log:
Added log_show_lock(lockaddr) to the interface. It will sift thru the lists of open locks, and if a match is found, it will print out info about the match. Useful in debugging. By 'print out', I mean it will do an ast_log(LOG_NOTICE,....); If you are having unexpected trouble with lock contention, and the locks come and go too quickly to see them with 'core show locks', then you can call this func right before the possible lock contention will happen. It will output something only if a match is made.
Modified:
team/murf/bug11210/include/asterisk/lock.h
team/murf/bug11210/main/utils.c
Modified: team/murf/bug11210/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/include/asterisk/lock.h?view=diff&rev=114039&r1=114038&r2=114039
==============================================================================
--- team/murf/bug11210/include/asterisk/lock.h (original)
+++ team/murf/bug11210/include/asterisk/lock.h Thu Apr 10 13:24:36 2008
@@ -168,6 +168,18 @@
* be removed from the current thread's lock info struct.
*/
void ast_remove_lock_info(void *lock_addr);
+
+
+
+/*!
+ * \brief log info for the current lock with ast_log().
+ *
+ * this function would be mostly for debug. If you come across a lock
+ * that is unexpectedly but momentarily locked, and you wonder who
+ * are fighting with for the lock, this routine could be called, IF
+ * you have the thread debugging stuff turned on.
+ */
+void log_show_lock(void *this_lock_addr);
static void __attribute__((constructor)) init_empty_mutex(void)
{
Modified: team/murf/bug11210/main/utils.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/main/utils.c?view=diff&rev=114039&r1=114038&r2=114039
==============================================================================
--- team/murf/bug11210/main/utils.c (original)
+++ team/murf/bug11210/main/utils.c Thu Apr 10 13:24:36 2008
@@ -714,6 +714,54 @@
return "UNKNOWN";
}
+void log_show_lock(void *this_lock_addr)
+{
+ struct thr_lock_info *lock_info;
+ struct ast_str *str;
+
+ pthread_mutex_lock(&lock_infos_lock.mutex);
+ AST_LIST_TRAVERSE(&lock_infos, lock_info, entry) {
+ int i;
+ pthread_mutex_lock(&lock_info->lock);
+ for (i = 0; str && i < lock_info->num_locks; i++) {
+ int j;
+ ast_mutex_t *lock;
+ if (lock_info->locks[i].lock_addr == this_lock_addr) {
+
+ ast_log(LOG_NOTICE, "---> %sLock #%d (%s): %s %d %s %s %p (%d)\n",
+ lock_info->locks[i].pending > 0 ? "Waiting for " : lock_info->locks[i].pending < 0 ? "Tried and failed to get " : "",
+ i,
+ lock_info->locks[i].file,
+ locktype2str(lock_info->locks[i].type),
+ lock_info->locks[i].line_num,
+ lock_info->locks[i].func,
+ lock_info->locks[i].lock_name,
+ lock_info->locks[i].lock_addr,
+ lock_info->locks[i].times_locked);
+
+ if (!lock_info->locks[i].pending || lock_info->locks[i].pending == -1)
+ continue;
+
+ /* We only have further details for mutexes right now */
+ if (lock_info->locks[i].type != AST_MUTEX)
+ continue;
+
+ lock = lock_info->locks[i].lock_addr;
+
+ ast_reentrancy_lock(lock);
+ for (j = 0; str && j < lock->reentrancy; j++) {
+ ast_log(LOG_NOTICE, "--- ---> Locked Here: %s line %d (%s)\n",
+ lock->file[j], lock->lineno[j], lock->func[j]);
+ }
+ ast_reentrancy_unlock(lock);
+ }
+ }
+ pthread_mutex_unlock(&lock_info->lock);
+ }
+ pthread_mutex_unlock(&lock_infos_lock.mutex);
+}
+
+
static char *handle_show_locks(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct thr_lock_info *lock_info;
@@ -740,7 +788,7 @@
"=== Currently Held Locks ==============================================\n"
"=======================================================================\n"
"===\n"
- "=== <file> <line num> <function> <lock name> <lock addr> (times locked)\n"
+ "=== <pending> <lock#> (<file>): <lock type> <line num> <function> <lock name> <lock addr> (times locked)\n"
"===\n");
if (!str)
More information about the asterisk-commits
mailing list