#include <pthread.h>
#include <time.h>
#include <sys/param.h>
#include <execinfo.h>
#include "asterisk/logger.h"
#include "asterisk/compiler.h"
#include <errno.h>
#include "asterisk/inline_api.h"
Go to the source code of this file.
Data Structures | |
struct | ast_lock_track |
struct | ast_mutex_info |
Structure for mutex and tracking information. More... | |
struct | ast_rwlock_info |
Structure for rwlock and tracking information. More... | |
Defines | |
#define | __AST_MUTEX_DEFINE(scope, mutex, init_val, track) scope ast_mutex_t mutex = init_val |
#define | __ast_mutex_logger() do { if (canlog) ast_log(LOG_ERROR, __VA_ARGS__); else fprintf(stderr, __VA_ARGS__); } while (0) |
#define | __AST_RWLOCK_DEFINE(scope, rwlock, init_val, track) scope ast_rwlock_t rwlock = init_val |
#define | __AST_RWLOCK_INIT_VALUE PTHREAD_RWLOCK_INITIALIZER |
#define | ast_cond_broadcast(cond) __ast_cond_broadcast(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond) |
#define | ast_cond_destroy(cond) __ast_cond_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond) |
#define | ast_cond_init(cond, attr) __ast_cond_init(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond, attr) |
#define | ast_cond_signal(cond) __ast_cond_signal(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond) |
#define | ast_cond_timedwait(cond, mutex, time) __ast_cond_timedwait(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #mutex, cond, mutex, time) |
#define | ast_cond_wait(cond, mutex) __ast_cond_wait(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #mutex, cond, mutex) |
#define | AST_LOCK_TRACK_INIT_VALUE { { NULL }, { 0 }, 0, { NULL }, { 0 }, {{{ 0 }}}, PTHREAD_MUTEX_INIT_VALUE } |
#define | AST_MAX_REENTRANCY 10 |
#define | AST_MUTEX_DEFINE_STATIC(mutex) __AST_MUTEX_DEFINE(static, mutex, AST_MUTEX_INIT_VALUE, 1) |
#define | AST_MUTEX_DEFINE_STATIC_NOTRACKING(mutex) __AST_MUTEX_DEFINE(static, mutex, AST_MUTEX_INIT_VALUE_NOTRACKING, 0) |
#define | ast_mutex_destroy(a) __ast_pthread_mutex_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a) |
#define | ast_mutex_init(pmutex) __ast_pthread_mutex_init(1, __FILE__, __LINE__, __PRETTY_FUNCTION__, #pmutex, pmutex) |
#define | ast_mutex_init_notracking(pmutex) __ast_pthread_mutex_init(0, __FILE__, __LINE__, __PRETTY_FUNCTION__, #pmutex, pmutex) |
#define | AST_MUTEX_INIT_VALUE { PTHREAD_MUTEX_INIT_VALUE, NULL, 1 } |
#define | AST_MUTEX_INIT_VALUE_NOTRACKING { PTHREAD_MUTEX_INIT_VALUE, NULL, 0 } |
#define | AST_MUTEX_INITIALIZER __use_AST_MUTEX_DEFINE_STATIC_rather_than_AST_MUTEX_INITIALIZER__ |
#define | AST_MUTEX_KIND PTHREAD_MUTEX_RECURSIVE_NP |
#define | ast_mutex_lock(a) __ast_pthread_mutex_lock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a) |
#define | ast_mutex_trylock(a) __ast_pthread_mutex_trylock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a) |
#define | ast_mutex_unlock(a) __ast_pthread_mutex_unlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a) |
#define | AST_PTHREADT_NULL (pthread_t) -1 |
#define | AST_PTHREADT_STOP (pthread_t) -2 |
#define | AST_RWLOCK_DEFINE_STATIC(rwlock) __AST_RWLOCK_DEFINE(static, rwlock, AST_RWLOCK_INIT_VALUE, 1) |
#define | AST_RWLOCK_DEFINE_STATIC_NOTRACKING(rwlock) __AST_RWLOCK_DEFINE(static, rwlock, AST_RWLOCK_INIT_VALUE_NOTRACKING, 0) |
#define | ast_rwlock_destroy(rwlock) __ast_rwlock_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, #rwlock, rwlock) |
#define | ast_rwlock_init(rwlock) __ast_rwlock_init(1, __FILE__, __LINE__, __PRETTY_FUNCTION__, #rwlock, rwlock) |
wrapper for rwlock with tracking enabled | |
#define | ast_rwlock_init_notracking(rwlock) __ast_rwlock_init(0, __FILE__, __LINE__, __PRETTY_FUNCTION__, #rwlock, rwlock) |
wrapper for ast_rwlock_init with tracking disabled | |
#define | AST_RWLOCK_INIT_VALUE { __AST_RWLOCK_INIT_VALUE, NULL, 1 } |
#define | AST_RWLOCK_INIT_VALUE_NOTRACKING { __AST_RWLOCK_INIT_VALUE, NULL, 0 } |
#define | ast_rwlock_rdlock(a) __ast_rwlock_rdlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a) |
#define | ast_rwlock_timedrdlock(a, b) __ast_rwlock_timedrdlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a, b) |
#define | ast_rwlock_timedwrlock(a, b) __ast_rwlock_timedwrlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a, b) |
#define | ast_rwlock_tryrdlock(a) __ast_rwlock_tryrdlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a) |
#define | ast_rwlock_trywrlock(a) __ast_rwlock_trywrlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a) |
#define | ast_rwlock_unlock(a) __ast_rwlock_unlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a) |
#define | ast_rwlock_wrlock(a) __ast_rwlock_wrlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a) |
#define | CHANNEL_DEADLOCK_AVOIDANCE(chan) |
Unlock a lock briefly. | |
#define | DEADLOCK_AVOIDANCE(lock) |
#define | DLA_LOCK(lock) |
Deadlock avoidance lock. | |
#define | DLA_UNLOCK(lock) |
Deadlock avoidance unlock. | |
#define | DO_THREAD_CRASH do { } while (0) |
#define | gethostbyname __gethostbyname__is__not__reentrant__use__ast_gethostbyname__instead__ |
#define | pthread_cond_broadcast use_ast_cond_broadcast_instead_of_pthread_cond_broadcast |
#define | pthread_cond_destroy use_ast_cond_destroy_instead_of_pthread_cond_destroy |
#define | pthread_cond_init use_ast_cond_init_instead_of_pthread_cond_init |
#define | pthread_cond_signal use_ast_cond_signal_instead_of_pthread_cond_signal |
#define | pthread_cond_t use_ast_cond_t_instead_of_pthread_cond_t |
#define | pthread_cond_timedwait use_ast_cond_timedwait_instead_of_pthread_cond_timedwait |
#define | pthread_cond_wait use_ast_cond_wait_instead_of_pthread_cond_wait |
#define | pthread_create __use_ast_pthread_create_instead__ |
#define | pthread_mutex_destroy use_ast_mutex_destroy_instead_of_pthread_mutex_destroy |
#define | pthread_mutex_init use_ast_mutex_init_instead_of_pthread_mutex_init |
#define | PTHREAD_MUTEX_INIT_VALUE PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP |
#define | pthread_mutex_lock use_ast_mutex_lock_instead_of_pthread_mutex_lock |
#define | pthread_mutex_t use_ast_mutex_t_instead_of_pthread_mutex_t |
#define | pthread_mutex_trylock use_ast_mutex_trylock_instead_of_pthread_mutex_trylock |
#define | pthread_mutex_unlock use_ast_mutex_unlock_instead_of_pthread_mutex_unlock |
#define | ROFFSET ((lt->reentrancy > 0) ? (lt->reentrancy-1) : 0) |
Typedefs | |
typedef pthread_cond_t | ast_cond_t |
typedef ast_mutex_info | ast_mutex_t |
typedef ast_rwlock_info | ast_rwlock_t |
Enumerations | |
enum | ast_lock_type { AST_MUTEX, AST_RDLOCK, AST_WRLOCK } |
Functions | |
int | __ast_cond_broadcast (const char *filename, int lineno, const char *func, const char *cond_name, ast_cond_t *cond) |
int | __ast_cond_destroy (const char *filename, int lineno, const char *func, const char *cond_name, ast_cond_t *cond) |
int | __ast_cond_init (const char *filename, int lineno, const char *func, const char *cond_name, ast_cond_t *cond, pthread_condattr_t *cond_attr) |
int | __ast_cond_signal (const char *filename, int lineno, const char *func, const char *cond_name, ast_cond_t *cond) |
int | __ast_cond_timedwait (const char *filename, int lineno, const char *func, const char *cond_name, const char *mutex_name, ast_cond_t *cond, ast_mutex_t *t, const struct timespec *abstime) |
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) |
int | __ast_pthread_mutex_destroy (const char *filename, int lineno, const char *func, const char *mutex_name, ast_mutex_t *t) |
int | __ast_pthread_mutex_init (int tracking, const char *filename, int lineno, const char *func, const char *mutex_name, ast_mutex_t *t) |
int | __ast_pthread_mutex_lock (const char *filename, int lineno, const char *func, const char *mutex_name, ast_mutex_t *t) |
int | __ast_pthread_mutex_trylock (const char *filename, int lineno, const char *func, const char *mutex_name, ast_mutex_t *t) |
int | __ast_pthread_mutex_unlock (const char *filename, int lineno, const char *func, const char *mutex_name, ast_mutex_t *t) |
int | __ast_rwlock_destroy (const char *filename, int lineno, const char *func, const char *rwlock_name, ast_rwlock_t *t) |
int | __ast_rwlock_init (int tracking, const char *filename, int lineno, const char *func, const char *rwlock_name, ast_rwlock_t *t) |
int | __ast_rwlock_rdlock (const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name) |
int | __ast_rwlock_timedrdlock (const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name, const struct timespec *abs_timeout) |
int | __ast_rwlock_timedwrlock (const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name, const struct timespec *abs_timeout) |
int | __ast_rwlock_tryrdlock (const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name) |
int | __ast_rwlock_trywrlock (const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name) |
int | __ast_rwlock_unlock (const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name) |
int | __ast_rwlock_wrlock (const char *filename, int lineno, const char *func, ast_rwlock_t *t, const char *name) |
static void | __dump_backtrace (struct ast_bt *bt, int canlog) |
int | ast_atomic_dec_and_test (volatile int *p) |
decrement *p by 1 and return true if the variable has reached 0. Useful e.g. to check if a refcount has reached 0. | |
int | ast_atomic_fetchadd_int (volatile int *p, int v) |
Atomically add v to *p and return * the previous value of *p. This can be used to handle reference counts, and the return value can be used to generate unique identifiers. | |
int | ast_atomic_fetchadd_int_slow (volatile int *p, int v) |
int | ast_find_lock_info (void *lock_addr, char *filename, size_t filename_size, int *lineno, char *func, size_t func_size, char *mutex_name, size_t mutex_name_size) |
retrieve lock info for the specified mutex | |
void | ast_mark_lock_acquired (void *lock_addr) |
Mark the last lock as acquired. | |
void | ast_mark_lock_failed (void *lock_addr) |
Mark the last lock as failed (trylock). | |
static void | ast_reentrancy_init (struct ast_lock_track **plt) |
static void | ast_reentrancy_lock (struct ast_lock_track *lt) |
static void | ast_reentrancy_unlock (struct ast_lock_track *lt) |
void | ast_remove_lock_info (void *lock_addr, struct ast_bt *bt) |
remove lock info for the current thread | |
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) |
Store lock info for the current thread. | |
static void | delete_reentrancy_cs (struct ast_lock_track **plt) |
void | log_show_lock (void *this_lock_addr) |
log info for the current lock with ast_log(). |
Definition in file lock.h.
#define __AST_MUTEX_DEFINE | ( | scope, | |||
mutex, | |||||
init_val, | |||||
track | ) | scope ast_mutex_t mutex = init_val |
#define __ast_mutex_logger | ( | ) | do { if (canlog) ast_log(LOG_ERROR, __VA_ARGS__); else fprintf(stderr, __VA_ARGS__); } while (0) |
Definition at line 212 of file lock.h.
Referenced by __ast_cond_timedwait(), __ast_cond_wait(), __ast_pthread_mutex_destroy(), __ast_pthread_mutex_lock(), __ast_pthread_mutex_trylock(), __ast_pthread_mutex_unlock(), __ast_rwlock_destroy(), __ast_rwlock_init(), __ast_rwlock_rdlock(), __ast_rwlock_timedrdlock(), __ast_rwlock_timedwrlock(), __ast_rwlock_tryrdlock(), __ast_rwlock_trywrlock(), __ast_rwlock_unlock(), __ast_rwlock_wrlock(), and __dump_backtrace().
#define __AST_RWLOCK_DEFINE | ( | scope, | |||
rwlock, | |||||
init_val, | |||||
track | ) | scope ast_rwlock_t rwlock = init_val |
#define __AST_RWLOCK_INIT_VALUE PTHREAD_RWLOCK_INITIALIZER |
Definition at line 83 of file lock.h.
Referenced by __ast_rwlock_destroy(), __ast_rwlock_init(), __ast_rwlock_rdlock(), __ast_rwlock_timedrdlock(), __ast_rwlock_timedwrlock(), __ast_rwlock_tryrdlock(), __ast_rwlock_trywrlock(), __ast_rwlock_unlock(), and __ast_rwlock_wrlock().
#define ast_cond_broadcast | ( | cond | ) | __ast_cond_broadcast(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond) |
Definition at line 170 of file lock.h.
Referenced by aji_handle_message(), ast_smdi_md_message_push(), ast_smdi_md_message_putback(), ast_smdi_mwi_message_push(), ast_smdi_mwi_message_putback(), and inotify_daemon().
#define ast_cond_destroy | ( | cond | ) | __ast_cond_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond) |
Definition at line 168 of file lock.h.
Referenced by __unload_module(), agent_cleanup(), agent_hangup(), ast_audiohook_destroy(), ast_bridge_impart(), ast_bridge_join(), ast_sched_thread_destroy(), ast_smdi_interface_destroy(), bridge_channel_thread(), do_reload(), find_idle_thread(), get_lock(), iax2_process_thread_cleanup(), init_logger(), login_exec(), mixmonitor_free(), read_agent_config(), setup_mixmonitor_ds(), sla_destroy(), sla_handle_dial_state_event(), sla_station_exec(), start_network_thread(), tps_taskprocessor_destroy(), and unload_module().
#define ast_cond_init | ( | cond, | |||
attr | ) | __ast_cond_init(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond, attr) |
Definition at line 167 of file lock.h.
Referenced by add_agent(), add_notify(), alloc_smdi_interface(), ast_audiohook_init(), ast_autoservice_init(), ast_bridge_impart(), ast_bridge_join(), ast_device_state_engine_init(), ast_enable_distributed_devstate(), ast_sched_thread_create(), ast_taskprocessor_get(), ast_tps_init(), astdb_init(), do_reload(), find_idle_thread(), get_lock(), init_logger(), init_timing_thread(), load_module(), setup_mixmonitor_ds(), sla_handle_dial_state_event(), sla_load_config(), sla_station_exec(), and start_network_thread().
#define ast_cond_signal | ( | cond | ) | __ast_cond_signal(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond) |
Definition at line 169 of file lock.h.
Referenced by _unload_module(), agent_cleanup(), agent_hangup(), agent_new(), ast_audiohook_update_status(), ast_audiohook_write_frame(), ast_autoservice_start(), ast_bridge_change_state(), ast_bridge_merge(), ast_devstate_changed_literal(), ast_log(), ast_sched_thread_add(), ast_sched_thread_add_variable(), ast_sched_thread_destroy(), ast_sched_thread_poke(), ast_taskprocessor_push(), calendar_destructor(), close_logger(), conf_free(), conf_run(), db_sync(), devstate_change_collector_cb(), dial_trunk(), lock_broker(), mixmonitor_ds_destroy(), my_decrease_ss_count(), pthread_timer_open(), run_station(), schedule_calendar_event(), signal_condition(), sla_destroy(), sla_queue_event_full(), smart_bridge_operation(), stop_mixmonitor_exec(), stop_poll_thread(), submit_unscheduled_batch(), tps_ping_handler(), tps_taskprocessor_destroy(), and unload_module().
#define ast_cond_timedwait | ( | cond, | |||
mutex, | |||||
time | ) | __ast_cond_timedwait(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #mutex, cond, mutex, time) |
Definition at line 172 of file lock.h.
Referenced by acf_jabberreceive_read(), ast_audiohook_trigger_wait(), caldav_load_calendar(), cli_tps_ping(), do_cdr(), do_refresh(), do_timing(), ewscal_load_calendar(), exchangecal_load_calendar(), get_lock(), iax2_process_thread(), ical_load_calendar(), mb_poll_thread(), mwi_monitor_handler(), sched_run(), sla_thread(), and smdi_message_wait().
#define ast_cond_wait | ( | cond, | |||
mutex | ) | __ast_cond_wait(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #mutex, cond, mutex) |
Definition at line 171 of file lock.h.
Referenced by add_notify(), announce_thread(), ast_localtime_wakeup_monitor(), autoservice_run(), bridge_channel_join_singlethreaded(), db_sync_thread(), do_devstate_changes(), do_timing(), find_idle_thread(), logger_thread(), login_exec(), mixmonitor_thread(), run_devstate_collector(), sched_run(), sla_handle_dial_state_event(), sla_station_exec(), sla_thread(), and tps_processing_function().
#define AST_LOCK_TRACK_INIT_VALUE { { NULL }, { 0 }, 0, { NULL }, { 0 }, {{{ 0 }}}, PTHREAD_MUTEX_INIT_VALUE } |
#define AST_MAX_REENTRANCY 10 |
Definition at line 100 of file lock.h.
Referenced by __ast_cond_timedwait(), __ast_cond_wait(), __ast_pthread_mutex_lock(), __ast_pthread_mutex_trylock(), __ast_pthread_mutex_unlock(), __ast_rwlock_rdlock(), __ast_rwlock_timedrdlock(), __ast_rwlock_timedwrlock(), __ast_rwlock_tryrdlock(), __ast_rwlock_trywrlock(), __ast_rwlock_wrlock(), and ast_reentrancy_init().
#define ast_mutex_destroy | ( | a | ) | __ast_pthread_mutex_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a) |
Definition at line 154 of file lock.h.
Referenced by __oh323_destroy(), __unload_module(), agent_cleanup(), agent_hangup(), ast_audiohook_destroy(), ast_bridge_impart(), ast_bridge_join(), ast_dnsmgr_release(), ast_sched_thread_destroy(), ast_smdi_interface_destroy(), ast_speech_destroy(), ast_speech_new(), bridge_channel_thread(), bridge_hangup(), build_conf(), build_device(), chan_list_destructor(), close_client(), destroy_conference_bridge(), destroy_dahdi_pvt(), destroy_session(), do_monitor(), find_idle_thread(), find_realtime(), free_config(), get_lock(), iax2_process_thread_cleanup(), internal_ao2_ref(), load_module(), login_exec(), misdn_cfg_destroy(), misdn_jb_destroy(), mixmonitor_free(), odbc_obj_destructor(), read_agent_config(), reload_config(), sched_context_destroy(), session_instance_destructor(), setup_mixmonitor_ds(), sla_destroy(), sla_handle_dial_state_event(), sla_station_exec(), softmix_bridge_leave(), start_network_thread(), timing_read(), tps_taskprocessor_destroy(), unalloc_sub(), and unload_module().
#define ast_mutex_init | ( | pmutex | ) | __ast_pthread_mutex_init(1, __FILE__, __LINE__, __PRETTY_FUNCTION__, #pmutex, pmutex) |
Definition at line 152 of file lock.h.
Referenced by _ast_odbc_request_obj2(), accept_thread(), add_agent(), add_notify(), alloc_profile(), alloc_smdi_interface(), alloc_sub(), ast_audiohook_init(), ast_bridge_impart(), ast_bridge_join(), ast_context_find_or_create(), ast_dial_create(), ast_dnsmgr_get(), ast_enable_distributed_devstate(), ast_sched_thread_create(), ast_speech_new(), ast_ssl_init(), ast_taskprocessor_get(), ast_tcptls_client_create(), ast_tcptls_server_root(), bridge_request(), build_conf(), build_device(), caldav_load_calendar(), conf_run(), config_device(), config_line(), config_parse_variables(), create_client(), duplicate_pseudo(), ewscal_load_calendar(), exchangecal_load_calendar(), find_idle_thread(), find_tpeer(), get_lock(), gtalk_alloc(), ical_load_calendar(), init_timing_thread(), internal_ao2_alloc(), jingle_alloc(), join_conference_bridge(), load_config(), load_module(), misdn_cfg_init(), misdn_jb_init(), oh323_alloc(), read_config(), rpt_master(), sched_context_create(), session_do(), setup_mixmonitor_ds(), sig_pri_init_pri(), sig_pri_start_pri(), skinny_new(), sla_handle_dial_state_event(), sla_load_config(), sla_station_exec(), softmix_bridge_join(), start_network_thread(), and store_config().
#define ast_mutex_init_notracking | ( | pmutex | ) | __ast_pthread_mutex_init(0, __FILE__, __LINE__, __PRETTY_FUNCTION__, #pmutex, pmutex) |
#define AST_MUTEX_INIT_VALUE { PTHREAD_MUTEX_INIT_VALUE, NULL, 1 } |
#define AST_MUTEX_INIT_VALUE_NOTRACKING { PTHREAD_MUTEX_INIT_VALUE, NULL, 0 } |
#define AST_MUTEX_INITIALIZER __use_AST_MUTEX_DEFINE_STATIC_rather_than_AST_MUTEX_INITIALIZER__ |
#define AST_MUTEX_KIND PTHREAD_MUTEX_RECURSIVE_NP |
Definition at line 76 of file lock.h.
Referenced by __ast_pthread_mutex_init(), ast_reentrancy_init(), and dummy_start().
#define ast_mutex_lock | ( | a | ) | __ast_pthread_mutex_lock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a) |
Definition at line 155 of file lock.h.
Referenced by __attempt_transmit(), __auth_reject(), __auto_congest(), __auto_hangup(), __find_callno(), __get_from_jb(), __iax2_poke_noanswer(), __oh323_new(), __reload(), __send_lagrq(), __send_ping(), __unload_module(), _unload_module(), acf_channel_read(), acf_jabberreceive_read(), action_agents(), action_dahdishowchannels(), add_notify(), agent_ack_sleep(), agent_call(), agent_cont_sleep(), agent_devicestate(), agent_digit_begin(), agent_digit_end(), agent_fixup(), agent_hangup(), agent_indicate(), agent_logoff(), agent_new(), agent_read(), agent_request(), agent_sendhtml(), agent_sendtext(), agent_write(), agents_data_provider_get(), agents_show(), agents_show_online(), aji_handle_message(), alsa_answer(), alsa_call(), alsa_digit(), alsa_fixup(), alsa_hangup(), alsa_indicate(), alsa_read(), alsa_request(), alsa_text(), alsa_write(), analog_ss_thread(), announce_thread(), answer_exec_run(), aoro2_obj_cb(), app_exec(), append_mailbox_mapping(), ast_atomic_fetchadd_int_slow(), ast_bridge_change_state(), ast_bridge_merge(), ast_cdr_detach(), ast_cdr_engine_init(), ast_cdr_submit_batch(), ast_cel_report_event(), ast_cli_netstats(), ast_config_engine_deregister(), ast_config_engine_register(), ast_context_lockmacro(), ast_db_del(), ast_db_deltree(), ast_db_get(), ast_db_gettree(), ast_db_put(), ast_dial_join(), ast_dnsmgr_changed(), ast_get_enum(), ast_iax2_new(), ast_monitor_start(), ast_random(), ast_rdlock_contexts(), ast_replace_sigchld(), ast_sched_add_variable(), ast_sched_del(), ast_sched_dump(), ast_sched_report(), ast_sched_runq(), ast_sched_thread_add(), ast_sched_thread_add_variable(), ast_sched_thread_destroy(), ast_sched_thread_poke(), ast_sched_wait(), ast_sched_when(), ast_search_dns(), ast_smdi_md_message_push(), ast_smdi_md_message_putback(), ast_smdi_mwi_message_push(), ast_smdi_mwi_message_putback(), ast_taskprocessor_push(), ast_unreplace_sigchld(), ast_wrlock_contexts(), auth_reject(), authenticate_reply(), auto_hangup(), blr_ebl(), blr_txt(), bridge_channel_join_singlethreaded(), bridge_hangup(), bridge_write(), build_device(), caldav_load_calendar(), cb_events(), cdr_handler(), check_availability(), check_beep(), cl_dequeue_chan(), cl_queue_chan(), clear_config_maps(), cli_tps_ping(), close_client(), conf_free(), conf_run(), config_device(), config_handler(), config_line(), config_load(), config_pgsql(), console_answer(), console_autoanswer(), console_dial(), console_hangup(), console_sendtext(), create_channel_name(), create_client(), csv_log(), custom_log(), dahdi_answer(), dahdi_bridge(), dahdi_call(), dahdi_cc_callback(), dahdi_channels_data_provider_get(), dahdi_destroy_channel_bynum(), dahdi_digit_begin(), dahdi_digit_end(), dahdi_exception(), dahdi_fixup(), dahdi_func_read(), dahdi_func_write(), dahdi_handle_dtmf(), dahdi_hangup(), dahdi_indicate(), dahdi_pri_error(), dahdi_pri_message(), dahdi_r2_disconnect_call(), dahdi_r2_on_call_disconnect(), dahdi_r2_on_call_end(), dahdi_r2_on_call_init(), dahdi_r2_on_call_offered(), dahdi_r2_on_hardware_alarm(), dahdi_r2_on_line_blocked(), dahdi_r2_on_line_idle(), dahdi_r2_on_protocol_error(), dahdi_request(), dahdi_restart(), dahdi_set_dnd(), dahdi_set_hwgain(), dahdi_set_swgain(), dahdi_show_channel(), dahdi_show_channels(), dahdi_softhangup_all(), dahdi_unlink(), dahdi_unlink_pri_pvt(), data_odbc_provider_handler(), db_sync_thread(), decrease_call_count(), defer_full_frame(), delete_users(), destroy_all_channels(), destroy_all_mailbox_mappings(), destroy_endpoint(), destroy_monitor_audiohook(), destroy_pgsql(), devstate_change_collector_cb(), dial_trunk(), dnsmgr_refresh(), do_cdr(), do_monitor(), do_refresh(), do_reload(), do_timing(), donodelog(), dp_lookup(), dump_cmd_queues(), dump_queue(), ewscal_load_calendar(), exchangecal_load_calendar(), find_call_locked(), find_chan_by_bc(), find_channel(), find_command(), find_engine(), find_hold_active_call(), find_hold_call(), find_hold_call_l3(), find_idle_thread(), find_subchannel_and_lock(), find_subchannel_by_name(), find_tpeer(), function_remote(), get_chan_by_ast(), get_chan_by_ast_name(), get_input(), get_lock(), gtalk_alloc(), gtalk_answer(), gtalk_digit_begin(), gtalk_digit_end(), gtalk_fixup(), gtalk_get_rtp_peer(), gtalk_hangup(), gtalk_newcall(), gtalk_read(), gtalk_ringing_ack(), gtalk_set_rtp_peer(), gtalk_show_channels(), gtalk_write(), h323_reload(), handle_capabilities_res_message(), handle_cli_core_show_config_mappings(), handle_cli_database_show(), handle_cli_database_showkey(), handle_cli_dialplan_save(), handle_cli_iax2_show_channels(), handle_cli_iax2_show_stats(), handle_cli_misdn_show_channel(), handle_cli_misdn_show_channels(), handle_cli_odbc_show(), handle_cli_osp_show(), handle_deferred_full_frames(), handle_mfcr2_call_files(), handle_mfcr2_set_blocked(), handle_mfcr2_set_debug(), handle_mfcr2_set_idle(), handle_mfcr2_show_channels(), handle_mgcp_audit_endpoint(), handle_mgcp_show_endpoints(), handle_modlist(), handle_pri_set_debug_file(), handle_register_message(), handle_request(), handle_request_do(), handle_speechrecognize(), hidthread(), iax2_answer(), iax2_bridge(), iax2_call(), iax2_do_register(), iax2_fixup(), iax2_hangup(), iax2_indicate(), iax2_key_rotate(), iax2_poke_peer(), iax2_process_thread(), iax2_queryoption(), iax2_setoption(), iax2_write(), iax_process_template(), iax_prov_complete_template(), iax_provision_build(), iax_provision_free_templates(), iax_provision_version(), iax_show_provisioning(), iax_template_parse(), ical_load_calendar(), increase_call_count(), inotify_daemon(), jingle_alloc(), jingle_answer(), jingle_digit(), jingle_fixup(), jingle_get_rtp_peer(), jingle_hangup(), jingle_newcall(), jingle_read(), jingle_set_rtp_peer(), jingle_show_channels(), jingle_write(), key_main_page(), key_select_extension(), leave_voicemail(), load_config(), load_module(), load_rpt_vars(), lock_both(), lock_broker(), lock_msg_q(), log_jitterstats(), login_exec(), lua_free_extensions(), lua_load_extensions(), lua_reload_extensions(), make_trunk(), mansession_lock(), mb_poll_thread(), mgcp_answer(), mgcp_call(), mgcp_devicestate(), mgcp_fixup(), mgcp_hangup(), mgcp_indicate(), mgcp_pktcgate_open(), mgcp_pktcgate_remove(), mgcp_postrequest(), mgcp_prune_realtime_gateway(), mgcp_read(), mgcp_reload(), mgcp_senddigit_begin(), mgcp_senddigit_end(), mgcp_write(), mgcpsock_read(), misdn_cfg_lock(), misdn_chan_is_valid(), misdn_hangup(), misdn_jb_empty(), misdn_jb_fill(), misdn_overlap_dial_task(), mixmonitor_ds_destroy(), mixmonitor_thread(), mwi_monitor_handler(), my_decrease_ss_count(), my_handle_dtmf(), my_increase_ss_count(), my_lock_private(), node_lookup(), odbc_obj_connect(), odbc_obj_disconnect(), oh323_alloc(), oh323_answer(), oh323_call(), oh323_destroy(), oh323_digit_begin(), oh323_digit_end(), oh323_fixup(), oh323_get_rtp_peer(), oh323_hangup(), oh323_indicate(), oh323_read(), oh323_request(), oh323_simulate_dtmf_end(), oh323_update_info(), oh323_write(), osp_create_transaction(), osp_get_provider(), osp_unload(), parse_config(), parsing(), peer_destructor(), pgsql_log(), phone_request(), play_sound_file(), pri_dchannel(), private_enum_init(), prune_gateways(), pthread_timer_open(), pvt_destructor(), queue_ringing_trunk(), radio_tune(), rcv_mac_addr(), realtime_destroy_handler(), realtime_handler(), realtime_ldap_base_ap(), realtime_multi_handler(), realtime_multi_pgsql(), realtime_pgsql(), realtime_store_handler(), realtime_update2_handler(), realtime_update_handler(), recordthread(), register_verify(), registry_authrequest(), release_chan(), release_chan_early(), reload(), reload_config(), reload_followme(), require_pgsql(), restart_monitor(), restart_pktc_thread(), retrans_pkt(), rpt_master(), rpt_tele_thread(), run_devstate_collector(), run_station(), save_to_folder(), sched_context_destroy(), sched_run(), schedule_calendar_event(), scheduled_destroy(), send_client(), send_command_locked(), send_lagrq(), send_ping(), send_request(), send_retransmit(), set_config(), set_pvt_defaults(), setup_dahdi_int(), sig_pri_attempt_transfer(), sig_pri_cli_show_span(), sig_pri_new_ast_channel(), signal_condition(), sip_reload(), sip_tcptls_write(), skinny_get_rtp_peer(), skinny_hangup(), skinny_read(), skinny_req_parse(), skinny_write(), sla_check_reload(), sla_destroy(), sla_handle_dial_state_event(), sla_handle_ringing_trunk_event(), sla_hangup_stations(), sla_queue_event_full(), sla_station_exec(), sla_thread(), sla_trunk_exec(), smart_bridge_operation(), socket_process(), softmix_bridge_poke(), softmix_bridge_thread(), softmix_bridge_write(), spandsp_fax_cli_show_stats(), speech_background(), sqlite_log(), ssl_lock(), start_rtp(), statpost(), stop_mixmonitor_exec(), stop_poll_thread(), store_config(), store_pgsql(), stun_monitor_request(), submit_unscheduled_batch(), syslog_log(), tds_load_module(), tds_log(), tds_unload_module(), timing_read(), tps_ping_handler(), tps_processing_function(), tps_taskprocessor_destroy(), tps_taskprocessor_pop(), transmit_frame(), transmit_response(), tune_write(), unistim_fixup(), unistim_hangup(), unistim_info(), unistim_new(), unistim_read(), unistim_register(), unistim_reload(), unistim_write(), unistimsock_read(), unload_module(), update2_ldap(), update2_pgsql(), update_ldap(), update_pgsql(), update_registry(), vm_execmain(), write_cdr(), and writefile().
#define ast_mutex_trylock | ( | a | ) | __ast_pthread_mutex_trylock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a) |
Definition at line 157 of file lock.h.
Referenced by ast_cli_perms_init(), ast_module_reload(), bridge_queue_hangup(), bridge_write(), cache_get_callno_locked(), dahdi_bridge(), dahdi_read(), dahdi_unlink(), do_monitor(), lock_both(), mgcp_prune_realtime_gateway(), pri_grab(), refresh_list(), and unload_module().
#define ast_mutex_unlock | ( | a | ) | __ast_pthread_mutex_unlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a) |
Definition at line 156 of file lock.h.
Referenced by __attempt_transmit(), __auth_reject(), __auto_congest(), __auto_hangup(), __find_callno(), __get_from_jb(), __iax2_poke_noanswer(), __oh323_destroy(), __oh323_new(), __oh323_rtp_create(), __reload(), __send_lagrq(), __send_ping(), __unload_module(), _unload_module(), acf_channel_read(), acf_jabberreceive_read(), action_agents(), add_notify(), agent_ack_sleep(), agent_call(), agent_cont_sleep(), agent_devicestate(), agent_digit_begin(), agent_digit_end(), agent_fixup(), agent_hangup(), agent_indicate(), agent_logoff(), agent_new(), agent_read(), agent_request(), agent_sendhtml(), agent_sendtext(), agent_write(), agents_data_provider_get(), agents_show(), agents_show_online(), aji_handle_message(), alsa_answer(), alsa_call(), alsa_digit(), alsa_fixup(), alsa_hangup(), alsa_indicate(), alsa_read(), alsa_request(), alsa_text(), alsa_write(), analog_ss_thread(), announce_thread(), answer_call(), answer_exec_run(), aoro2_obj_cb(), app_exec(), append_mailbox_mapping(), ast_atomic_fetchadd_int_slow(), ast_bridge_change_state(), ast_bridge_merge(), ast_cdr_detach(), ast_cdr_engine_init(), ast_cdr_submit_batch(), ast_cel_report_event(), ast_cli_netstats(), ast_cli_perms_init(), ast_config_engine_deregister(), ast_config_engine_register(), ast_context_unlockmacro(), ast_db_del(), ast_db_deltree(), ast_db_get(), ast_db_gettree(), ast_db_put(), ast_dial_join(), ast_dnsmgr_changed(), ast_get_enum(), ast_iax2_new(), ast_module_reload(), ast_monitor_start(), ast_random(), ast_replace_sigchld(), ast_sched_add_variable(), ast_sched_del(), ast_sched_dump(), ast_sched_runq(), ast_sched_thread_add(), ast_sched_thread_add_variable(), ast_sched_thread_destroy(), ast_sched_thread_poke(), ast_sched_wait(), ast_sched_when(), ast_search_dns(), ast_smdi_md_message_push(), ast_smdi_md_message_putback(), ast_smdi_mwi_message_push(), ast_smdi_mwi_message_putback(), ast_taskprocessor_push(), ast_unlock_contexts(), ast_unreplace_sigchld(), auth_reject(), authenticate_reply(), auto_hangup(), blr_ebl(), blr_txt(), bridge_channel_join_singlethreaded(), bridge_hangup(), bridge_queue_hangup(), bridge_write(), build_device(), cache_get_callno_locked(), caldav_load_calendar(), cb_events(), cdr_handler(), chan_ringing(), check_availability(), check_beep(), cl_dequeue_chan(), cl_queue_chan(), cleanup_connection(), clear_config_maps(), cli_tps_ping(), close_client(), conf_free(), conf_run(), config_device(), config_handler(), config_line(), config_load(), config_pgsql(), connection_made(), console_answer(), console_autoanswer(), console_dial(), console_hangup(), console_sendtext(), create_channel_name(), create_client(), csv_log(), custom_log(), dahdi_answer(), dahdi_bridge(), dahdi_call(), dahdi_cc_callback(), dahdi_channels_data_provider_get(), dahdi_destroy_channel_bynum(), dahdi_digit_begin(), dahdi_digit_end(), dahdi_exception(), dahdi_func_read(), dahdi_func_write(), dahdi_handle_dtmf(), dahdi_hangup(), dahdi_indicate(), dahdi_pri_error(), dahdi_pri_message(), dahdi_r2_disconnect_call(), dahdi_r2_on_call_disconnect(), dahdi_r2_on_call_end(), dahdi_r2_on_call_init(), dahdi_r2_on_call_offered(), dahdi_r2_on_hardware_alarm(), dahdi_r2_on_line_blocked(), dahdi_r2_on_line_idle(), dahdi_r2_on_protocol_error(), dahdi_read(), dahdi_request(), dahdi_set_dnd(), dahdi_set_hwgain(), dahdi_set_swgain(), dahdi_softhangup_all(), dahdi_unlink_pri_pvt(), data_odbc_provider_handler(), db_sync_thread(), decrease_call_count(), defer_full_frame(), delete_users(), destroy_all_channels(), destroy_all_mailbox_mappings(), destroy_monitor_audiohook(), destroy_pgsql(), devstate_change_collector_cb(), dial_trunk(), dnsmgr_refresh(), do_cdr(), do_monitor(), do_refresh(), do_reload(), do_timing(), donodelog(), dp_lookup(), dump_cmd_queues(), dump_queue(), ewscal_load_calendar(), exchangecal_load_calendar(), external_rtp_create(), find_cache(), find_call_locked(), find_chan_by_bc(), find_hold_active_call(), find_hold_call(), find_hold_call_l3(), find_idle_thread(), find_subchannel_and_lock(), find_subchannel_by_name(), function_remote(), get_chan_by_ast(), get_chan_by_ast_name(), get_input(), get_lock(), gtalk_alloc(), gtalk_answer(), gtalk_digit_begin(), gtalk_digit_end(), gtalk_fixup(), gtalk_get_rtp_peer(), gtalk_hangup(), gtalk_newcall(), gtalk_read(), gtalk_ringing_ack(), gtalk_set_rtp_peer(), gtalk_show_channels(), gtalk_write(), h323_reload(), handle_capabilities_res_message(), handle_cli_database_show(), handle_cli_database_showkey(), handle_cli_dialplan_save(), handle_cli_iax2_show_channels(), handle_cli_iax2_show_stats(), handle_cli_misdn_show_channels(), handle_cli_odbc_show(), handle_deferred_full_frames(), handle_modlist(), handle_pri_set_debug_file(), handle_register_message(), handle_request(), handle_request_do(), handle_speechrecognize(), hangup_connection(), hidthread(), iax2_answer(), iax2_bridge(), iax2_call(), iax2_do_register(), iax2_fixup(), iax2_hangup(), iax2_indicate(), iax2_key_rotate(), iax2_poke_peer(), iax2_process_thread(), iax2_provision(), iax2_queryoption(), iax2_request(), iax2_setoption(), iax2_trunk_queue(), iax2_write(), iax_process_template(), iax_prov_complete_template(), iax_provision_build(), iax_provision_free_templates(), iax_provision_version(), iax_show_provisioning(), iax_template_parse(), ical_load_calendar(), increase_call_count(), inotify_daemon(), jingle_alloc(), jingle_answer(), jingle_digit(), jingle_fixup(), jingle_get_rtp_peer(), jingle_hangup(), jingle_newcall(), jingle_read(), jingle_set_rtp_peer(), jingle_show_channels(), jingle_write(), key_main_page(), key_select_extension(), ldap_loadentry(), leave_voicemail(), load_config(), load_module(), load_rpt_vars(), lock_broker(), log_jitterstats(), login_exec(), lua_free_extensions(), lua_load_extensions(), lua_reload_extensions(), make_trunk(), mansession_unlock(), mb_poll_thread(), mgcp_answer(), mgcp_call(), mgcp_fixup(), mgcp_hangup(), mgcp_indicate(), mgcp_pktcgate_open(), mgcp_pktcgate_remove(), mgcp_postrequest(), mgcp_prune_realtime_gateway(), mgcp_read(), mgcp_reload(), mgcp_request(), mgcp_senddigit_begin(), mgcp_senddigit_end(), mgcp_write(), mgcpsock_read(), misdn_cfg_unlock(), misdn_chan_is_valid(), misdn_hangup(), misdn_jb_empty(), misdn_overlap_dial_task(), mixmonitor_ds_destroy(), mixmonitor_thread(), mwi_monitor_handler(), my_decrease_ss_count(), my_handle_dtmf(), my_increase_ss_count(), my_unlock_private(), node_lookup(), odbc_obj_connect(), odbc_obj_disconnect(), oh323_alloc(), oh323_answer(), oh323_call(), oh323_destroy(), oh323_digit_begin(), oh323_digit_end(), oh323_fixup(), oh323_get_rtp_peer(), oh323_hangup(), oh323_indicate(), oh323_read(), oh323_request(), oh323_simulate_dtmf_end(), oh323_update_info(), oh323_write(), osp_unload(), parse_config(), parsing(), peer_destructor(), pgsql_log(), phone_request(), play_sound_file(), pri_dchannel(), pri_rel(), private_enum_init(), progress(), pthread_timer_open(), pvt_destructor(), queue_ringing_trunk(), radio_tune(), rcv_mac_addr(), realtime_destroy_handler(), realtime_handler(), realtime_ldap_base_ap(), realtime_multi_handler(), realtime_multi_pgsql(), realtime_pgsql(), realtime_store_handler(), realtime_update2_handler(), realtime_update_handler(), receive_digit(), recordthread(), refresh_list(), register_verify(), registry_authrequest(), release_chan(), release_chan_early(), reload(), reload_config(), reload_followme(), remote_hold(), require_pgsql(), restart_monitor(), restart_pktc_thread(), retrans_pkt(), rpt_master(), rpt_tele_thread(), run_devstate_collector(), run_station(), save_to_folder(), sched_context_destroy(), sched_run(), schedule_calendar_event(), scheduled_destroy(), send_client(), send_command_locked(), send_lagrq(), send_ping(), send_request(), send_retransmit(), set_config(), set_dtmf_payload(), set_local_capabilities(), set_pvt_defaults(), setup_dahdi_int(), setup_rtp_connection(), sig_pri_attempt_transfer(), sig_pri_cli_show_span(), sig_pri_new_ast_channel(), signal_condition(), sip_reload(), sip_tcptls_write(), skinny_get_rtp_peer(), skinny_hangup(), skinny_read(), skinny_req_parse(), skinny_write(), sla_check_reload(), sla_destroy(), sla_handle_dial_state_event(), sla_handle_ringing_trunk_event(), sla_hangup_stations(), sla_queue_event_full(), sla_station_exec(), sla_thread(), sla_trunk_exec(), smart_bridge_operation(), socket_process(), socket_process_meta(), softmix_bridge_poke(), softmix_bridge_thread(), softmix_bridge_write(), spandsp_fax_cli_show_stats(), speech_background(), sqlite_log(), ssl_lock(), start_rtp(), statpost(), stop_mixmonitor_exec(), stop_poll_thread(), store_config(), store_pgsql(), stun_monitor_request(), submit_unscheduled_batch(), syslog_log(), tds_load_module(), tds_log(), tds_unload_module(), timing_read(), tps_ping_handler(), tps_processing_function(), tps_taskprocessor_destroy(), tps_taskprocessor_pop(), transmit_frame(), transmit_response(), tune_write(), unistim_fixup(), unistim_hangup(), unistim_info(), unistim_new(), unistim_read(), unistim_register(), unistim_reload(), unistim_write(), unistimsock_read(), unload_module(), unlock_both(), unlock_msg_q(), update2_ldap(), update2_pgsql(), update_ldap(), update_pgsql(), update_registry(), vm_execmain(), write_cdr(), and writefile().
#define AST_PTHREADT_NULL (pthread_t) -1 |
Definition at line 65 of file lock.h.
Referenced by __ast_manager_event_multichan(), __ast_rwlock_unlock(), __sip_reliable_xmit(), __unload_module(), _unload_module(), action_waitevent(), add_notify(), ast_autoservice_start(), ast_autoservice_stop(), ast_bridge_new(), ast_cdr_submit_batch(), ast_dial_create(), ast_dial_join(), ast_localtime_wakeup_monitor(), ast_log(), ast_safe_fork(), ast_sched_thread_create(), ast_sched_thread_destroy(), ast_smdi_interface_destroy(), ast_taskprocessor_get(), ast_tcptls_server_start(), ast_tcptls_server_stop(), bridge_channel_join(), bridge_poke(), bridge_thread(), build_conf(), build_mansession(), calendar_event_notify(), close_logger(), conf_free(), conf_run(), console_verboser(), dahdi_r2_destroy_links(), dahdi_r2_get_link(), dahdi_restart(), do_reload(), init_pvt(), inotify_daemon(), load_config(), load_rpt_vars(), moh_class_destructor(), multiplexed_add_or_remove(), multiplexed_bridge_create(), multiplexed_nudge(), multiplexed_thread_function(), network_thread(), process_precache(), quit_handler(), restart_monitor(), restart_pktc_thread(), rpt_master(), sig_pri_init_pri(), sla_destroy(), sla_load_config(), sla_queue_event_full(), smart_bridge_operation(), stop_poll_thread(), stop_stream(), tps_taskprocessor_destroy(), and unload_module().
#define AST_PTHREADT_STOP (pthread_t) -2 |
Definition at line 66 of file lock.h.
Referenced by __unload_module(), answer_exec_run(), ast_bridge_merge(), ast_dial_join(), ast_smdi_interface_destroy(), bridge_poke(), monitor_dial(), multiplexed_thread_function(), restart_monitor(), restart_pktc_thread(), rpt(), rpt_master(), and unload_module().
#define AST_RWLOCK_DEFINE_STATIC | ( | rwlock | ) | __AST_RWLOCK_DEFINE(static, rwlock, AST_RWLOCK_INIT_VALUE, 1) |
#define AST_RWLOCK_DEFINE_STATIC_NOTRACKING | ( | rwlock | ) | __AST_RWLOCK_DEFINE(static, rwlock, AST_RWLOCK_INIT_VALUE_NOTRACKING, 0) |
#define ast_rwlock_destroy | ( | rwlock | ) | __ast_rwlock_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, #rwlock, rwlock) |
Definition at line 199 of file lock.h.
Referenced by __ast_internal_context_destroy(), ast_hashtab_destroy(), ast_hashtab_destroylock(), ast_heap_destroy(), and destroy_table().
#define ast_rwlock_init | ( | rwlock | ) | __ast_rwlock_init(1, __FILE__, __LINE__, __PRETTY_FUNCTION__, #rwlock, rwlock) |
wrapper for rwlock with tracking enabled
Definition at line 190 of file lock.h.
Referenced by ast_context_find_or_create(), ast_data_init(), ast_hashtab_create(), ast_hashtab_dup(), ast_hashtab_initlock(), ast_heap_create(), and find_table().
#define ast_rwlock_init_notracking | ( | rwlock | ) | __ast_rwlock_init(0, __FILE__, __LINE__, __PRETTY_FUNCTION__, #rwlock, rwlock) |
#define AST_RWLOCK_INIT_VALUE { __AST_RWLOCK_INIT_VALUE, NULL, 1 } |
#define AST_RWLOCK_INIT_VALUE_NOTRACKING { __AST_RWLOCK_INIT_VALUE, NULL, 0 } |
#define ast_rwlock_rdlock | ( | a | ) | __ast_rwlock_rdlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a) |
Definition at line 201 of file lock.h.
Referenced by ast_calendar_config_acquire(), ast_hashtab_get_stats(), ast_hashtab_lookup(), ast_hashtab_lookup_with_hash(), ast_hashtab_rdlock(), ast_hashtab_start_traversal(), ast_rdlock_call_features(), ast_rdlock_context(), ast_str_retrieve_variable(), feature_interpret_helper(), feature_request_and_dial(), find_table(), get_active_pvt(), handle_feature_show(), handle_show_globals(), manager_log(), pbx_builtin_getvar_helper(), and set_config_flags().
#define ast_rwlock_timedrdlock | ( | a, | |||
b | ) | __ast_rwlock_timedrdlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a, b) |
#define ast_rwlock_timedwrlock | ( | a, | |||
b | ) | __ast_rwlock_timedwrlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a, b) |
#define ast_rwlock_tryrdlock | ( | a | ) | __ast_rwlock_tryrdlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a) |
#define ast_rwlock_trywrlock | ( | a | ) | __ast_rwlock_trywrlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a) |
#define ast_rwlock_unlock | ( | a | ) | __ast_rwlock_unlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a) |
Definition at line 200 of file lock.h.
Referenced by ast_calendar_config_acquire(), ast_calendar_config_release(), ast_hashtab_destroy(), ast_hashtab_end_traversal(), ast_hashtab_get_stats(), ast_hashtab_insert_immediate(), ast_hashtab_insert_safe(), ast_hashtab_lookup(), ast_hashtab_lookup_with_hash(), ast_hashtab_remove_object_via_lookup(), ast_hashtab_remove_this_object(), ast_hashtab_unlock(), ast_str_retrieve_variable(), ast_unlock_call_features(), ast_unlock_context(), destroy_pvts(), destroy_table(), feature_interpret_helper(), feature_request_and_dial(), get_active_pvt(), handle_feature_show(), handle_show_globals(), load_config(), load_tech_calendars(), manager_log(), pbx_builtin_clear_globals(), pbx_builtin_getvar_helper(), pbx_builtin_pushvar_helper(), pbx_builtin_setvar_helper(), remap_feature(), set_active(), set_config_flags(), and unmap_features().
#define ast_rwlock_wrlock | ( | a | ) | __ast_rwlock_wrlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, #a) |
Definition at line 202 of file lock.h.
Referenced by ast_hashtab_destroy(), ast_hashtab_insert_immediate(), ast_hashtab_insert_safe(), ast_hashtab_remove_object_via_lookup(), ast_hashtab_remove_this_object(), ast_hashtab_start_write_traversal(), ast_hashtab_wrlock(), ast_wrlock_context(), destroy_pvts(), destroy_table(), load_config(), load_tech_calendars(), pbx_builtin_clear_globals(), pbx_builtin_pushvar_helper(), pbx_builtin_setvar_helper(), remap_feature(), set_active(), and unmap_features().
#define CHANNEL_DEADLOCK_AVOIDANCE | ( | chan | ) |
Unlock a lock briefly.
used during deadlock avoidance, to preserve the original location where a lock was originally acquired.
Definition at line 338 of file lock.h.
Referenced by ast_call_forward(), ast_do_masquerade(), bridge_queue_hangup(), bridge_write(), dahdi_bridge(), dahdi_handle_event(), dahdi_read(), dial_exec_full(), do_forward(), local_queue_frame(), manager_park(), misdn_attempt_transfer(), ring_entry(), and sip_hangup().
#define DEADLOCK_AVOIDANCE | ( | lock | ) |
Definition at line 360 of file lock.h.
Referenced by agent_logoff(), agent_read(), dahdi_queue_frame(), dahdi_unlink(), grab_owner(), iax2_destroy(), iax2_lock_owner(), lock_both(), mgcp_queue_frame(), mgcp_queue_hangup(), my_deadlock_avoidance_private(), oh323_simulate_dtmf_end(), release_chan(), release_chan_early(), and wait_for_peercallno().
#define DLA_LOCK | ( | lock | ) |
Deadlock avoidance lock.
In certain deadlock avoidance scenarios, there is more than one lock to be unlocked and relocked. Therefore, this pair of macros is provided for that purpose. Note that every DLA_UNLOCK _MUST_ be paired with a matching DLA_LOCK. The intent of this pair of macros is to be used around another set of deadlock avoidance code, mainly CHANNEL_DEADLOCK_AVOIDANCE, as the locking order specifies that we may safely lock a channel, followed by its pvt, with no worries about a deadlock. In any other scenario, this macro may not be safe to use.
Definition at line 413 of file lock.h.
Referenced by dahdi_handle_event().
#define DLA_UNLOCK | ( | lock | ) |
Value:
do { \ char __filename[80], __func[80], __mutex_name[80]; \ int __lineno; \ int __res = ast_find_lock_info(lock, __filename, sizeof(__filename), &__lineno, __func, sizeof(__func), __mutex_name, sizeof(__mutex_name)); \ int __res2 = ast_mutex_unlock(lock);
In certain deadlock avoidance scenarios, there is more than one lock to be unlocked and relocked. Therefore, this pair of macros is provided for that purpose. Note that every DLA_UNLOCK _MUST_ be paired with a matching DLA_LOCK. The intent of this pair of macros is to be used around another set of deadlock avoidance code, mainly CHANNEL_DEADLOCK_AVOIDANCE, as the locking order specifies that we may safely lock a channel, followed by its pvt, with no worries about a deadlock. In any other scenario, this macro may not be safe to use.
Definition at line 394 of file lock.h.
Referenced by dahdi_handle_event().
#define DO_THREAD_CRASH do { } while (0) |
Definition at line 217 of file lock.h.
Referenced by __ast_cond_timedwait(), __ast_cond_wait(), __ast_pthread_mutex_lock(), __ast_pthread_mutex_unlock(), __ast_rwlock_rdlock(), __ast_rwlock_unlock(), and __ast_rwlock_wrlock().
#define gethostbyname __gethostbyname__is__not__reentrant__use__ast_gethostbyname__instead__ |
#define pthread_cond_broadcast use_ast_cond_broadcast_instead_of_pthread_cond_broadcast |
#define pthread_cond_destroy use_ast_cond_destroy_instead_of_pthread_cond_destroy |
#define pthread_cond_init use_ast_cond_init_instead_of_pthread_cond_init |
#define pthread_cond_signal use_ast_cond_signal_instead_of_pthread_cond_signal |
#define pthread_cond_t use_ast_cond_t_instead_of_pthread_cond_t |
#define pthread_cond_timedwait use_ast_cond_timedwait_instead_of_pthread_cond_timedwait |
#define pthread_cond_wait use_ast_cond_wait_instead_of_pthread_cond_wait |
#define pthread_create __use_ast_pthread_create_instead__ |
Definition at line 573 of file lock.h.
Referenced by ast_pthread_create_stack(), misdn_lib_init(), and misdn_tasks_init().
#define pthread_mutex_destroy use_ast_mutex_destroy_instead_of_pthread_mutex_destroy |
Definition at line 560 of file lock.h.
Referenced by __ast_pthread_mutex_destroy(), delete_reentrancy_cs(), and stack_destroy().
#define pthread_mutex_init use_ast_mutex_init_instead_of_pthread_mutex_init |
Definition at line 559 of file lock.h.
Referenced by __ast_pthread_mutex_init(), ast_reentrancy_init(), dummy_start(), init_bc(), and stack_init().
#define PTHREAD_MUTEX_INIT_VALUE PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP |
#define pthread_mutex_lock use_ast_mutex_lock_instead_of_pthread_mutex_lock |
Definition at line 556 of file lock.h.
Referenced by __ast_pthread_mutex_lock(), ast_find_lock_info(), ast_mark_lock_acquired(), ast_mark_lock_failed(), ast_reentrancy_lock(), ast_remove_lock_info(), ast_store_lock_info(), dummy_start(), find_free_chan_in_stack(), handle_event_nt(), handle_frm_nt(), handle_l1(), handle_show_locks(), handle_timers(), lock_info_destroy(), log_show_lock(), manager_event_handler(), misdn_lib_get_free_bc(), misdn_lib_get_l2_down(), misdn_lib_get_l2_up(), and misdn_send_lock().
#define pthread_mutex_t use_ast_mutex_t_instead_of_pthread_mutex_t |
Definition at line 553 of file lock.h.
Referenced by __ast_cond_timedwait(), __ast_cond_wait(), __ast_pthread_mutex_destroy(), __ast_pthread_mutex_init(), __ast_pthread_mutex_lock(), __ast_pthread_mutex_trylock(), and __ast_pthread_mutex_unlock().
#define pthread_mutex_trylock use_ast_mutex_trylock_instead_of_pthread_mutex_trylock |
Definition at line 558 of file lock.h.
Referenced by __ast_pthread_mutex_destroy(), __ast_pthread_mutex_lock(), and __ast_pthread_mutex_trylock().
#define pthread_mutex_unlock use_ast_mutex_unlock_instead_of_pthread_mutex_unlock |
Definition at line 557 of file lock.h.
Referenced by __ast_pthread_mutex_destroy(), __ast_pthread_mutex_unlock(), ast_find_lock_info(), ast_mark_lock_acquired(), ast_mark_lock_failed(), ast_reentrancy_unlock(), ast_remove_lock_info(), ast_store_lock_info(), dummy_start(), handle_event_nt(), handle_frm_nt(), handle_l1(), handle_show_locks(), handle_timers(), lock_info_destroy(), log_show_lock(), manager_event_handler(), misdn_lib_get_free_bc(), misdn_lib_get_l2_down(), misdn_lib_get_l2_up(), and misdn_send_unlock().
#define ROFFSET ((lt->reentrancy > 0) ? (lt->reentrancy-1) : 0) |
Definition at line 208 of file lock.h.
Referenced by __ast_cond_timedwait(), __ast_cond_wait(), __ast_pthread_mutex_destroy(), __ast_pthread_mutex_lock(), and __ast_pthread_mutex_unlock().
typedef pthread_cond_t ast_cond_t |
typedef struct ast_mutex_info ast_mutex_t |
typedef struct ast_rwlock_info ast_rwlock_t |
enum ast_lock_type |
Definition at line 222 of file lock.h.
00222 { 00223 AST_MUTEX, 00224 AST_RDLOCK, 00225 AST_WRLOCK, 00226 };
int __ast_cond_broadcast | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
const char * | cond_name, | |||
ast_cond_t * | cond | |||
) |
Definition at line 459 of file lock.c.
References pthread_cond_broadcast.
00461 { 00462 return pthread_cond_broadcast(cond); 00463 }
int __ast_cond_destroy | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
const char * | cond_name, | |||
ast_cond_t * | cond | |||
) |
Definition at line 465 of file lock.c.
References pthread_cond_destroy.
00467 { 00468 return pthread_cond_destroy(cond); 00469 }
int __ast_cond_init | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
const char * | cond_name, | |||
ast_cond_t * | cond, | |||
pthread_condattr_t * | cond_attr | |||
) |
Definition at line 447 of file lock.c.
References pthread_cond_init.
00449 { 00450 return pthread_cond_init(cond, cond_attr); 00451 }
int __ast_cond_signal | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
const char * | cond_name, | |||
ast_cond_t * | cond | |||
) |
Definition at line 453 of file lock.c.
References pthread_cond_signal.
00455 { 00456 return pthread_cond_signal(cond); 00457 }
int __ast_cond_timedwait | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
const char * | cond_name, | |||
const char * | mutex_name, | |||
ast_cond_t * | cond, | |||
ast_mutex_t * | t, | |||
const struct timespec * | abstime | |||
) |
Definition at line 579 of file lock.c.
References __ast_mutex_logger, __ast_pthread_mutex_init(), __dump_backtrace(), ast_bt_get_addresses(), AST_MAX_REENTRANCY, AST_MUTEX, ast_reentrancy_init(), ast_reentrancy_lock(), ast_reentrancy_unlock(), ast_remove_lock_info(), ast_store_lock_info(), ast_lock_track::backtrace, DO_THREAD_CRASH, ast_lock_track::file, ast_lock_track::func, ast_lock_track::lineno, ast_mutex_info::mutex, pthread_cond_timedwait, pthread_mutex_t, ast_lock_track::reentrancy, ROFFSET, ast_lock_track::thread, ast_mutex_info::track, and ast_mutex_info::tracking.
00582 { 00583 int res; 00584 00585 #ifdef DEBUG_THREADS 00586 struct ast_lock_track *lt; 00587 int canlog = strcmp(filename, "logger.c") & t->tracking; 00588 #ifdef HAVE_BKTR 00589 struct ast_bt *bt = NULL; 00590 #endif 00591 00592 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00593 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00594 __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n", 00595 filename, lineno, func, mutex_name); 00596 res = __ast_pthread_mutex_init(t->tracking, filename, lineno, func, mutex_name, t); 00597 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00598 __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n", 00599 filename, lineno, func, mutex_name); 00600 } 00601 return res; 00602 } 00603 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00604 00605 if (t->tracking && !t->track) { 00606 ast_reentrancy_init(&t->track); 00607 } 00608 lt = t->track; 00609 00610 if (t->tracking) { 00611 ast_reentrancy_lock(lt); 00612 if (lt->reentrancy && (lt->thread[ROFFSET] != pthread_self())) { 00613 __ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n", 00614 filename, lineno, func, mutex_name); 00615 __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n", 00616 lt->file[ROFFSET], lt->lineno[ROFFSET], lt->func[ROFFSET], mutex_name); 00617 #ifdef HAVE_BKTR 00618 __dump_backtrace(<->backtrace[ROFFSET], canlog); 00619 #endif 00620 DO_THREAD_CRASH; 00621 } 00622 00623 if (--lt->reentrancy < 0) { 00624 __ast_mutex_logger("%s line %d (%s): mutex '%s' freed more times than we've locked!\n", 00625 filename, lineno, func, mutex_name); 00626 lt->reentrancy = 0; 00627 } 00628 00629 if (lt->reentrancy < AST_MAX_REENTRANCY) { 00630 lt->file[lt->reentrancy] = NULL; 00631 lt->lineno[lt->reentrancy] = 0; 00632 lt->func[lt->reentrancy] = NULL; 00633 lt->thread[lt->reentrancy] = 0; 00634 } 00635 #ifdef HAVE_BKTR 00636 if (lt->reentrancy) { 00637 bt = <->backtrace[lt->reentrancy - 1]; 00638 } 00639 #endif 00640 ast_reentrancy_unlock(lt); 00641 00642 #ifdef HAVE_BKTR 00643 ast_remove_lock_info(t, bt); 00644 #else 00645 ast_remove_lock_info(t); 00646 #endif 00647 } 00648 #endif /* DEBUG_THREADS */ 00649 00650 res = pthread_cond_timedwait(cond, &t->mutex, abstime); 00651 00652 #ifdef DEBUG_THREADS 00653 if (res && (res != ETIMEDOUT)) { 00654 __ast_mutex_logger("%s line %d (%s): Error waiting on condition mutex '%s'\n", 00655 filename, lineno, func, strerror(res)); 00656 DO_THREAD_CRASH; 00657 } else if (t->tracking) { 00658 ast_reentrancy_lock(lt); 00659 if (lt->reentrancy < AST_MAX_REENTRANCY) { 00660 lt->file[lt->reentrancy] = filename; 00661 lt->lineno[lt->reentrancy] = lineno; 00662 lt->func[lt->reentrancy] = func; 00663 lt->thread[lt->reentrancy] = pthread_self(); 00664 #ifdef HAVE_BKTR 00665 ast_bt_get_addresses(<->backtrace[lt->reentrancy]); 00666 bt = <->backtrace[lt->reentrancy]; 00667 #endif 00668 lt->reentrancy++; 00669 } else { 00670 __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n", 00671 filename, lineno, func, mutex_name); 00672 } 00673 ast_reentrancy_unlock(lt); 00674 00675 #ifdef HAVE_BKTR 00676 ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t, bt); 00677 #else 00678 ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t); 00679 #endif 00680 } 00681 #endif /* DEBUG_THREADS */ 00682 00683 return res; 00684 }
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 | |||
) |
Definition at line 471 of file lock.c.
References __ast_mutex_logger, __ast_pthread_mutex_init(), __dump_backtrace(), ast_bt_get_addresses(), AST_MAX_REENTRANCY, AST_MUTEX, ast_reentrancy_init(), ast_reentrancy_lock(), ast_reentrancy_unlock(), ast_remove_lock_info(), ast_store_lock_info(), ast_lock_track::backtrace, DO_THREAD_CRASH, ast_lock_track::file, ast_lock_track::func, ast_lock_track::lineno, ast_mutex_info::mutex, pthread_cond_wait, pthread_mutex_t, ast_lock_track::reentrancy, ROFFSET, ast_lock_track::thread, ast_mutex_info::track, and ast_mutex_info::tracking.
00474 { 00475 int res; 00476 00477 #ifdef DEBUG_THREADS 00478 struct ast_lock_track *lt; 00479 int canlog = strcmp(filename, "logger.c") & t->tracking; 00480 #ifdef HAVE_BKTR 00481 struct ast_bt *bt = NULL; 00482 #endif 00483 00484 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00485 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00486 __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n", 00487 filename, lineno, func, mutex_name); 00488 res = __ast_pthread_mutex_init(t->tracking, filename, lineno, func, mutex_name, t); 00489 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00490 __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n", 00491 filename, lineno, func, mutex_name); 00492 } 00493 return res; 00494 } 00495 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00496 00497 if (t->tracking && !t->track) { 00498 ast_reentrancy_init(&t->track); 00499 } 00500 lt = t->track; 00501 00502 if (t->tracking) { 00503 ast_reentrancy_lock(lt); 00504 if (lt->reentrancy && (lt->thread[ROFFSET] != pthread_self())) { 00505 __ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n", 00506 filename, lineno, func, mutex_name); 00507 __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n", 00508 lt->file[ROFFSET], lt->lineno[ROFFSET], lt->func[ROFFSET], mutex_name); 00509 #ifdef HAVE_BKTR 00510 __dump_backtrace(<->backtrace[ROFFSET], canlog); 00511 #endif 00512 DO_THREAD_CRASH; 00513 } 00514 00515 if (--lt->reentrancy < 0) { 00516 __ast_mutex_logger("%s line %d (%s): mutex '%s' freed more times than we've locked!\n", 00517 filename, lineno, func, mutex_name); 00518 lt->reentrancy = 0; 00519 } 00520 00521 if (lt->reentrancy < AST_MAX_REENTRANCY) { 00522 lt->file[lt->reentrancy] = NULL; 00523 lt->lineno[lt->reentrancy] = 0; 00524 lt->func[lt->reentrancy] = NULL; 00525 lt->thread[lt->reentrancy] = 0; 00526 } 00527 00528 #ifdef HAVE_BKTR 00529 if (lt->reentrancy) { 00530 bt = <->backtrace[lt->reentrancy - 1]; 00531 } 00532 #endif 00533 ast_reentrancy_unlock(lt); 00534 00535 #ifdef HAVE_BKTR 00536 ast_remove_lock_info(t, bt); 00537 #else 00538 ast_remove_lock_info(t); 00539 #endif 00540 } 00541 #endif /* DEBUG_THREADS */ 00542 00543 res = pthread_cond_wait(cond, &t->mutex); 00544 00545 #ifdef DEBUG_THREADS 00546 if (res) { 00547 __ast_mutex_logger("%s line %d (%s): Error waiting on condition mutex '%s'\n", 00548 filename, lineno, func, strerror(res)); 00549 DO_THREAD_CRASH; 00550 } else if (t->tracking) { 00551 ast_reentrancy_lock(lt); 00552 if (lt->reentrancy < AST_MAX_REENTRANCY) { 00553 lt->file[lt->reentrancy] = filename; 00554 lt->lineno[lt->reentrancy] = lineno; 00555 lt->func[lt->reentrancy] = func; 00556 lt->thread[lt->reentrancy] = pthread_self(); 00557 #ifdef HAVE_BKTR 00558 ast_bt_get_addresses(<->backtrace[lt->reentrancy]); 00559 bt = <->backtrace[lt->reentrancy]; 00560 #endif 00561 lt->reentrancy++; 00562 } else { 00563 __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n", 00564 filename, lineno, func, mutex_name); 00565 } 00566 ast_reentrancy_unlock(lt); 00567 00568 #ifdef HAVE_BKTR 00569 ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t, bt); 00570 #else 00571 ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t); 00572 #endif 00573 } 00574 #endif /* DEBUG_THREADS */ 00575 00576 return res; 00577 }
int __ast_pthread_mutex_destroy | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
const char * | mutex_name, | |||
ast_mutex_t * | t | |||
) |
Definition at line 78 of file lock.c.
References __ast_mutex_logger, __dump_backtrace(), ast_reentrancy_init(), ast_reentrancy_lock(), ast_reentrancy_unlock(), ast_lock_track::backtrace, delete_reentrancy_cs(), ast_lock_track::file, ast_lock_track::func, ast_lock_track::lineno, ast_mutex_info::mutex, pthread_mutex_destroy, pthread_mutex_t, pthread_mutex_trylock, pthread_mutex_unlock, ast_lock_track::reentrancy, ROFFSET, ast_lock_track::thread, ast_mutex_info::track, and ast_mutex_info::tracking.
00080 { 00081 int res; 00082 00083 #ifdef DEBUG_THREADS 00084 struct ast_lock_track *lt; 00085 int canlog = strcmp(filename, "logger.c") & t->tracking; 00086 00087 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00088 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00089 /* Don't try to uninitialize non initialized mutex 00090 * This may no effect on linux 00091 * And always ganerate core on *BSD with 00092 * linked libpthread 00093 * This not error condition if the mutex created on the fly. 00094 */ 00095 __ast_mutex_logger("%s line %d (%s): NOTICE: mutex '%s' is uninitialized.\n", 00096 filename, lineno, func, mutex_name); 00097 return 0; 00098 } 00099 #endif 00100 00101 if (t->tracking && !t->track) { 00102 ast_reentrancy_init(&t->track); 00103 } 00104 lt = t->track; 00105 00106 res = pthread_mutex_trylock(&t->mutex); 00107 switch (res) { 00108 case 0: 00109 pthread_mutex_unlock(&t->mutex); 00110 break; 00111 case EINVAL: 00112 __ast_mutex_logger("%s line %d (%s): Error: attempt to destroy invalid mutex '%s'.\n", 00113 filename, lineno, func, mutex_name); 00114 break; 00115 case EBUSY: 00116 __ast_mutex_logger("%s line %d (%s): Error: attempt to destroy locked mutex '%s'.\n", 00117 filename, lineno, func, mutex_name); 00118 if (t->tracking) { 00119 ast_reentrancy_lock(lt); 00120 __ast_mutex_logger("%s line %d (%s): Error: '%s' was locked here.\n", 00121 lt->file[ROFFSET], lt->lineno[ROFFSET], lt->func[ROFFSET], mutex_name); 00122 #ifdef HAVE_BKTR 00123 __dump_backtrace(<->backtrace[ROFFSET], canlog); 00124 #endif 00125 ast_reentrancy_unlock(lt); 00126 } 00127 break; 00128 } 00129 #endif /* DEBUG_THREADS */ 00130 00131 res = pthread_mutex_destroy(&t->mutex); 00132 00133 #ifdef DEBUG_THREADS 00134 if (res) { 00135 __ast_mutex_logger("%s line %d (%s): Error destroying mutex %s: %s\n", 00136 filename, lineno, func, mutex_name, strerror(res)); 00137 } 00138 if (t->tracking) { 00139 ast_reentrancy_lock(lt); 00140 lt->file[0] = filename; 00141 lt->lineno[0] = lineno; 00142 lt->func[0] = func; 00143 lt->reentrancy = 0; 00144 lt->thread[0] = 0; 00145 #ifdef HAVE_BKTR 00146 memset(<->backtrace[0], 0, sizeof(lt->backtrace[0])); 00147 #endif 00148 ast_reentrancy_unlock(lt); 00149 delete_reentrancy_cs(&t->track); 00150 } 00151 #endif /* DEBUG_THREADS */ 00152 00153 return res; 00154 }
int __ast_pthread_mutex_init | ( | int | tracking, | |
const char * | filename, | |||
int | lineno, | |||
const char * | func, | |||
const char * | mutex_name, | |||
ast_mutex_t * | t | |||
) |
Definition at line 44 of file lock.c.
References AST_MUTEX_KIND, ast_reentrancy_init(), ast_mutex_info::mutex, pthread_mutex_init, pthread_mutex_t, ast_mutex_info::track, and ast_mutex_info::tracking.
Referenced by __ast_cond_timedwait(), __ast_cond_wait(), __ast_pthread_mutex_lock(), __ast_pthread_mutex_trylock(), and __ast_pthread_mutex_unlock().
00046 { 00047 int res; 00048 pthread_mutexattr_t attr; 00049 00050 t->track = NULL; 00051 #ifdef DEBUG_THREADS 00052 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00053 if ((t->mutex) != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00054 /* 00055 int canlog = strcmp(filename, "logger.c") & track; 00056 __ast_mutex_logger("%s line %d (%s): NOTICE: mutex '%s' is already initialized.\n", 00057 filename, lineno, func, mutex_name); 00058 DO_THREAD_CRASH; 00059 */ 00060 return 0; 00061 } 00062 00063 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00064 00065 if ((t->tracking = tracking)) { 00066 ast_reentrancy_init(&t->track); 00067 } 00068 #endif /* DEBUG_THREADS */ 00069 00070 pthread_mutexattr_init(&attr); 00071 pthread_mutexattr_settype(&attr, AST_MUTEX_KIND); 00072 00073 res = pthread_mutex_init(&t->mutex, &attr); 00074 pthread_mutexattr_destroy(&attr); 00075 return res; 00076 }
int __ast_pthread_mutex_lock | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
const char * | mutex_name, | |||
ast_mutex_t * | t | |||
) |
Definition at line 156 of file lock.c.
References __ast_mutex_logger, __ast_pthread_mutex_init(), __dump_backtrace(), ast_bt_get_addresses(), ast_mark(), ast_mark_lock_acquired(), AST_MAX_REENTRANCY, AST_MUTEX, ast_reentrancy_init(), ast_reentrancy_lock(), ast_reentrancy_unlock(), ast_remove_lock_info(), ast_store_lock_info(), ast_lock_track::backtrace, DO_THREAD_CRASH, ast_lock_track::file, ast_lock_track::func, ast_lock_track::lineno, ast_mutex_info::mutex, pthread_mutex_lock, pthread_mutex_t, pthread_mutex_trylock, ast_lock_track::reentrancy, ROFFSET, ast_mutex_info::track, and ast_mutex_info::tracking.
Referenced by __ao2_lock().
00158 { 00159 int res; 00160 00161 #ifdef DEBUG_THREADS 00162 struct ast_lock_track *lt; 00163 int canlog = strcmp(filename, "logger.c") & t->tracking; 00164 #ifdef HAVE_BKTR 00165 struct ast_bt *bt = NULL; 00166 #endif 00167 00168 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00169 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00170 /* Don't warn abount uninitialized mutex. 00171 * Simple try to initialize it. 00172 * May be not needed in linux system. 00173 */ 00174 res = __ast_pthread_mutex_init(t->tracking, filename, lineno, func, mutex_name, t); 00175 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00176 __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n", 00177 filename, lineno, func, mutex_name); 00178 return res; 00179 } 00180 } 00181 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00182 00183 if (t->tracking && !t->track) { 00184 ast_reentrancy_init(&t->track); 00185 } 00186 lt = t->track; 00187 00188 if (t->tracking) { 00189 #ifdef HAVE_BKTR 00190 ast_reentrancy_lock(lt); 00191 if (lt->reentrancy != AST_MAX_REENTRANCY) { 00192 ast_bt_get_addresses(<->backtrace[lt->reentrancy]); 00193 bt = <->backtrace[lt->reentrancy]; 00194 } 00195 ast_reentrancy_unlock(lt); 00196 ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t, bt); 00197 #else 00198 ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t); 00199 #endif 00200 } 00201 #endif /* DEBUG_THREADS */ 00202 00203 #if defined(DETECT_DEADLOCKS) && defined(DEBUG_THREADS) 00204 { 00205 time_t seconds = time(NULL); 00206 time_t wait_time, reported_wait = 0; 00207 do { 00208 #ifdef HAVE_MTX_PROFILE 00209 ast_mark(mtx_prof, 1); 00210 #endif 00211 res = pthread_mutex_trylock(&t->mutex); 00212 #ifdef HAVE_MTX_PROFILE 00213 ast_mark(mtx_prof, 0); 00214 #endif 00215 if (res == EBUSY) { 00216 wait_time = time(NULL) - seconds; 00217 if (wait_time > reported_wait && (wait_time % 5) == 0) { 00218 __ast_mutex_logger("%s line %d (%s): Deadlock? waited %d sec for mutex '%s'?\n", 00219 filename, lineno, func, (int) wait_time, mutex_name); 00220 ast_reentrancy_lock(lt); 00221 #ifdef HAVE_BKTR 00222 __dump_backtrace(<->backtrace[lt->reentrancy], canlog); 00223 #endif 00224 __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n", 00225 lt->file[ROFFSET], lt->lineno[ROFFSET], 00226 lt->func[ROFFSET], mutex_name); 00227 #ifdef HAVE_BKTR 00228 __dump_backtrace(<->backtrace[ROFFSET], canlog); 00229 #endif 00230 ast_reentrancy_unlock(lt); 00231 reported_wait = wait_time; 00232 } 00233 usleep(200); 00234 } 00235 } while (res == EBUSY); 00236 } 00237 #else /* !DETECT_DEADLOCKS || !DEBUG_THREADS */ 00238 #ifdef HAVE_MTX_PROFILE 00239 ast_mark(mtx_prof, 1); 00240 res = pthread_mutex_trylock(&t->mutex); 00241 ast_mark(mtx_prof, 0); 00242 if (res) 00243 #endif 00244 res = pthread_mutex_lock(&t->mutex); 00245 #endif /* !DETECT_DEADLOCKS || !DEBUG_THREADS */ 00246 00247 #ifdef DEBUG_THREADS 00248 if (t->tracking && !res) { 00249 ast_reentrancy_lock(lt); 00250 if (lt->reentrancy < AST_MAX_REENTRANCY) { 00251 lt->file[lt->reentrancy] = filename; 00252 lt->lineno[lt->reentrancy] = lineno; 00253 lt->func[lt->reentrancy] = func; 00254 lt->thread[lt->reentrancy] = pthread_self(); 00255 lt->reentrancy++; 00256 } else { 00257 __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n", 00258 filename, lineno, func, mutex_name); 00259 } 00260 ast_reentrancy_unlock(lt); 00261 if (t->tracking) { 00262 ast_mark_lock_acquired(t); 00263 } 00264 } else if (t->tracking) { 00265 #ifdef HAVE_BKTR 00266 if (lt->reentrancy) { 00267 ast_reentrancy_lock(lt); 00268 bt = <->backtrace[lt->reentrancy-1]; 00269 ast_reentrancy_unlock(lt); 00270 } else { 00271 bt = NULL; 00272 } 00273 ast_remove_lock_info(t, bt); 00274 #else 00275 ast_remove_lock_info(t); 00276 #endif 00277 } 00278 if (res) { 00279 __ast_mutex_logger("%s line %d (%s): Error obtaining mutex: %s\n", 00280 filename, lineno, func, strerror(res)); 00281 DO_THREAD_CRASH; 00282 } 00283 #endif /* DEBUG_THREADS */ 00284 00285 return res; 00286 }
int __ast_pthread_mutex_trylock | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
const char * | mutex_name, | |||
ast_mutex_t * | t | |||
) |
Definition at line 288 of file lock.c.
References __ast_mutex_logger, __ast_pthread_mutex_init(), ast_bt_get_addresses(), ast_mark_lock_acquired(), ast_mark_lock_failed(), AST_MAX_REENTRANCY, AST_MUTEX, ast_reentrancy_init(), ast_reentrancy_lock(), ast_reentrancy_unlock(), ast_store_lock_info(), ast_lock_track::backtrace, ast_mutex_info::mutex, pthread_mutex_t, pthread_mutex_trylock, ast_lock_track::reentrancy, ast_mutex_info::track, and ast_mutex_info::tracking.
Referenced by __ao2_trylock().
00290 { 00291 int res; 00292 00293 #ifdef DEBUG_THREADS 00294 struct ast_lock_track *lt; 00295 int canlog = strcmp(filename, "logger.c") & t->tracking; 00296 #ifdef HAVE_BKTR 00297 struct ast_bt *bt = NULL; 00298 #endif 00299 00300 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00301 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00302 /* Don't warn abount uninitialized mutex. 00303 * Simple try to initialize it. 00304 * May be not needed in linux system. 00305 */ 00306 res = __ast_pthread_mutex_init(t->tracking, filename, lineno, func, mutex_name, t); 00307 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00308 __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n", 00309 filename, lineno, func, mutex_name); 00310 return res; 00311 } 00312 } 00313 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00314 00315 if (t->tracking && !t->track) { 00316 ast_reentrancy_init(&t->track); 00317 } 00318 lt = t->track; 00319 00320 if (t->tracking) { 00321 #ifdef HAVE_BKTR 00322 ast_reentrancy_lock(lt); 00323 if (lt->reentrancy != AST_MAX_REENTRANCY) { 00324 ast_bt_get_addresses(<->backtrace[lt->reentrancy]); 00325 bt = <->backtrace[lt->reentrancy]; 00326 } 00327 ast_reentrancy_unlock(lt); 00328 ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t, bt); 00329 #else 00330 ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t); 00331 #endif 00332 } 00333 #endif /* DEBUG_THREADS */ 00334 00335 res = pthread_mutex_trylock(&t->mutex); 00336 00337 #ifdef DEBUG_THREADS 00338 if (t->tracking && !res) { 00339 ast_reentrancy_lock(lt); 00340 if (lt->reentrancy < AST_MAX_REENTRANCY) { 00341 lt->file[lt->reentrancy] = filename; 00342 lt->lineno[lt->reentrancy] = lineno; 00343 lt->func[lt->reentrancy] = func; 00344 lt->thread[lt->reentrancy] = pthread_self(); 00345 lt->reentrancy++; 00346 } else { 00347 __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n", 00348 filename, lineno, func, mutex_name); 00349 } 00350 ast_reentrancy_unlock(lt); 00351 if (t->tracking) { 00352 ast_mark_lock_acquired(t); 00353 } 00354 } else if (t->tracking) { 00355 ast_mark_lock_failed(t); 00356 } 00357 #endif /* DEBUG_THREADS */ 00358 00359 return res; 00360 }
int __ast_pthread_mutex_unlock | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
const char * | mutex_name, | |||
ast_mutex_t * | t | |||
) |
Definition at line 362 of file lock.c.
References __ast_mutex_logger, __ast_pthread_mutex_init(), __dump_backtrace(), AST_MAX_REENTRANCY, ast_reentrancy_init(), ast_reentrancy_lock(), ast_reentrancy_unlock(), ast_remove_lock_info(), ast_lock_track::backtrace, DO_THREAD_CRASH, ast_lock_track::file, ast_lock_track::func, ast_lock_track::lineno, ast_mutex_info::mutex, pthread_mutex_t, pthread_mutex_unlock, ast_lock_track::reentrancy, ROFFSET, ast_lock_track::thread, ast_mutex_info::track, and ast_mutex_info::tracking.
Referenced by __ao2_unlock().
00364 { 00365 int res; 00366 00367 #ifdef DEBUG_THREADS 00368 struct ast_lock_track *lt; 00369 int canlog = strcmp(filename, "logger.c") & t->tracking; 00370 #ifdef HAVE_BKTR 00371 struct ast_bt *bt = NULL; 00372 #endif 00373 00374 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00375 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00376 __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n", 00377 filename, lineno, func, mutex_name); 00378 res = __ast_pthread_mutex_init(t->tracking, filename, lineno, func, mutex_name, t); 00379 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00380 __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n", 00381 filename, lineno, func, mutex_name); 00382 } 00383 return res; 00384 } 00385 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00386 00387 if (t->tracking && !t->track) { 00388 ast_reentrancy_init(&t->track); 00389 } 00390 lt = t->track; 00391 00392 if (t->tracking) { 00393 ast_reentrancy_lock(lt); 00394 if (lt->reentrancy && (lt->thread[ROFFSET] != pthread_self())) { 00395 __ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n", 00396 filename, lineno, func, mutex_name); 00397 __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n", 00398 lt->file[ROFFSET], lt->lineno[ROFFSET], lt->func[ROFFSET], mutex_name); 00399 #ifdef HAVE_BKTR 00400 __dump_backtrace(<->backtrace[ROFFSET], canlog); 00401 #endif 00402 DO_THREAD_CRASH; 00403 } 00404 00405 if (--lt->reentrancy < 0) { 00406 __ast_mutex_logger("%s line %d (%s): mutex '%s' freed more times than we've locked!\n", 00407 filename, lineno, func, mutex_name); 00408 lt->reentrancy = 0; 00409 } 00410 00411 if (lt->reentrancy < AST_MAX_REENTRANCY) { 00412 lt->file[lt->reentrancy] = NULL; 00413 lt->lineno[lt->reentrancy] = 0; 00414 lt->func[lt->reentrancy] = NULL; 00415 lt->thread[lt->reentrancy] = 0; 00416 } 00417 00418 #ifdef HAVE_BKTR 00419 if (lt->reentrancy) { 00420 bt = <->backtrace[lt->reentrancy - 1]; 00421 } 00422 #endif 00423 ast_reentrancy_unlock(lt); 00424 00425 #ifdef HAVE_BKTR 00426 ast_remove_lock_info(t, bt); 00427 #else 00428 ast_remove_lock_info(t); 00429 #endif 00430 } 00431 #endif /* DEBUG_THREADS */ 00432 00433 res = pthread_mutex_unlock(&t->mutex); 00434 00435 #ifdef DEBUG_THREADS 00436 if (res) { 00437 __ast_mutex_logger("%s line %d (%s): Error releasing mutex: %s\n", 00438 filename, lineno, func, strerror(res)); 00439 DO_THREAD_CRASH; 00440 } 00441 #endif /* DEBUG_THREADS */ 00442 00443 return res; 00444 }
int __ast_rwlock_destroy | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
const char * | rwlock_name, | |||
ast_rwlock_t * | t | |||
) |
Definition at line 719 of file lock.c.
References __ast_mutex_logger, __AST_RWLOCK_INIT_VALUE, ast_reentrancy_lock(), ast_reentrancy_unlock(), ast_lock_track::backtrace, delete_reentrancy_cs(), ast_lock_track::file, ast_lock_track::func, ast_lock_track::lineno, ast_rwlock_info::lock, ast_lock_track::reentrancy, ast_lock_track::thread, ast_rwlock_info::track, and ast_rwlock_info::tracking.
00720 { 00721 int res; 00722 00723 #ifdef DEBUG_THREADS 00724 struct ast_lock_track *lt = t->track; 00725 int canlog = strcmp(filename, "logger.c") & t->tracking; 00726 00727 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00728 if (t->lock == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 00729 __ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is uninitialized.\n", 00730 filename, lineno, func, rwlock_name); 00731 return 0; 00732 } 00733 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00734 00735 #endif /* DEBUG_THREADS */ 00736 00737 res = pthread_rwlock_destroy(&t->lock); 00738 00739 #ifdef DEBUG_THREADS 00740 if (res) { 00741 __ast_mutex_logger("%s line %d (%s): Error destroying rwlock %s: %s\n", 00742 filename, lineno, func, rwlock_name, strerror(res)); 00743 } 00744 if (t->tracking) { 00745 ast_reentrancy_lock(lt); 00746 lt->file[0] = filename; 00747 lt->lineno[0] = lineno; 00748 lt->func[0] = func; 00749 lt->reentrancy = 0; 00750 lt->thread[0] = 0; 00751 #ifdef HAVE_BKTR 00752 memset(<->backtrace[0], 0, sizeof(lt->backtrace[0])); 00753 #endif 00754 ast_reentrancy_unlock(lt); 00755 delete_reentrancy_cs(&t->track); 00756 } 00757 #endif /* DEBUG_THREADS */ 00758 00759 return res; 00760 }
int __ast_rwlock_init | ( | int | tracking, | |
const char * | filename, | |||
int | lineno, | |||
const char * | func, | |||
const char * | rwlock_name, | |||
ast_rwlock_t * | t | |||
) |
Definition at line 686 of file lock.c.
References __ast_mutex_logger, __AST_RWLOCK_INIT_VALUE, ast_reentrancy_init(), ast_rwlock_info::lock, ast_rwlock_info::track, and ast_rwlock_info::tracking.
Referenced by __ast_rwlock_rdlock(), __ast_rwlock_timedrdlock(), __ast_rwlock_timedwrlock(), __ast_rwlock_tryrdlock(), __ast_rwlock_trywrlock(), __ast_rwlock_unlock(), and __ast_rwlock_wrlock().
00687 { 00688 int res; 00689 pthread_rwlockattr_t attr; 00690 00691 #ifdef DEBUG_THREADS 00692 00693 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00694 int canlog = strcmp(filename, "logger.c") & t->tracking; 00695 00696 if (t->lock != ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 00697 __ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is already initialized.\n", 00698 filename, lineno, func, rwlock_name); 00699 return 0; 00700 } 00701 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00702 00703 if ((t->tracking = tracking)) { 00704 ast_reentrancy_init(&t->track); 00705 } 00706 #endif /* DEBUG_THREADS */ 00707 00708 pthread_rwlockattr_init(&attr); 00709 00710 #ifdef HAVE_PTHREAD_RWLOCK_PREFER_WRITER_NP 00711 pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NP); 00712 #endif 00713 00714 res = pthread_rwlock_init(&t->lock, &attr); 00715 pthread_rwlockattr_destroy(&attr); 00716 return res; 00717 }
int __ast_rwlock_rdlock | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
ast_rwlock_t * | t, | |||
const char * | name | |||
) |
Definition at line 848 of file lock.c.
References __ast_mutex_logger, __ast_rwlock_init(), __AST_RWLOCK_INIT_VALUE, __dump_backtrace(), ast_bt_get_addresses(), ast_mark_lock_acquired(), AST_MAX_REENTRANCY, AST_RDLOCK, ast_reentrancy_init(), ast_reentrancy_lock(), ast_reentrancy_unlock(), ast_remove_lock_info(), ast_store_lock_info(), ast_lock_track::backtrace, DO_THREAD_CRASH, ast_lock_track::file, ast_lock_track::func, ast_lock_track::lineno, ast_rwlock_info::lock, ast_lock_track::reentrancy, ast_lock_track::thread, ast_rwlock_info::track, and ast_rwlock_info::tracking.
Referenced by __ast_heap_rdlock().
00849 { 00850 int res; 00851 00852 #ifdef DEBUG_THREADS 00853 struct ast_lock_track *lt; 00854 int canlog = strcmp(filename, "logger.c") & t->tracking; 00855 #ifdef HAVE_BKTR 00856 struct ast_bt *bt = NULL; 00857 #endif 00858 00859 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00860 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 00861 /* Don't warn abount uninitialized lock. 00862 * Simple try to initialize it. 00863 * May be not needed in linux system. 00864 */ 00865 res = __ast_rwlock_init(t->tracking, filename, line, func, name, t); 00866 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 00867 __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n", 00868 filename, line, func, name); 00869 return res; 00870 } 00871 } 00872 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00873 00874 if (t->tracking && !t->track) { 00875 ast_reentrancy_init(&t->track); 00876 } 00877 lt = t->track; 00878 00879 if (t->tracking) { 00880 #ifdef HAVE_BKTR 00881 ast_reentrancy_lock(lt); 00882 if (lt->reentrancy != AST_MAX_REENTRANCY) { 00883 ast_bt_get_addresses(<->backtrace[lt->reentrancy]); 00884 bt = <->backtrace[lt->reentrancy]; 00885 } 00886 ast_reentrancy_unlock(lt); 00887 ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t, bt); 00888 #else 00889 ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t); 00890 #endif 00891 } 00892 #endif /* DEBUG_THREADS */ 00893 00894 #if defined(DETECT_DEADLOCKS) && defined(DEBUG_THREADS) 00895 { 00896 time_t seconds = time(NULL); 00897 time_t wait_time, reported_wait = 0; 00898 do { 00899 res = pthread_rwlock_tryrdlock(&t->lock); 00900 if (res == EBUSY) { 00901 wait_time = time(NULL) - seconds; 00902 if (wait_time > reported_wait && (wait_time % 5) == 0) { 00903 __ast_mutex_logger("%s line %d (%s): Deadlock? waited %d sec for readlock '%s'?\n", 00904 filename, line, func, (int)wait_time, name); 00905 if (t->tracking) { 00906 ast_reentrancy_lock(lt); 00907 #ifdef HAVE_BKTR 00908 __dump_backtrace(<->backtrace[lt->reentrancy], canlog); 00909 #endif 00910 __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n", 00911 lt->file[lt->reentrancy-1], lt->lineno[lt->reentrancy-1], 00912 lt->func[lt->reentrancy-1], name); 00913 #ifdef HAVE_BKTR 00914 __dump_backtrace(<->backtrace[lt->reentrancy-1], canlog); 00915 #endif 00916 ast_reentrancy_unlock(lt); 00917 } 00918 reported_wait = wait_time; 00919 } 00920 usleep(200); 00921 } 00922 } while (res == EBUSY); 00923 } 00924 #else /* !DETECT_DEADLOCKS || !DEBUG_THREADS */ 00925 res = pthread_rwlock_rdlock(&t->lock); 00926 #endif /* !DETECT_DEADLOCKS || !DEBUG_THREADS */ 00927 00928 #ifdef DEBUG_THREADS 00929 if (!res && t->tracking) { 00930 ast_reentrancy_lock(lt); 00931 if (lt->reentrancy < AST_MAX_REENTRANCY) { 00932 lt->file[lt->reentrancy] = filename; 00933 lt->lineno[lt->reentrancy] = line; 00934 lt->func[lt->reentrancy] = func; 00935 lt->thread[lt->reentrancy] = pthread_self(); 00936 lt->reentrancy++; 00937 } 00938 ast_reentrancy_unlock(lt); 00939 if (t->tracking) { 00940 ast_mark_lock_acquired(t); 00941 } 00942 } else if (t->tracking) { 00943 #ifdef HAVE_BKTR 00944 if (lt->reentrancy) { 00945 ast_reentrancy_lock(lt); 00946 bt = <->backtrace[lt->reentrancy-1]; 00947 ast_reentrancy_unlock(lt); 00948 } else { 00949 bt = NULL; 00950 } 00951 ast_remove_lock_info(t, bt); 00952 #else 00953 ast_remove_lock_info(t); 00954 #endif 00955 } 00956 00957 if (res) { 00958 __ast_mutex_logger("%s line %d (%s): Error obtaining read lock: %s\n", 00959 filename, line, func, strerror(res)); 00960 DO_THREAD_CRASH; 00961 } 00962 #endif /* DEBUG_THREADS */ 00963 00964 return res; 00965 }
int __ast_rwlock_timedrdlock | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
ast_rwlock_t * | t, | |||
const char * | name, | |||
const struct timespec * | abs_timeout | |||
) |
Definition at line 1089 of file lock.c.
References __ast_mutex_logger, __ast_rwlock_init(), __AST_RWLOCK_INIT_VALUE, ast_bt_get_addresses(), AST_MAX_REENTRANCY, ast_reentrancy_init(), ast_reentrancy_lock(), ast_reentrancy_unlock(), ast_store_lock_info(), ast_tvnow(), ast_tvsub(), AST_WRLOCK, ast_lock_track::backtrace, ast_rwlock_info::lock, ast_lock_track::reentrancy, ast_rwlock_info::track, and ast_rwlock_info::tracking.
01091 { 01092 int res; 01093 01094 #ifdef DEBUG_THREADS 01095 struct ast_lock_track *lt; 01096 int canlog = strcmp(filename, "logger.c") & t->tracking; 01097 #ifdef HAVE_BKTR 01098 struct ast_bt *bt = NULL; 01099 #endif 01100 01101 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 01102 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 01103 /* Don't warn abount uninitialized lock. 01104 * Simple try to initialize it. 01105 * May be not needed in linux system. 01106 */ 01107 res = __ast_rwlock_init(t->tracking, filename, line, func, name, t); 01108 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 01109 __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n", 01110 filename, line, func, name); 01111 return res; 01112 } 01113 } 01114 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 01115 01116 if (t->tracking && !t->track) { 01117 ast_reentrancy_init(&t->track); 01118 } 01119 lt = t->track; 01120 01121 if (t->tracking) { 01122 #ifdef HAVE_BKTR 01123 ast_reentrancy_lock(lt); 01124 if (lt->reentrancy != AST_MAX_REENTRANCY) { 01125 ast_bt_get_addresses(<->backtrace[lt->reentrancy]); 01126 bt = <->backtrace[lt->reentrancy]; 01127 } 01128 ast_reentrancy_unlock(lt); 01129 ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt); 01130 #else 01131 ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t); 01132 #endif 01133 } 01134 #endif /* DEBUG_THREADS */ 01135 01136 #ifdef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK 01137 res = pthread_rwlock_timedrdlock(&t->lock, abs_timeout); 01138 #else 01139 do { 01140 struct timeval _start = ast_tvnow(), _diff; 01141 for (;;) { 01142 if (!(res = pthread_rwlock_tryrdlock(&t->lock))) { 01143 break; 01144 } 01145 _diff = ast_tvsub(ast_tvnow(), _start); 01146 if (_diff.tv_sec > abs_timeout->tv_sec || (_diff.tv_sec == abs_timeout->tv_sec && _diff.tv_usec * 1000 > abs_timeout->tv_nsec)) { 01147 break; 01148 } 01149 usleep(1); 01150 } 01151 } while (0); 01152 #endif 01153 01154 #ifdef DEBUG_THREADS 01155 if (!res && t->tracking) { 01156 ast_reentrancy_lock(lt); 01157 if (lt->reentrancy < AST_MAX_REENTRANCY) { 01158 lt->file[lt->reentrancy] = filename; 01159 lt->lineno[lt->reentrancy] = line; 01160 lt->func[lt->reentrancy] = func; 01161 lt->thread[lt->reentrancy] = pthread_self(); 01162 lt->reentrancy++; 01163 } 01164 ast_reentrancy_unlock(lt); 01165 if (t->tracking) { 01166 ast_mark_lock_acquired(t); 01167 } 01168 } else if (t->tracking) { 01169 #ifdef HAVE_BKTR 01170 if (lt->reentrancy) { 01171 ast_reentrancy_lock(lt); 01172 bt = <->backtrace[lt->reentrancy-1]; 01173 ast_reentrancy_unlock(lt); 01174 } else { 01175 bt = NULL; 01176 } 01177 ast_remove_lock_info(t, bt); 01178 #else 01179 ast_remove_lock_info(t); 01180 #endif 01181 } 01182 if (res) { 01183 __ast_mutex_logger("%s line %d (%s): Error obtaining read lock: %s\n", 01184 filename, line, func, strerror(res)); 01185 DO_THREAD_CRASH; 01186 } 01187 #endif /* DEBUG_THREADS */ 01188 01189 return res; 01190 }
int __ast_rwlock_timedwrlock | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
ast_rwlock_t * | t, | |||
const char * | name, | |||
const struct timespec * | abs_timeout | |||
) |
Definition at line 1192 of file lock.c.
References __ast_mutex_logger, __ast_rwlock_init(), __AST_RWLOCK_INIT_VALUE, ast_bt_get_addresses(), AST_MAX_REENTRANCY, ast_reentrancy_init(), ast_reentrancy_lock(), ast_reentrancy_unlock(), ast_store_lock_info(), ast_tvnow(), ast_tvsub(), AST_WRLOCK, ast_lock_track::backtrace, ast_rwlock_info::lock, ast_lock_track::reentrancy, ast_rwlock_info::track, and ast_rwlock_info::tracking.
01194 { 01195 int res; 01196 01197 #ifdef DEBUG_THREADS 01198 struct ast_lock_track *lt; 01199 int canlog = strcmp(filename, "logger.c") & t->tracking; 01200 #ifdef HAVE_BKTR 01201 struct ast_bt *bt = NULL; 01202 #endif 01203 01204 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 01205 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 01206 /* Don't warn abount uninitialized lock. 01207 * Simple try to initialize it. 01208 * May be not needed in linux system. 01209 */ 01210 res = __ast_rwlock_init(t->tracking, filename, line, func, name, t); 01211 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 01212 __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n", 01213 filename, line, func, name); 01214 return res; 01215 } 01216 } 01217 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 01218 01219 if (t->tracking && !t->track) { 01220 ast_reentrancy_init(&t->track); 01221 } 01222 lt = t->track; 01223 01224 if (t->tracking) { 01225 #ifdef HAVE_BKTR 01226 ast_reentrancy_lock(lt); 01227 if (lt->reentrancy != AST_MAX_REENTRANCY) { 01228 ast_bt_get_addresses(<->backtrace[lt->reentrancy]); 01229 bt = <->backtrace[lt->reentrancy]; 01230 } 01231 ast_reentrancy_unlock(lt); 01232 ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt); 01233 #else 01234 ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t); 01235 #endif 01236 } 01237 #endif /* DEBUG_THREADS */ 01238 01239 #ifdef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK 01240 res = pthread_rwlock_timedwrlock(&t->lock, abs_timeout); 01241 #else 01242 do { 01243 struct timeval _start = ast_tvnow(), _diff; 01244 for (;;) { 01245 if (!(res = pthread_rwlock_trywrlock(&t->lock))) { 01246 break; 01247 } 01248 _diff = ast_tvsub(ast_tvnow(), _start); 01249 if (_diff.tv_sec > abs_timeout->tv_sec || (_diff.tv_sec == abs_timeout->tv_sec && _diff.tv_usec * 1000 > abs_timeout->tv_nsec)) { 01250 break; 01251 } 01252 usleep(1); 01253 } 01254 } while (0); 01255 #endif 01256 01257 #ifdef DEBUG_THREADS 01258 if (!res && t->tracking) { 01259 ast_reentrancy_lock(lt); 01260 if (lt->reentrancy < AST_MAX_REENTRANCY) { 01261 lt->file[lt->reentrancy] = filename; 01262 lt->lineno[lt->reentrancy] = line; 01263 lt->func[lt->reentrancy] = func; 01264 lt->thread[lt->reentrancy] = pthread_self(); 01265 lt->reentrancy++; 01266 } 01267 ast_reentrancy_unlock(lt); 01268 if (t->tracking) { 01269 ast_mark_lock_acquired(t); 01270 } 01271 } else if (t->tracking) { 01272 #ifdef HAVE_BKTR 01273 if (lt->reentrancy) { 01274 ast_reentrancy_lock(lt); 01275 bt = <->backtrace[lt->reentrancy-1]; 01276 ast_reentrancy_unlock(lt); 01277 } else { 01278 bt = NULL; 01279 } 01280 if (t->tracking) { 01281 ast_remove_lock_info(t, bt); 01282 } 01283 #else 01284 if (t->tracking) { 01285 ast_remove_lock_info(t); 01286 } 01287 #endif 01288 } 01289 if (res) { 01290 __ast_mutex_logger("%s line %d (%s): Error obtaining read lock: %s\n", 01291 filename, line, func, strerror(res)); 01292 DO_THREAD_CRASH; 01293 } 01294 #endif /* DEBUG_THREADS */ 01295 01296 return res; 01297 }
int __ast_rwlock_tryrdlock | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
ast_rwlock_t * | t, | |||
const char * | name | |||
) |
Definition at line 1299 of file lock.c.
References __ast_mutex_logger, __ast_rwlock_init(), __AST_RWLOCK_INIT_VALUE, ast_bt_get_addresses(), ast_mark_lock_acquired(), ast_mark_lock_failed(), AST_MAX_REENTRANCY, AST_RDLOCK, ast_reentrancy_init(), ast_reentrancy_lock(), ast_reentrancy_unlock(), ast_store_lock_info(), ast_lock_track::backtrace, ast_lock_track::file, ast_lock_track::func, ast_lock_track::lineno, ast_rwlock_info::lock, ast_lock_track::reentrancy, ast_lock_track::thread, ast_rwlock_info::track, and ast_rwlock_info::tracking.
01300 { 01301 int res; 01302 01303 #ifdef DEBUG_THREADS 01304 struct ast_lock_track *lt; 01305 #ifdef HAVE_BKTR 01306 struct ast_bt *bt = NULL; 01307 #endif 01308 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 01309 int canlog = strcmp(filename, "logger.c") & t->tracking; 01310 01311 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 01312 /* Don't warn abount uninitialized lock. 01313 * Simple try to initialize it. 01314 * May be not needed in linux system. 01315 */ 01316 res = __ast_rwlock_init(t->tracking, filename, line, func, name, t); 01317 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 01318 __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n", 01319 filename, line, func, name); 01320 return res; 01321 } 01322 } 01323 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 01324 01325 if (t->tracking && !t->track) { 01326 ast_reentrancy_init(&t->track); 01327 } 01328 lt = t->track; 01329 01330 if (t->tracking) { 01331 #ifdef HAVE_BKTR 01332 ast_reentrancy_lock(lt); 01333 if (lt->reentrancy != AST_MAX_REENTRANCY) { 01334 ast_bt_get_addresses(<->backtrace[lt->reentrancy]); 01335 bt = <->backtrace[lt->reentrancy]; 01336 } 01337 ast_reentrancy_unlock(lt); 01338 ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t, bt); 01339 #else 01340 ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t); 01341 #endif 01342 } 01343 #endif /* DEBUG_THREADS */ 01344 01345 res = pthread_rwlock_tryrdlock(&t->lock); 01346 01347 #ifdef DEBUG_THREADS 01348 if (!res && t->tracking) { 01349 ast_reentrancy_lock(lt); 01350 if (lt->reentrancy < AST_MAX_REENTRANCY) { 01351 lt->file[lt->reentrancy] = filename; 01352 lt->lineno[lt->reentrancy] = line; 01353 lt->func[lt->reentrancy] = func; 01354 lt->thread[lt->reentrancy] = pthread_self(); 01355 lt->reentrancy++; 01356 } 01357 ast_reentrancy_unlock(lt); 01358 if (t->tracking) { 01359 ast_mark_lock_acquired(t); 01360 } 01361 } else if (t->tracking) { 01362 ast_mark_lock_failed(t); 01363 } 01364 #endif /* DEBUG_THREADS */ 01365 01366 return res; 01367 }
int __ast_rwlock_trywrlock | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
ast_rwlock_t * | t, | |||
const char * | name | |||
) |
Definition at line 1369 of file lock.c.
References __ast_mutex_logger, __ast_rwlock_init(), __AST_RWLOCK_INIT_VALUE, ast_bt_get_addresses(), ast_mark_lock_acquired(), ast_mark_lock_failed(), AST_MAX_REENTRANCY, ast_reentrancy_init(), ast_reentrancy_lock(), ast_reentrancy_unlock(), ast_store_lock_info(), AST_WRLOCK, ast_lock_track::backtrace, ast_lock_track::file, ast_lock_track::func, ast_lock_track::lineno, ast_rwlock_info::lock, ast_lock_track::reentrancy, ast_lock_track::thread, ast_rwlock_info::track, and ast_rwlock_info::tracking.
01370 { 01371 int res; 01372 01373 #ifdef DEBUG_THREADS 01374 struct ast_lock_track *lt; 01375 #ifdef HAVE_BKTR 01376 struct ast_bt *bt = NULL; 01377 #endif 01378 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 01379 int canlog = strcmp(filename, "logger.c") & t->tracking; 01380 01381 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 01382 /* Don't warn abount uninitialized lock. 01383 * Simple try to initialize it. 01384 * May be not needed in linux system. 01385 */ 01386 res = __ast_rwlock_init(t->tracking, filename, line, func, name, t); 01387 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 01388 __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n", 01389 filename, line, func, name); 01390 return res; 01391 } 01392 } 01393 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 01394 01395 if (t->tracking && !t->track) { 01396 ast_reentrancy_init(&t->track); 01397 } 01398 lt = t->track; 01399 01400 if (t->tracking) { 01401 #ifdef HAVE_BKTR 01402 ast_reentrancy_lock(lt); 01403 if (lt->reentrancy != AST_MAX_REENTRANCY) { 01404 ast_bt_get_addresses(<->backtrace[lt->reentrancy]); 01405 bt = <->backtrace[lt->reentrancy]; 01406 } 01407 ast_reentrancy_unlock(lt); 01408 ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt); 01409 #else 01410 ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t); 01411 #endif 01412 } 01413 #endif /* DEBUG_THREADS */ 01414 01415 res = pthread_rwlock_trywrlock(&t->lock); 01416 01417 #ifdef DEBUG_THREADS 01418 if (!res && t->tracking) { 01419 ast_reentrancy_lock(lt); 01420 if (lt->reentrancy < AST_MAX_REENTRANCY) { 01421 lt->file[lt->reentrancy] = filename; 01422 lt->lineno[lt->reentrancy] = line; 01423 lt->func[lt->reentrancy] = func; 01424 lt->thread[lt->reentrancy] = pthread_self(); 01425 lt->reentrancy++; 01426 } 01427 ast_reentrancy_unlock(lt); 01428 ast_mark_lock_acquired(t); 01429 } else if (t->tracking) { 01430 ast_mark_lock_failed(t); 01431 } 01432 #endif /* DEBUG_THREADS */ 01433 01434 return res; 01435 }
int __ast_rwlock_unlock | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
ast_rwlock_t * | t, | |||
const char * | name | |||
) |
Definition at line 762 of file lock.c.
References __ast_mutex_logger, __ast_rwlock_init(), __AST_RWLOCK_INIT_VALUE, AST_PTHREADT_NULL, ast_reentrancy_init(), ast_reentrancy_lock(), ast_reentrancy_unlock(), ast_remove_lock_info(), ast_lock_track::backtrace, DO_THREAD_CRASH, ast_lock_track::file, ast_lock_track::func, ast_lock_track::lineno, ast_rwlock_info::lock, ast_lock_track::reentrancy, ast_lock_track::thread, ast_rwlock_info::track, and ast_rwlock_info::tracking.
Referenced by __ast_heap_unlock().
00763 { 00764 int res; 00765 00766 #ifdef DEBUG_THREADS 00767 struct ast_lock_track *lt; 00768 int canlog = strcmp(filename, "logger.c") & t->tracking; 00769 #ifdef HAVE_BKTR 00770 struct ast_bt *bt = NULL; 00771 #endif 00772 int lock_found = 0; 00773 00774 00775 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00776 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 00777 __ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is uninitialized.\n", 00778 filename, line, func, name); 00779 res = __ast_rwlock_init(t->tracking, filename, line, func, name, t); 00780 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 00781 __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n", 00782 filename, line, func, name); 00783 } 00784 return res; 00785 } 00786 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00787 00788 if (t->tracking && !t->track) { 00789 ast_reentrancy_init(&t->track); 00790 } 00791 lt = t->track; 00792 00793 if (t->tracking) { 00794 ast_reentrancy_lock(lt); 00795 if (lt->reentrancy) { 00796 int i; 00797 pthread_t self = pthread_self(); 00798 for (i = lt->reentrancy - 1; i >= 0; --i) { 00799 if (lt->thread[i] == self) { 00800 lock_found = 1; 00801 if (i != lt->reentrancy - 1) { 00802 lt->file[i] = lt->file[lt->reentrancy - 1]; 00803 lt->lineno[i] = lt->lineno[lt->reentrancy - 1]; 00804 lt->func[i] = lt->func[lt->reentrancy - 1]; 00805 lt->thread[i] = lt->thread[lt->reentrancy - 1]; 00806 } 00807 #ifdef HAVE_BKTR 00808 bt = <->backtrace[i]; 00809 #endif 00810 lt->file[lt->reentrancy - 1] = NULL; 00811 lt->lineno[lt->reentrancy - 1] = 0; 00812 lt->func[lt->reentrancy - 1] = NULL; 00813 lt->thread[lt->reentrancy - 1] = AST_PTHREADT_NULL; 00814 break; 00815 } 00816 } 00817 } 00818 00819 if (lock_found && --lt->reentrancy < 0) { 00820 __ast_mutex_logger("%s line %d (%s): rwlock '%s' freed more times than we've locked!\n", 00821 filename, line, func, name); 00822 lt->reentrancy = 0; 00823 } 00824 00825 ast_reentrancy_unlock(lt); 00826 00827 #ifdef HAVE_BKTR 00828 ast_remove_lock_info(t, bt); 00829 #else 00830 ast_remove_lock_info(t); 00831 #endif 00832 } 00833 #endif /* DEBUG_THREADS */ 00834 00835 res = pthread_rwlock_unlock(&t->lock); 00836 00837 #ifdef DEBUG_THREADS 00838 if (res) { 00839 __ast_mutex_logger("%s line %d (%s): Error releasing rwlock: %s\n", 00840 filename, line, func, strerror(res)); 00841 DO_THREAD_CRASH; 00842 } 00843 #endif /* DEBUG_THREADS */ 00844 00845 return res; 00846 }
int __ast_rwlock_wrlock | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
ast_rwlock_t * | t, | |||
const char * | name | |||
) |
Definition at line 967 of file lock.c.
References __ast_mutex_logger, __ast_rwlock_init(), __AST_RWLOCK_INIT_VALUE, __dump_backtrace(), ast_bt_get_addresses(), ast_mark_lock_acquired(), AST_MAX_REENTRANCY, ast_reentrancy_init(), ast_reentrancy_lock(), ast_reentrancy_unlock(), ast_remove_lock_info(), ast_store_lock_info(), AST_WRLOCK, ast_lock_track::backtrace, DO_THREAD_CRASH, ast_lock_track::file, ast_lock_track::func, ast_lock_track::lineno, ast_rwlock_info::lock, ast_lock_track::reentrancy, ast_lock_track::thread, ast_rwlock_info::track, and ast_rwlock_info::tracking.
Referenced by __ast_heap_wrlock().
00968 { 00969 int res; 00970 00971 #ifdef DEBUG_THREADS 00972 struct ast_lock_track *lt; 00973 int canlog = strcmp(filename, "logger.c") & t->tracking; 00974 #ifdef HAVE_BKTR 00975 struct ast_bt *bt = NULL; 00976 #endif 00977 00978 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00979 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 00980 /* Don't warn abount uninitialized lock. 00981 * Simple try to initialize it. 00982 * May be not needed in linux system. 00983 */ 00984 res = __ast_rwlock_init(t->tracking, filename, line, func, name, t); 00985 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 00986 __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n", 00987 filename, line, func, name); 00988 return res; 00989 } 00990 } 00991 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00992 00993 if (t->tracking && !t->track) { 00994 ast_reentrancy_init(&t->track); 00995 } 00996 lt = t->track; 00997 00998 if (t->tracking) { 00999 #ifdef HAVE_BKTR 01000 ast_reentrancy_lock(lt); 01001 if (lt->reentrancy != AST_MAX_REENTRANCY) { 01002 ast_bt_get_addresses(<->backtrace[lt->reentrancy]); 01003 bt = <->backtrace[lt->reentrancy]; 01004 } 01005 ast_reentrancy_unlock(lt); 01006 ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt); 01007 #else 01008 ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t); 01009 #endif 01010 } 01011 #endif /* DEBUG_THREADS */ 01012 01013 #if defined(DETECT_DEADLOCKS) && defined(DEBUG_THREADS) 01014 { 01015 time_t seconds = time(NULL); 01016 time_t wait_time, reported_wait = 0; 01017 do { 01018 res = pthread_rwlock_trywrlock(&t->lock); 01019 if (res == EBUSY) { 01020 wait_time = time(NULL) - seconds; 01021 if (wait_time > reported_wait && (wait_time % 5) == 0) { 01022 __ast_mutex_logger("%s line %d (%s): Deadlock? waited %d sec for writelock '%s'?\n", 01023 filename, line, func, (int)wait_time, name); 01024 if (t->tracking) { 01025 ast_reentrancy_lock(lt); 01026 #ifdef HAVE_BKTR 01027 __dump_backtrace(<->backtrace[lt->reentrancy], canlog); 01028 #endif 01029 __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n", 01030 lt->file[lt->reentrancy-1], lt->lineno[lt->reentrancy-1], 01031 lt->func[lt->reentrancy-1], name); 01032 #ifdef HAVE_BKTR 01033 __dump_backtrace(<->backtrace[lt->reentrancy-1], canlog); 01034 #endif 01035 ast_reentrancy_unlock(lt); 01036 } 01037 reported_wait = wait_time; 01038 } 01039 usleep(200); 01040 } 01041 } while (res == EBUSY); 01042 } 01043 #else /* !DETECT_DEADLOCKS || !DEBUG_THREADS */ 01044 res = pthread_rwlock_wrlock(&t->lock); 01045 #endif /* !DETECT_DEADLOCKS || !DEBUG_THREADS */ 01046 01047 #ifdef DEBUG_THREADS 01048 if (!res && t->tracking) { 01049 ast_reentrancy_lock(lt); 01050 if (lt->reentrancy < AST_MAX_REENTRANCY) { 01051 lt->file[lt->reentrancy] = filename; 01052 lt->lineno[lt->reentrancy] = line; 01053 lt->func[lt->reentrancy] = func; 01054 lt->thread[lt->reentrancy] = pthread_self(); 01055 lt->reentrancy++; 01056 } 01057 ast_reentrancy_unlock(lt); 01058 if (t->tracking) { 01059 ast_mark_lock_acquired(t); 01060 } 01061 } else if (t->tracking) { 01062 #ifdef HAVE_BKTR 01063 if (lt->reentrancy) { 01064 ast_reentrancy_lock(lt); 01065 bt = <->backtrace[lt->reentrancy-1]; 01066 ast_reentrancy_unlock(lt); 01067 } else { 01068 bt = NULL; 01069 } 01070 if (t->tracking) { 01071 ast_remove_lock_info(t, bt); 01072 } 01073 #else 01074 if (t->tracking) { 01075 ast_remove_lock_info(t); 01076 } 01077 #endif 01078 } 01079 if (res) { 01080 __ast_mutex_logger("%s line %d (%s): Error obtaining write lock: %s\n", 01081 filename, line, func, strerror(res)); 01082 DO_THREAD_CRASH; 01083 } 01084 #endif /* DEBUG_THREADS */ 01085 01086 return res; 01087 }
static void __dump_backtrace | ( | struct ast_bt * | bt, | |
int | canlog | |||
) | [inline, static] |
Definition at line 293 of file lock.h.
References __ast_mutex_logger, ast_bt::addresses, free, and ast_bt::num_frames.
Referenced by __ast_cond_timedwait(), __ast_cond_wait(), __ast_pthread_mutex_destroy(), __ast_pthread_mutex_lock(), __ast_pthread_mutex_unlock(), __ast_rwlock_rdlock(), and __ast_rwlock_wrlock().
00294 { 00295 char **strings; 00296 00297 ssize_t i; 00298 00299 strings = backtrace_symbols(bt->addresses, bt->num_frames); 00300 00301 for (i = 0; i < bt->num_frames; i++) 00302 __ast_mutex_logger("%s\n", strings[i]); 00303 00304 free(strings); 00305 }
int ast_atomic_dec_and_test | ( | volatile int * | p | ) | [inline] |
decrement *p by 1 and return true if the variable has reached 0. Useful e.g. to check if a refcount has reached 0.
Definition at line 649 of file lock.h.
Referenced by dispose_conf(), iax2_process_thread_cleanup(), run_station(), and sla_station_exec().
int ast_atomic_fetchadd_int | ( | volatile int * | p, | |
int | v | |||
) | [inline] |
Atomically add v to *p and return * the previous value of *p. This can be used to handle reference counts, and the return value can be used to generate unique identifiers.
Definition at line 603 of file lock.h.
Referenced by __ao2_lock(), __ao2_trylock(), __ao2_unlock(), __ast_channel_alloc_ap(), __ast_manager_event_multichan(), __ast_module_user_add(), __ast_module_user_hangup_all(), __ast_module_user_remove(), _ast_odbc_request_obj2(), _sip_tcp_helper_thread(), accept_thread(), action_login(), add_subscribe_event(), admin_exec(), advance_event(), append_event(), ast_cli_command_full(), ast_dial_append(), ast_event_subscribe_new(), ast_module_ref(), ast_module_unref(), authenticate_verify(), build_conf(), build_peer(), cc_device_monitor_init(), cc_extension_monitor_init(), cc_interfaces_datastore_init(), cdr_seq_inc(), create_new_sip_etag(), dahdi_destroy(), dahdi_request(), dahdi_translate(), destroy_session(), dundi_query_read(), enum_query_read(), fax_session_new(), fax_session_release(), fax_session_reserve(), find_idle_thread(), find_session(), generic_fax_exec(), grab_last(), handle_register_message(), httpd_helper_thread(), iax2_destroy_helper(), iax2_process_thread(), iax_frame_free(), iax_frame_new(), inprocess_count(), internal_ao2_alloc(), internal_ao2_callback(), internal_ao2_container_alloc(), internal_ao2_link(), internal_ao2_ref(), load_realtime_queue(), receivefax_exec(), run_station(), sendfax_exec(), session_destructor(), session_do(), sig_pri_hangup(), sip_destroy_peer(), sip_new(), sip_peer_hold(), sip_register(), sip_registry_destroy(), sla_add_trunk_to_station(), sla_handle_hold_event(), sla_station_exec(), sla_trunk_exec(), smdi_msg_retrieve_read(), spandsp_fax_switch_to_t38(), temp_peer(), and update_stats().
int ast_atomic_fetchadd_int_slow | ( | volatile int * | p, | |
int | v | |||
) |
Definition at line 1829 of file utils.c.
References ast_mutex_lock, ast_mutex_unlock, and fetchadd_m.
01830 { 01831 int ret; 01832 ast_mutex_lock(&fetchadd_m); 01833 ret = *p; 01834 *p += v; 01835 ast_mutex_unlock(&fetchadd_m); 01836 return ret; 01837 }
int ast_find_lock_info | ( | void * | lock_addr, | |
char * | filename, | |||
size_t | filename_size, | |||
int * | lineno, | |||
char * | func, | |||
size_t | func_size, | |||
char * | mutex_name, | |||
size_t | mutex_name_size | |||
) |
retrieve lock info for the specified mutex
this gets called during deadlock avoidance, so that the information may be preserved as to what location originally acquired the lock.
Definition at line 644 of file utils.c.
References ast_copy_string(), ast_threadstorage_get(), lock_info, pthread_mutex_lock, pthread_mutex_unlock, and thread_lock_info.
00645 { 00646 struct thr_lock_info *lock_info; 00647 int i = 0; 00648 00649 if (!(lock_info = ast_threadstorage_get(&thread_lock_info, sizeof(*lock_info)))) 00650 return -1; 00651 00652 pthread_mutex_lock(&lock_info->lock); 00653 00654 for (i = lock_info->num_locks - 1; i >= 0; i--) { 00655 if (lock_info->locks[i].lock_addr == lock_addr) 00656 break; 00657 } 00658 00659 if (i == -1) { 00660 /* Lock not found :( */ 00661 pthread_mutex_unlock(&lock_info->lock); 00662 return -1; 00663 } 00664 00665 ast_copy_string(filename, lock_info->locks[i].file, filename_size); 00666 *lineno = lock_info->locks[i].line_num; 00667 ast_copy_string(func, lock_info->locks[i].func, func_size); 00668 ast_copy_string(mutex_name, lock_info->locks[i].lock_name, mutex_name_size); 00669 00670 pthread_mutex_unlock(&lock_info->lock); 00671 00672 return 0; 00673 }
void ast_mark_lock_acquired | ( | void * | lock_addr | ) |
Mark the last lock as acquired.
Definition at line 615 of file utils.c.
References ast_threadstorage_get(), lock_info, pthread_mutex_lock, pthread_mutex_unlock, and thread_lock_info.
Referenced by __ast_pthread_mutex_lock(), __ast_pthread_mutex_trylock(), __ast_rwlock_rdlock(), __ast_rwlock_tryrdlock(), __ast_rwlock_trywrlock(), and __ast_rwlock_wrlock().
00616 { 00617 struct thr_lock_info *lock_info; 00618 00619 if (!(lock_info = ast_threadstorage_get(&thread_lock_info, sizeof(*lock_info)))) 00620 return; 00621 00622 pthread_mutex_lock(&lock_info->lock); 00623 if (lock_info->locks[lock_info->num_locks - 1].lock_addr == lock_addr) { 00624 lock_info->locks[lock_info->num_locks - 1].pending = 0; 00625 } 00626 pthread_mutex_unlock(&lock_info->lock); 00627 }
void ast_mark_lock_failed | ( | void * | lock_addr | ) |
Mark the last lock as failed (trylock).
Definition at line 629 of file utils.c.
References ast_threadstorage_get(), lock_info, pthread_mutex_lock, pthread_mutex_unlock, and thread_lock_info.
Referenced by __ast_pthread_mutex_trylock(), __ast_rwlock_tryrdlock(), and __ast_rwlock_trywrlock().
00630 { 00631 struct thr_lock_info *lock_info; 00632 00633 if (!(lock_info = ast_threadstorage_get(&thread_lock_info, sizeof(*lock_info)))) 00634 return; 00635 00636 pthread_mutex_lock(&lock_info->lock); 00637 if (lock_info->locks[lock_info->num_locks - 1].lock_addr == lock_addr) { 00638 lock_info->locks[lock_info->num_locks - 1].pending = -1; 00639 lock_info->locks[lock_info->num_locks - 1].times_locked--; 00640 } 00641 pthread_mutex_unlock(&lock_info->lock); 00642 }
static void ast_reentrancy_init | ( | struct ast_lock_track ** | plt | ) | [inline, static] |
Definition at line 439 of file lock.h.
References AST_MAX_REENTRANCY, AST_MUTEX_KIND, ast_lock_track::backtrace, calloc, ast_lock_track::file, ast_lock_track::func, HAVE_BKTR, ast_lock_track::lineno, pthread_mutex_init, ast_lock_track::reentr_mutex, ast_lock_track::reentrancy, and ast_lock_track::thread.
Referenced by __ast_cond_timedwait(), __ast_cond_wait(), __ast_pthread_mutex_destroy(), __ast_pthread_mutex_init(), __ast_pthread_mutex_lock(), __ast_pthread_mutex_trylock(), __ast_pthread_mutex_unlock(), __ast_rwlock_init(), __ast_rwlock_rdlock(), __ast_rwlock_timedrdlock(), __ast_rwlock_timedwrlock(), __ast_rwlock_tryrdlock(), __ast_rwlock_trywrlock(), __ast_rwlock_unlock(), and __ast_rwlock_wrlock().
00440 { 00441 int i; 00442 pthread_mutexattr_t reentr_attr; 00443 struct ast_lock_track *lt = *plt; 00444 00445 if (!lt) { 00446 lt = *plt = (struct ast_lock_track *) calloc(1, sizeof(*lt)); 00447 } 00448 00449 for (i = 0; i < AST_MAX_REENTRANCY; i++) { 00450 lt->file[i] = NULL; 00451 lt->lineno[i] = 0; 00452 lt->func[i] = NULL; 00453 lt->thread[i] = 0; 00454 #ifdef HAVE_BKTR 00455 memset(<->backtrace[i], 0, sizeof(lt->backtrace[i])); 00456 #endif 00457 } 00458 00459 lt->reentrancy = 0; 00460 00461 pthread_mutexattr_init(&reentr_attr); 00462 pthread_mutexattr_settype(&reentr_attr, AST_MUTEX_KIND); 00463 pthread_mutex_init(<->reentr_mutex, &reentr_attr); 00464 pthread_mutexattr_destroy(&reentr_attr); 00465 }
static void ast_reentrancy_lock | ( | struct ast_lock_track * | lt | ) | [inline, static] |
Definition at line 429 of file lock.h.
References pthread_mutex_lock, and ast_lock_track::reentr_mutex.
Referenced by __ast_cond_timedwait(), __ast_cond_wait(), __ast_pthread_mutex_destroy(), __ast_pthread_mutex_lock(), __ast_pthread_mutex_trylock(), __ast_pthread_mutex_unlock(), __ast_rwlock_destroy(), __ast_rwlock_rdlock(), __ast_rwlock_timedrdlock(), __ast_rwlock_timedwrlock(), __ast_rwlock_tryrdlock(), __ast_rwlock_trywrlock(), __ast_rwlock_unlock(), __ast_rwlock_wrlock(), and append_lock_information().
00430 { 00431 pthread_mutex_lock(<->reentr_mutex); 00432 }
static void ast_reentrancy_unlock | ( | struct ast_lock_track * | lt | ) | [inline, static] |
Definition at line 434 of file lock.h.
References pthread_mutex_unlock, and ast_lock_track::reentr_mutex.
Referenced by __ast_cond_timedwait(), __ast_cond_wait(), __ast_pthread_mutex_destroy(), __ast_pthread_mutex_lock(), __ast_pthread_mutex_trylock(), __ast_pthread_mutex_unlock(), __ast_rwlock_destroy(), __ast_rwlock_rdlock(), __ast_rwlock_timedrdlock(), __ast_rwlock_timedwrlock(), __ast_rwlock_tryrdlock(), __ast_rwlock_trywrlock(), __ast_rwlock_unlock(), __ast_rwlock_wrlock(), and append_lock_information().
00435 { 00436 pthread_mutex_unlock(<->reentr_mutex); 00437 }
void ast_remove_lock_info | ( | void * | lock_addr, | |
struct ast_bt * | bt | |||
) |
remove lock info for the current thread
this gets called by ast_mutex_unlock so that information on the lock can be removed from the current thread's lock info struct.
Definition at line 676 of file utils.c.
References ast_threadstorage_get(), lock_info, thr_lock_info::num_locks, pthread_mutex_lock, pthread_mutex_unlock, and thread_lock_info.
Referenced by __ast_cond_timedwait(), __ast_cond_wait(), __ast_pthread_mutex_lock(), __ast_pthread_mutex_unlock(), __ast_rwlock_rdlock(), __ast_rwlock_unlock(), and __ast_rwlock_wrlock().
00680 { 00681 struct thr_lock_info *lock_info; 00682 int i = 0; 00683 00684 if (!(lock_info = ast_threadstorage_get(&thread_lock_info, sizeof(*lock_info)))) 00685 return; 00686 00687 pthread_mutex_lock(&lock_info->lock); 00688 00689 for (i = lock_info->num_locks - 1; i >= 0; i--) { 00690 if (lock_info->locks[i].lock_addr == lock_addr) 00691 break; 00692 } 00693 00694 if (i == -1) { 00695 /* Lock not found :( */ 00696 pthread_mutex_unlock(&lock_info->lock); 00697 return; 00698 } 00699 00700 if (lock_info->locks[i].times_locked > 1) { 00701 lock_info->locks[i].times_locked--; 00702 #ifdef HAVE_BKTR 00703 lock_info->locks[i].backtrace = bt; 00704 #endif 00705 pthread_mutex_unlock(&lock_info->lock); 00706 return; 00707 } 00708 00709 if (i < lock_info->num_locks - 1) { 00710 /* Not the last one ... *should* be rare! */ 00711 memmove(&lock_info->locks[i], &lock_info->locks[i + 1], 00712 (lock_info->num_locks - (i + 1)) * sizeof(lock_info->locks[0])); 00713 } 00714 00715 lock_info->num_locks--; 00716 00717 pthread_mutex_unlock(&lock_info->lock); 00718 }
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 | |||
) |
Store lock info for the current thread.
This function gets called in ast_mutex_lock() and ast_mutex_trylock() so that information about this lock can be stored in this thread's lock info struct. The lock is marked as pending as the thread is waiting on the lock. ast_mark_lock_acquired() will mark it as held by this thread.
Definition at line 556 of file utils.c.
References ast_threadstorage_get(), HAVE_BKTR, lock_info, pthread_mutex_lock, pthread_mutex_unlock, and thread_lock_info.
Referenced by __ast_cond_timedwait(), __ast_cond_wait(), __ast_pthread_mutex_lock(), __ast_pthread_mutex_trylock(), __ast_rwlock_rdlock(), __ast_rwlock_timedrdlock(), __ast_rwlock_timedwrlock(), __ast_rwlock_tryrdlock(), __ast_rwlock_trywrlock(), and __ast_rwlock_wrlock().
00562 { 00563 struct thr_lock_info *lock_info; 00564 int i; 00565 00566 if (!(lock_info = ast_threadstorage_get(&thread_lock_info, sizeof(*lock_info)))) 00567 return; 00568 00569 pthread_mutex_lock(&lock_info->lock); 00570 00571 for (i = 0; i < lock_info->num_locks; i++) { 00572 if (lock_info->locks[i].lock_addr == lock_addr) { 00573 lock_info->locks[i].times_locked++; 00574 #ifdef HAVE_BKTR 00575 lock_info->locks[i].backtrace = bt; 00576 #endif 00577 pthread_mutex_unlock(&lock_info->lock); 00578 return; 00579 } 00580 } 00581 00582 if (lock_info->num_locks == AST_MAX_LOCKS) { 00583 /* Can't use ast_log here, because it will cause infinite recursion */ 00584 fprintf(stderr, "XXX ERROR XXX A thread holds more locks than '%d'." 00585 " Increase AST_MAX_LOCKS!\n", AST_MAX_LOCKS); 00586 pthread_mutex_unlock(&lock_info->lock); 00587 return; 00588 } 00589 00590 if (i && lock_info->locks[i - 1].pending == -1) { 00591 /* The last lock on the list was one that this thread tried to lock but 00592 * failed at doing so. It has now moved on to something else, so remove 00593 * the old lock from the list. */ 00594 i--; 00595 lock_info->num_locks--; 00596 memset(&lock_info->locks[i], 0, sizeof(lock_info->locks[0])); 00597 } 00598 00599 lock_info->locks[i].file = filename; 00600 lock_info->locks[i].line_num = line_num; 00601 lock_info->locks[i].func = func; 00602 lock_info->locks[i].lock_name = lock_name; 00603 lock_info->locks[i].lock_addr = lock_addr; 00604 lock_info->locks[i].times_locked = 1; 00605 lock_info->locks[i].type = type; 00606 lock_info->locks[i].pending = 1; 00607 #ifdef HAVE_BKTR 00608 lock_info->locks[i].backtrace = bt; 00609 #endif 00610 lock_info->num_locks++; 00611 00612 pthread_mutex_unlock(&lock_info->lock); 00613 }
static void delete_reentrancy_cs | ( | struct ast_lock_track ** | plt | ) | [inline, static] |
Definition at line 467 of file lock.h.
References free, pthread_mutex_destroy, and ast_lock_track::reentr_mutex.
Referenced by __ast_pthread_mutex_destroy(), and __ast_rwlock_destroy().
00468 { 00469 struct ast_lock_track *lt; 00470 if (*plt) { 00471 lt = *plt; 00472 pthread_mutex_destroy(<->reentr_mutex); 00473 free(lt); 00474 *plt = NULL; 00475 } 00476 }
void log_show_lock | ( | void * | this_lock_addr | ) |
log info for the current lock with ast_log().
This function can help you find highly temporal locks; locks that happen for a short time, but at unexpected times, usually at times that create a deadlock, Why is this thing locked right then? Who is locking it? Who am I fighting with for this lock?
To answer such questions, just call this routine before you would normally try to aquire a lock. It doesn't do anything if the lock is not acquired. If the lock is taken, it will publish a line or two to the console via ast_log().
Sometimes, the lock message is pretty uninformative. For instance, you might find that the lock is being aquired deep within the astobj2 code; this tells you little about higher level routines that call the astobj2 routines. But, using gdb, you can set a break at the ast_log below, and for that breakpoint, you can set the commands: where cont which will give a stack trace and continue. -- that aught to do the job!
Definition at line 814 of file utils.c.
References append_lock_information(), AST_LIST_TRAVERSE, ast_log(), ast_str_buffer(), ast_str_create(), lock_info, lock_infos_lock, LOG_NOTICE, ast_mutex_info::mutex, pthread_mutex_lock, pthread_mutex_unlock, and str.
00815 { 00816 struct thr_lock_info *lock_info; 00817 struct ast_str *str; 00818 00819 if (!(str = ast_str_create(4096))) { 00820 ast_log(LOG_NOTICE,"Could not create str\n"); 00821 return; 00822 } 00823 00824 00825 pthread_mutex_lock(&lock_infos_lock.mutex); 00826 AST_LIST_TRAVERSE(&lock_infos, lock_info, entry) { 00827 int i; 00828 pthread_mutex_lock(&lock_info->lock); 00829 for (i = 0; str && i < lock_info->num_locks; i++) { 00830 /* ONLY show info about this particular lock, if 00831 it's acquired... */ 00832 if (lock_info->locks[i].lock_addr == this_lock_addr) { 00833 append_lock_information(&str, lock_info, i); 00834 ast_log(LOG_NOTICE, "%s", ast_str_buffer(str)); 00835 break; 00836 } 00837 } 00838 pthread_mutex_unlock(&lock_info->lock); 00839 } 00840 pthread_mutex_unlock(&lock_infos_lock.mutex); 00841 ast_free(str); 00842 }