[asterisk-commits] rmudgett: branch rmudgett/debug_threads r428631 - in /team/rmudgett/debug_thr...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Nov 24 18:58:26 CST 2014
Author: rmudgett
Date: Mon Nov 24 18:58:20 2014
New Revision: 428631
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=428631
Log:
Don't overwrite the struct ast_lock_track.reentr_mutex member to restore tracking data.
Modified:
team/rmudgett/debug_threads/include/asterisk/lock.h
team/rmudgett/debug_threads/main/lock.c
Modified: team/rmudgett/debug_threads/include/asterisk/lock.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/debug_threads/include/asterisk/lock.h?view=diff&rev=428631&r1=428630&r2=428631
==============================================================================
--- team/rmudgett/debug_threads/include/asterisk/lock.h (original)
+++ team/rmudgett/debug_threads/include/asterisk/lock.h Mon Nov 24 18:58:20 2014
@@ -101,6 +101,12 @@
struct ast_channel;
+/*!
+ * \brief Lock tracking information.
+ *
+ * \note Any changes to this struct MUST be reflected in the
+ * lock.c:restore_lock_tracking() function.
+ */
struct ast_lock_track {
const char *file[AST_MAX_REENTRANCY];
int lineno[AST_MAX_REENTRANCY];
Modified: team/rmudgett/debug_threads/main/lock.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/debug_threads/main/lock.c?view=diff&rev=428631&r1=428630&r2=428631
==============================================================================
--- team/rmudgett/debug_threads/main/lock.c (original)
+++ team/rmudgett/debug_threads/main/lock.c Mon Nov 24 18:58:20 2014
@@ -549,6 +549,27 @@
return pthread_cond_destroy(cond);
}
+static void restore_lock_tracking(struct ast_lock_track *lt, struct ast_lock_track *lt_saved)
+{
+ ast_reentrancy_lock(lt);
+
+ /*
+ * The following code must match the struct ast_lock_track
+ * definition with the explicit exception of the reentr_mutex
+ * member.
+ */
+ memcpy(lt->file, lt_saved->file, sizeof(lt->file));
+ memcpy(lt->lineno, lt_saved->lineno, sizeof(lt->lineno));
+ lt->reentrancy = lt_saved->reentrancy;
+ memcpy(lt->func, lt_saved->func, sizeof(lt->func));
+ memcpy(lt->thread, lt_saved->thread, sizeof(lt->thread));
+#ifdef HAVE_BKTR
+ memcpy(lt->backtrace, lt_saved->backtrace, sizeof(lt->backtrace));
+#endif
+
+ ast_reentrancy_unlock(lt);
+}
+
int __ast_cond_wait(const char *filename, int lineno, const char *func,
const char *cond_name, const char *mutex_name,
ast_cond_t *cond, ast_mutex_t *t)
@@ -613,17 +634,7 @@
filename, lineno, func, strerror(res));
DO_THREAD_CRASH;
} else if (lt) {
- pthread_mutex_t reentr_mutex_orig;
-
- ast_reentrancy_lock(lt);
- /* Restore lock tracking to what it was prior to the wait */
-/* BUGBUG doing this to lt->reentr_mutex is bad the struct/union can change at any time. */
- reentr_mutex_orig = lt->reentr_mutex;
- *lt = lt_orig;
- /* un-trash the mutex we just copied over */
- lt->reentr_mutex = reentr_mutex_orig;
- ast_reentrancy_unlock(lt);
-
+ restore_lock_tracking(lt, <_orig);
ast_restore_lock_info(t);
}
#endif /* DEBUG_THREADS */
@@ -695,17 +706,7 @@
filename, lineno, func, strerror(res));
DO_THREAD_CRASH;
} else if (lt) {
- pthread_mutex_t reentr_mutex_orig;
-
- ast_reentrancy_lock(lt);
- /* Restore lock tracking to what it was prior to the wait */
-/* BUGBUG doing this to lt->reentr_mutex is bad the struct/union can change at any time. */
- reentr_mutex_orig = lt->reentr_mutex;
- *lt = lt_orig;
- /* un-trash the mutex we just copied over */
- lt->reentr_mutex = reentr_mutex_orig;
- ast_reentrancy_unlock(lt);
-
+ restore_lock_tracking(lt, <_orig);
ast_restore_lock_info(t);
}
#endif /* DEBUG_THREADS */
More information about the asterisk-commits
mailing list