mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 11:58:52 +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.
This commit is contained in:
committed by
asterisk-org-access-app[bot]
parent
95313d4727
commit
13ccbc1d08
@@ -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