summaryrefslogtreecommitdiff
path: root/include/asterisk/lock.h
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2012-11-23 00:02:23 +0000
committerMatthew Jordan <mjordan@digium.com>2012-11-23 00:02:23 +0000
commit588e90a4d9ca1bdda152faa04a661af5e68aad8b (patch)
treeb8d8d737c367fba63023eee05ac42b2c4b21f4f0 /include/asterisk/lock.h
parent4ccf2c7aa5e8be4a7f38170c3e7a3d1fa5beed9c (diff)
Re-initialize logmsgs mutex upon logger initialization to prevent lock errors
Similar to the patch that moved the fork earlier in the startup sequence to prevent mutex errors in the recursive mutex surrounding the read/write thread registration lock, this patch re-initializes the logmsgs mutex. Part of the start up sequence before forking the process into the background includes reading asterisk.conf; this has to occur prior to the call to daemon in order to read startup parameters. When reading in a conf file, log statements can be generated. Since this can't be avoided, the mutex instead is re-initialized to ensure a reset of any thread tracking information. This patch also includes some additional debugging to catch errors when locking or unlocking the recursive mutex that surrounds locks when the DEBUG_THREADS build option is enabled. DO_CRASH or THREAD_CRASH will cause an abort() if a mutex error is detected. (issue ASTERISK-19463) Reported by: mjordan Tesetd by: mjordan ........ Merged revisions 376586 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 376587 from http://svn.asterisk.org/svn/asterisk/branches/10 ........ Merged revisions 376588 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@376589 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk/lock.h')
-rw-r--r--include/asterisk/lock.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h
index 573fc0c00..cffd1a9ac 100644
--- a/include/asterisk/lock.h
+++ b/include/asterisk/lock.h
@@ -428,12 +428,24 @@ int ast_find_lock_info(void *lock_addr, char *filename, size_t filename_size, in
static inline void ast_reentrancy_lock(struct ast_lock_track *lt)
{
- pthread_mutex_lock(&lt->reentr_mutex);
+ int res;
+ if ((res = pthread_mutex_lock(&lt->reentr_mutex))) {
+ fprintf(stderr, "ast_reentrancy_lock failed: '%s' (%d)\n", strerror(res), res);
+#if defined(DO_CRASH) || defined(THREAD_CRASH)
+ abort();
+#endif
+ }
}
static inline void ast_reentrancy_unlock(struct ast_lock_track *lt)
{
- pthread_mutex_unlock(&lt->reentr_mutex);
+ int res;
+ if ((res = pthread_mutex_unlock(&lt->reentr_mutex))) {
+ fprintf(stderr, "ast_reentrancy_unlock failed: '%s' (%d)\n", strerror(res), res);
+#if defined(DO_CRASH) || defined(THREAD_CRASH)
+ abort();
+#endif
+ }
}
static inline void ast_reentrancy_init(struct ast_lock_track **plt)