[asterisk-commits] mmichelson: branch mmichelson/lock_backtraces r115358 - in /team/mmichelson/l...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue May 6 13:12:39 CDT 2008
Author: mmichelson
Date: Tue May 6 13:12:38 2008
New Revision: 115358
URL: http://svn.digium.com/view/asterisk?view=rev&rev=115358
Log:
Rest of the HAVE_BKTR stuff for non utils dirs.
Modified:
team/mmichelson/lock_backtraces/include/asterisk/lock.h
team/mmichelson/lock_backtraces/main/utils.c
Modified: team/mmichelson/lock_backtraces/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/team/mmichelson/lock_backtraces/include/asterisk/lock.h?view=diff&rev=115358&r1=115357&r2=115358
==============================================================================
--- team/mmichelson/lock_backtraces/include/asterisk/lock.h (original)
+++ team/mmichelson/lock_backtraces/include/asterisk/lock.h Tue May 6 13:12:38 2008
@@ -154,20 +154,20 @@
* on the lock. ast_mark_lock_acquired() will mark it as held by this thread.
*/
#if !defined(LOW_MEMORY)
+#ifdef HAVE_BKTR
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
- int line_num, const char *func, const char *lock_name, void *lock_addr
-#ifdef HAVE_BKTR
- , struct ast_bt *bt);
-#else
- );
+ int line_num, const char *func, const char *lock_name, void *lock_addr, struct ast_bt *bt);
+#else
+void ast_store_lock_info(enum ast_lock_type type, const char *filename,
+ int line_num, const char *func, const char *lock_name, void *lock_addr);
#endif /* HAVE_BKTR */
#else
-#define ast_store_lock_info(I,DONT,CARE,ABOUT,THE,PARAMETERS
-#ifdef HAVE_BKTR
-,BUD)
-#else
-)
+
+#ifdef HAVE_BKTR
+#define ast_store_lock_info(I,DONT,CARE,ABOUT,THE,PARAMETERS,BUD)
+#else
+#define ast_store_lock_info(I,DONT,CARE,ABOUT,THE,PARAMETERS)
#endif /* HAVE_BKTR */
#endif /* !defined(LOW_MEMORY) */
@@ -196,18 +196,16 @@
* be removed from the current thread's lock info struct.
*/
#if !defined(LOW_MEMORY)
-void ast_remove_lock_info(void *lock_addr
-#ifdef HAVE_BKTR
-, struct ast_bt *bt);
-#else
-);
+#ifdef HAVE_BKTR
+void ast_remove_lock_info(void *lock_addr, struct ast_bt *bt);
+#else
+void ast_remove_lock_info(void *lock_addr);
#endif /* HAVE_BKTR */
#else
-#define ast_remove_lock_info(ignore
-#ifdef HAVE_BKTR
-,me)
-#else
-)
+#ifdef HAVE_BKTR
+#define ast_remove_lock_info(ignore,me)
+#else
+#define ast_remove_lock_info(ignore)
#endif /* HAVE_BKTR */
#endif /* !defined(LOW_MEMORY) */
@@ -937,7 +935,9 @@
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
res = pthread_rwlock_unlock(&lock->lock);
+#ifdef HAVE_BKTR
memset(&lock->backtrace, 0, sizeof(lock->backtrace));
+#endif
ast_remove_lock_info(lock, NULL);
return res;
}
@@ -963,13 +963,20 @@
}
}
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
-
+#ifdef HAVE_BKTR
ast_store_lock_info(AST_RDLOCK, file, line, func, name, lock, &lock->backtrace);
+#else
+ ast_store_lock_info(AST_RDLOCK, file, line, func, name, lock);
+#endif
res = pthread_rwlock_rdlock(&lock->lock);
if (!res)
ast_mark_lock_acquired(lock);
else
+#ifdef HAVE_BKTR
ast_remove_lock_info(lock, NULL);
+#else
+ ast_remove_lock_info(lock);
+#endif
return res;
}
@@ -994,13 +1001,20 @@
}
}
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
-
+#ifdef HAVE_BKTR
ast_store_lock_info(AST_WRLOCK, file, line, func, name, lock, &lock->backtrace);
+#else
+ ast_store_lock_info(AST_WRLOCK, file, line, func, name, lock);
+#endif
res = pthread_rwlock_wrlock(&lock->lock);
if (!res)
ast_mark_lock_acquired(lock);
else
+#ifdef HAVE_BKTR
ast_remove_lock_info(lock, NULL);
+#else
+ ast_remove_lock_info(lock);
+#endif
return res;
}
@@ -1025,13 +1039,20 @@
}
}
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
-
+#ifdef HAVE_BKTR
ast_store_lock_info(AST_RDLOCK, file, line, func, name, lock, &lock->backtrace);
+#else
+ ast_store_lock_info(AST_RDLOCK, file, line, func, name, lock);
+#endif
res = pthread_rwlock_tryrdlock(&lock->lock);
if (!res)
ast_mark_lock_acquired(lock);
else
+#ifdef HAVE_BKTR
ast_remove_lock_info(lock, NULL);
+#else
+ ast_remove_lock_info(lock);
+#endif
return res;
}
@@ -1056,13 +1077,20 @@
}
}
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
-
+#ifdef HAVE_BKTR
ast_store_lock_info(AST_WRLOCK, file, line, func, name, lock, &lock->backtrace);
+#else
+ ast_store_lock_info(AST_WRLOCK, file, line, func, name, lock);
+#endif
res = pthread_rwlock_trywrlock(&lock->lock);
if (!res)
ast_mark_lock_acquired(lock);
else
+#ifdef HAVE_BKTR
ast_remove_lock_info(lock, NULL);
+#else
+ ast_remove_lock_info(lock);
+#endif
return res;
}
Modified: team/mmichelson/lock_backtraces/main/utils.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/lock_backtraces/main/utils.c?view=diff&rev=115358&r1=115357&r2=115358
==============================================================================
--- team/mmichelson/lock_backtraces/main/utils.c (original)
+++ team/mmichelson/lock_backtraces/main/utils.c Tue May 6 13:12:38 2008
@@ -540,7 +540,9 @@
enum ast_lock_type type;
/*! This thread is waiting on this lock */
int pending:2;
+#ifdef HAVE_BKTR
struct ast_bt *backtrace;
+#endif
} locks[AST_MAX_LOCKS];
/*! This is the number of locks currently held by this thread.
* The index (num_locks - 1) has the info on the last one in the
@@ -584,9 +586,13 @@
* \brief The thread storage key for per-thread lock info
*/
AST_THREADSTORAGE_CUSTOM(thread_lock_info, NULL, lock_info_destroy);
-
+#ifdef HAVE_BKTR
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr, struct ast_bt *bt)
+#else
+void ast_store_lock_info(enum ast_lock_type type, const char *filename,
+ int line_num, const char *func, const char *lock_name, void *lock_addr)
+#endif
{
struct thr_lock_info *lock_info;
int i;
@@ -599,7 +605,9 @@
for (i = 0; i < lock_info->num_locks; i++) {
if (lock_info->locks[i].lock_addr == lock_addr) {
lock_info->locks[i].times_locked++;
+#ifdef HAVE_BKTR
lock_info->locks[i].backtrace = bt;
+#endif
pthread_mutex_unlock(&lock_info->lock);
return;
}
@@ -630,7 +638,9 @@
lock_info->locks[i].times_locked = 1;
lock_info->locks[i].type = type;
lock_info->locks[i].pending = 1;
+#ifdef HAVE_BKTR
lock_info->locks[i].backtrace = bt;
+#endif
lock_info->num_locks++;
pthread_mutex_unlock(&lock_info->lock);
@@ -664,8 +674,11 @@
}
pthread_mutex_unlock(&lock_info->lock);
}
-
+#ifdef HAVE_BKTR
void ast_remove_lock_info(void *lock_addr, struct ast_bt *bt)
+#else
+void ast_remove_lock_info(void *lock_addr)
+#endif
{
struct thr_lock_info *lock_info;
int i = 0;
@@ -688,7 +701,9 @@
if (lock_info->locks[i].times_locked > 1) {
lock_info->locks[i].times_locked--;
+#ifdef HAVE_BKTR
lock_info->locks[i].backtrace = bt;
+#endif
pthread_mutex_unlock(&lock_info->lock);
return;
}
@@ -718,6 +733,7 @@
return "UNKNOWN";
}
+#ifdef HAVE_BKTR
static void append_backtrace_information(struct ast_str **str, struct ast_bt *bt)
{
char **symbols;
@@ -739,6 +755,7 @@
ast_str_append(str, 0, "\tCouldn't retrieve backtrace symbols\n");
}
}
+#endif
static void append_lock_information(struct ast_str **str, struct thr_lock_info *lock_info, int i)
{
@@ -754,8 +771,9 @@
lock_info->locks[i].func, lock_info->locks[i].lock_name,
lock_info->locks[i].lock_addr,
lock_info->locks[i].times_locked);
-
+#ifdef HAVE_BKTR
append_backtrace_information(str, lock_info->locks[i].backtrace);
+#endif
if (!lock_info->locks[i].pending || lock_info->locks[i].pending == -1)
return;
More information about the asterisk-commits
mailing list