mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
lock.c: Separate DETECT_DEADLOCKS from DEBUG_THREADS
Previously, DETECT_DEADLOCKS depended on DEBUG_THREADS.
Unfortunately, DEBUG_THREADS adds a lot of lock tracking overhead
to all of the lock lifecycle calls whereas DETECT_DEADLOCKS just
causes the lock calls to loop over trylock in 200us intervals until
the lock is obtained and spits out log messages if it takes more
than 5 seconds. From a code perspective, the only reason they were
tied together was for logging. So... The ifdefs in lock.c were
refactored to allow DETECT_DEADLOCKS to be enabled without
also enabling DEBUG_THREADS.
Resolves: #321
UserNote: You no longer need to select DEBUG_THREADS to use
DETECT_DEADLOCKS. This removes a significant amount of overhead
if you just want to detect possible deadlocks vs needing full
lock tracing.
(cherry picked from commit 04df168656
)
This commit is contained in:
committed by
Asterisk Development Team
parent
58a4294631
commit
af51fe730e
@@ -134,14 +134,15 @@ struct ast_lock_track_flags {
|
||||
*/
|
||||
struct ast_mutex_info {
|
||||
pthread_mutex_t mutex;
|
||||
#if !defined(DEBUG_THREADS) && !defined(DEBUG_THREADS_LOOSE_ABI)
|
||||
#if !defined(DEBUG_THREADS) && !defined(DEBUG_THREADS_LOOSE_ABI) && \
|
||||
!defined(DETECT_DEADLOCKS)
|
||||
/*!
|
||||
* These fields are renamed to ensure they are never used when
|
||||
* DEBUG_THREADS is not defined.
|
||||
*/
|
||||
struct ast_lock_track *_track;
|
||||
struct ast_lock_track_flags _flags;
|
||||
#elif defined(DEBUG_THREADS)
|
||||
#elif defined(DEBUG_THREADS) || defined(DETECT_DEADLOCKS)
|
||||
/*! Track which thread holds this mutex. */
|
||||
struct ast_lock_track *track;
|
||||
struct ast_lock_track_flags flags;
|
||||
@@ -155,14 +156,15 @@ struct ast_mutex_info {
|
||||
*/
|
||||
struct ast_rwlock_info {
|
||||
pthread_rwlock_t lock;
|
||||
#if !defined(DEBUG_THREADS) && !defined(DEBUG_THREADS_LOOSE_ABI)
|
||||
#if !defined(DEBUG_THREADS) && !defined(DEBUG_THREADS_LOOSE_ABI) && \
|
||||
!defined(DETECT_DEADLOCKS)
|
||||
/*!
|
||||
* These fields are renamed to ensure they are never used when
|
||||
* DEBUG_THREADS is not defined.
|
||||
*/
|
||||
struct ast_lock_track *_track;
|
||||
struct ast_lock_track_flags _flags;
|
||||
#elif defined(DEBUG_THREADS)
|
||||
#elif defined(DEBUG_THREADS) || defined(DETECT_DEADLOCKS)
|
||||
/*! Track which thread holds this lock */
|
||||
struct ast_lock_track *track;
|
||||
struct ast_lock_track_flags flags;
|
||||
|
Reference in New Issue
Block a user