Asterisk locking-related definitions:
#include <pthread.h>
#include <time.h>
#include <sys/param.h>
#include <execinfo.h>
#include "asterisk/logger.h"
#include "asterisk/compiler.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_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) |
#define | DEADLOCK_AVOIDANCE(lock) |
#define | DLA_LOCK(lock) ast_mutex_lock(lock) |
#define | DLA_UNLOCK(lock) ast_mutex_unlock(lock) |
#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 struct ast_mutex_info | ast_mutex_t |
typedef struct ast_rwlock_info | ast_rwlock_t |
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) |
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) |
Asterisk locking-related definitions:
Definition in file lock.h.
#define __AST_MUTEX_DEFINE | ( | scope, | |||
mutex, | |||||
init_val, | |||||
track | ) | scope ast_mutex_t mutex = init_val |
#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_pvt_destroy(), ast_audiohook_destroy(), ast_bridge_impart(), ast_bridge_join(), ast_sched_thread_destroy(), ast_smdi_interface_destroy(), bridge_channel_thread(), cdr_engine_shutdown(), do_reload(), find_idle_thread(), get_lock(), iax2_process_thread_cleanup(), init_logger(), mixmonitor_free(), 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(), build_calendar(), 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(), analog_ss_thread(), 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(), autoservice_shutdown(), calendar_destructor(), close_logger(), conf_free(), conf_run(), db_sync(), defer_full_frame(), devstate_change_collector_cb(), dial_trunk(), lock_broker(), login_exec(), 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(), agent_request(), announce_thread(), ast_localtime_wakeup_monitor(), autoservice_run(), bridge_channel_join_multithreaded(), bridge_channel_join_singlethreaded(), dahdi_restart(), db_sync_thread(), do_devstate_changes(), do_timing(), find_idle_thread(), iax2_process_thread(), logger_thread(), login_exec(), mixmonitor_thread(), run_devstate_collector(), sched_run(), sla_handle_dial_state_event(), sla_station_exec(), sla_thread(), start_network_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_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(), and __ast_rwlock_wrlock().
#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 __ast_internal_context_destroy(), __oh323_destroy(), __unload_module(), agent_pvt_destroy(), ast_audiohook_destroy(), ast_bridge_impart(), ast_bridge_join(), ast_dial_destroy(), ast_dnsmgr_release(), ast_sched_thread_destroy(), ast_smdi_interface_destroy(), ast_speech_destroy(), ast_speech_new(), auth_http_callback(), bridge_channel_thread(), bridge_hangup(), build_conf(), build_device(), build_gateway(), chan_list_destructor(), close_client(), conf_free(), destroy_conference_bridge(), destroy_dahdi_pvt(), destroy_endpoint(), destroy_session(), do_monitor(), find_idle_thread(), find_realtime(), free_config(), generic_http_callback(), get_lock(), iax2_process_thread_cleanup(), init_logger(), internal_ao2_ref(), load_module(), mgcp_prune_realtime_gateway(), misdn_cfg_destroy(), misdn_jb_destroy(), mixmonitor_free(), odbc_obj_destructor(), reload_config(), sched_context_destroy(), session_do(), 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_family(), 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(), auth_http_callback(), bridge_request(), build_conf(), build_device(), build_gateway(), 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(), generic_http_callback(), get_lock(), gtalk_alloc(), ical_load_calendar(), init_logger(), init_timing_thread(), internal_ao2_alloc(), jingle_alloc(), join_conference_bridge(), load_config(), load_module(), misdn_cfg_init(), misdn_jb_init(), mkintf(), oh323_alloc(), read_config(), sched_context_create(), session_do(), setup_mixmonitor_ds(), skinny_new(), sla_handle_dial_state_event(), sla_load_config(), sla_station_exec(), softmix_bridge_join(), and start_network_thread().
#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(), 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 __ast_alloc_region(), __ast_realloc(), __attempt_transmit(), __auth_reject(), __auto_congest(), __auto_hangup(), __dahdi_exception(), __find_callno(), __get_from_jb(), __iax2_poke_noanswer(), __oh323_new(), __reload(), __send_lagrq(), __send_ping(), __unload_module(), _ast_odbc_request_obj2(), _sip_tcp_helper_thread(), _unload_module(), acf_channel_read(), acf_jabberreceive_read(), action_agents(), action_dahdishowchannels(), add_notify(), adsi_delete(), adsi_message(), agent_ack_sleep(), agent_call(), agent_cleanup(), agent_cont_sleep(), agent_devicestate(), agent_digit_begin(), agent_digit_end(), agent_fixup(), agent_hangup(), agent_indicate(), agent_lock_owner(), agent_logoff(), 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_submit_batch(), ast_cel_check_retire_linkedid(), ast_cel_engine_term(), ast_cel_linkedid_ref(), ast_cel_report_event(), ast_cli_netstats(), ast_config_engine_deregister(), ast_config_engine_register(), ast_context_lockmacro(), ast_db_del(), ast_db_put(), ast_dial_join(), ast_dnsmgr_changed(), ast_features_reload(), ast_get_enum(), ast_iax2_new(), ast_merge_contexts_and_delete(), ast_monitor_start(), ast_odbc_direct_execute(), ast_odbc_find_table(), ast_odbc_prepare_and_execute(), ast_odbc_smart_execute(), 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(), astdb_init(), astdb_shutdown(), auth_reject(), authenticate_reply(), auto_hangup(), blr_ebl(), blr_txt(), bridge_channel_join_multithreaded(), bridge_channel_join_singlethreaded(), bridge_hangup(), bridge_write(), build_device(), build_profile(), build_reply_digest(), caldav_load_calendar(), can_safely_quit(), cb_events(), cdr_handler(), check_availability(), check_beep(), cl_dequeue_chan(), cl_queue_chan(), clear_config_maps(), cli_tps_ping(), close_client(), close_mailbox(), conf_free(), conf_run(), config_device(), config_handler(), config_line(), config_load(), config_module(), 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_handle_event(), dahdi_hangup(), dahdi_indicate(), dahdi_request(), dahdi_restart(), dahdi_set_dnd(), dahdi_set_hwgain(), dahdi_set_swgain(), dahdi_show_channel(), dahdi_show_channels(), dahdi_softhangup_all(), dahdi_unlink(), data_odbc_provider_handler(), db_get_common(), 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(), dnsmgr_shutdown(), do_cdr(), do_monitor(), do_refresh(), do_reload(), do_timing(), 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_table(), find_tpeer(), freed_regions_flush(), 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_abort_shutdown(), handle_capabilities_res_message(), handle_cli_core_show_config_mappings(), 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_cli_status(), handle_deferred_full_frames(), handle_init_event(), handle_memory_show_allocations(), handle_memory_show_summary(), handle_mgcp_audit_endpoint(), handle_mgcp_show_endpoints(), handle_modlist(), handle_register_message(), handle_request(), handle_request_do(), handle_speechrecognize(), handle_statechange(), 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(), 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(), meetme_menu_admin_extended(), 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(), mm_atexit_final(), mwi_monitor_handler(), my_decrease_ss_count(), my_handle_dtmf(), my_increase_ss_count(), my_lock_private(), 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_provider(), osp_create_transaction(), osp_get_provider(), osp_unload(), parse_config(), parsing(), pbx_load_module(), peer_destructor(), pgsql_log(), phone_request(), play_message(), play_sound_file(), private_enum_init(), process_db_keys(), prune_gateways(), pthread_timer_open(), pvt_destructor(), queue_ringing_trunk(), 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(), region_free(), region_remove(), regions_check_all_fences(), register_verify(), registry_authrequest(), release_chan(), release_chan_early(), reload(), reload_config(), reload_followme(), reqprep(), require_pgsql(), restart_monitor(), restart_pktc_thread(), retrans_pkt(), 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_hangup_source_and_cause(), set_pvt_defaults(), setup_dahdi_int(), signal_condition(), sip_reload(), sip_show_settings(), sip_tcptls_write(), skinny_get_rtp_peer(), skinny_hangup(), skinny_read(), skinny_req_parse(), skinny_write(), 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_network_thread(), start_rtp(), stop_mixmonitor_exec(), stop_poll_thread(), store_pgsql(), stun_monitor_request(), stun_stop_monitor(), submit_scheduled_batch(), 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(), 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(), vm_instructions_en(), 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(), refresh_list(), socket_process(), 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 __ast_alloc_region(), __ast_realloc(), __attempt_transmit(), __auth_reject(), __auto_congest(), __auto_hangup(), __dahdi_exception(), __find_callno(), __get_from_jb(), __iax2_poke_noanswer(), __oh323_destroy(), __oh323_new(), __oh323_rtp_create(), __reload(), __send_lagrq(), __send_ping(), __unload_module(), _ast_odbc_request_obj2(), _sip_tcp_helper_thread(), _unload_module(), acf_channel_read(), acf_jabberreceive_read(), action_agents(), action_dahdishowchannels(), add_notify(), adsi_delete(), adsi_message(), agent_ack_sleep(), agent_call(), agent_cleanup(), agent_cont_sleep(), agent_devicestate(), agent_digit_begin(), agent_digit_end(), agent_fixup(), agent_hangup(), agent_indicate(), agent_lock_owner(), agent_logoff(), 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_submit_batch(), ast_cel_check_retire_linkedid(), ast_cel_engine_term(), ast_cel_linkedid_ref(), 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_put(), ast_dial_join(), ast_dnsmgr_changed(), ast_features_reload(), ast_get_enum(), ast_iax2_new(), ast_merge_contexts_and_delete(), ast_module_reload(), ast_monitor_start(), ast_odbc_direct_execute(), ast_odbc_find_table(), ast_odbc_prepare_and_execute(), ast_odbc_smart_execute(), ast_random(), 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_unlock_contexts(), ast_unreplace_sigchld(), astdb_init(), astdb_shutdown(), auth_reject(), authenticate_reply(), auto_hangup(), blr_ebl(), blr_txt(), bridge_channel_join_multithreaded(), bridge_channel_join_singlethreaded(), bridge_hangup(), bridge_queue_hangup(), bridge_write(), build_device(), build_profile(), build_reply_digest(), cache_get_callno_locked(), caldav_load_calendar(), can_safely_quit(), 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(), close_mailbox(), conf_free(), conf_run(), config_device(), config_handler(), config_line(), config_load(), config_module(), 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_fixup(), dahdi_func_read(), dahdi_func_write(), dahdi_handle_dtmf(), dahdi_handle_event(), dahdi_hangup(), dahdi_indicate(), dahdi_read(), dahdi_request(), dahdi_restart(), dahdi_set_dnd(), dahdi_set_hwgain(), dahdi_set_swgain(), dahdi_show_channel(), dahdi_show_channels(), dahdi_softhangup_all(), dahdi_unlink(), data_odbc_provider_handler(), db_get_common(), 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(), dnsmgr_shutdown(), do_cdr(), do_monitor(), do_refresh(), do_reload(), do_timing(), 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_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_table(), freed_regions_flush(), 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_abort_shutdown(), handle_capabilities_res_message(), handle_cli_core_show_config_mappings(), 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_cli_status(), handle_deferred_full_frames(), handle_init_event(), handle_memory_show_allocations(), handle_memory_show_summary(), handle_mgcp_audit_endpoint(), handle_mgcp_show_endpoints(), handle_modlist(), handle_register_message(), handle_request(), handle_request_do(), handle_speechrecognize(), handle_statechange(), hangup_connection(), 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(), lock_broker(), log_jitterstats(), login_exec(), lua_free_extensions(), lua_load_extensions(), lua_reload_extensions(), make_trunk(), mansession_unlock(), mb_poll_thread(), meetme_menu_admin_extended(), 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_request(), mgcp_senddigit_begin(), mgcp_senddigit_end(), mgcp_write(), mgcpsock_read(), misdn_cfg_unlock(), misdn_chan_is_valid(), misdn_hangup(), misdn_jb_empty(), misdn_jb_fill(), misdn_overlap_dial_task(), mixmonitor_ds_destroy(), mixmonitor_thread(), mm_atexit_final(), mwi_monitor_handler(), my_decrease_ss_count(), my_handle_dtmf(), my_increase_ss_count(), my_unlock_private(), 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_provider(), osp_create_transaction(), osp_get_provider(), osp_unload(), parse_config(), parsing(), pbx_load_module(), peer_destructor(), pgsql_log(), phone_request(), play_message(), play_sound_file(), private_enum_init(), process_db_keys(), progress(), prune_gateways(), pthread_timer_open(), pvt_destructor(), queue_ringing_trunk(), 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(), region_free(), region_remove(), regions_check_all_fences(), register_verify(), registry_authrequest(), release_chan(), release_chan_early(), reload(), reload_config(), reload_followme(), remote_hold(), reqprep(), require_pgsql(), restart_monitor(), restart_pktc_thread(), retrans_pkt(), 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_hangup_source_and_cause(), set_local_capabilities(), set_peer_capabilities(), set_pvt_defaults(), setup_dahdi_int(), setup_rtp_connection(), signal_condition(), sip_reload(), sip_show_settings(), sip_tcptls_write(), skinny_get_rtp_peer(), skinny_hangup(), skinny_read(), skinny_req_parse(), skinny_write(), 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_network_thread(), start_rtp(), stop_mixmonitor_exec(), stop_poll_thread(), store_pgsql(), stun_monitor_request(), stun_stop_monitor(), submit_scheduled_batch(), 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(), 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(), vm_instructions_en(), 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(), actual_load_config(), add_notify(), ast_autoservice_start(), ast_autoservice_stop(), ast_bridge_destroy(), 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(), autoservice_shutdown(), bridge_channel_join(), bridge_poke(), bridge_thread(), build_calendar(), build_conf(), build_mansession(), calendar_event_notify(), cdr_engine_shutdown(), close_logger(), conf_free(), conf_run(), console_verboser(), dahdi_restart(), dnsmgr_shutdown(), do_reload(), generic_http_callback(), get_input(), init_pvt(), inotify_daemon(), load_module(), meetme_menu_admin_extended(), moh_class_destructor(), monitor_sig_flags(), multiplexed_add_or_remove(), multiplexed_bridge_create(), multiplexed_nudge(), multiplexed_thread_function(), network_thread(), process_clearcache(), process_precache(), really_quit(), restart_monitor(), restart_pktc_thread(), sla_destroy(), sla_load_config(), sla_queue_event_full(), smart_bridge_operation(), smdi_load(), 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(), dahdi_restart(), monitor_dial(), multiplexed_add_or_remove(), multiplexed_thread_function(), restart_monitor(), restart_pktc_thread(), 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(), data_shutdown(), 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_adsi_available(), ast_adsi_begin_download(), ast_adsi_channel_restore(), ast_adsi_clear_screen(), ast_adsi_clear_soft_keys(), ast_adsi_connect_session(), ast_adsi_data_mode(), ast_adsi_disconnect_session(), ast_adsi_display(), ast_adsi_download_connect(), ast_adsi_download_disconnect(), ast_adsi_end_download(), ast_adsi_get_cpeid(), ast_adsi_get_cpeinfo(), ast_adsi_input_control(), ast_adsi_input_format(), ast_adsi_load_session(), ast_adsi_load_soft_key(), ast_adsi_print(), ast_adsi_query_cpeid(), ast_adsi_query_cpeinfo(), ast_adsi_read_encoded_dtmf(), ast_adsi_set_keys(), ast_adsi_set_line(), ast_adsi_transmit_message(), ast_adsi_transmit_message_full(), ast_adsi_unload_session(), ast_adsi_voice_mode(), 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(), get_general_options(), 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_adsi_available(), ast_adsi_begin_download(), ast_adsi_channel_restore(), ast_adsi_clear_screen(), ast_adsi_clear_soft_keys(), ast_adsi_connect_session(), ast_adsi_data_mode(), ast_adsi_disconnect_session(), ast_adsi_display(), ast_adsi_download_connect(), ast_adsi_download_disconnect(), ast_adsi_end_download(), ast_adsi_get_cpeid(), ast_adsi_get_cpeinfo(), ast_adsi_input_control(), ast_adsi_input_format(), ast_adsi_install_funcs(), ast_adsi_load_session(), ast_adsi_load_soft_key(), ast_adsi_print(), ast_adsi_query_cpeid(), ast_adsi_query_cpeinfo(), ast_adsi_read_encoded_dtmf(), ast_adsi_set_keys(), ast_adsi_set_line(), ast_adsi_transmit_message(), ast_adsi_transmit_message_full(), ast_adsi_unload_session(), ast_adsi_voice_mode(), 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(), get_general_options(), 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(), set_general_options(), 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_adsi_install_funcs(), 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(), set_general_options(), and unmap_features().
#define CHANNEL_DEADLOCK_AVOIDANCE | ( | chan | ) |
ast_channel_unlock(chan); \ usleep(1); \ ast_channel_lock(chan);
Definition at line 480 of file lock.h.
Referenced by awesome_locking(), bridge_queue_hangup(), bridge_write(), dahdi_bridge(), dahdi_handle_event(), dahdi_read(), dial_exec_full(), misdn_attempt_transfer(), and sip_hangup().
#define DEADLOCK_AVOIDANCE | ( | lock | ) |
Definition at line 485 of file lock.h.
Referenced by agent_logoff(), agent_read(), dahdi_lock_sub_owner(), 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(), socket_process(), and wait_for_peercallno().
Definition at line 498 of file lock.h.
Referenced by dahdi_handle_event().
Definition at line 496 of file lock.h.
Referenced by dahdi_handle_event().
#define gethostbyname __gethostbyname__is__not__reentrant__use__ast_gethostbyname__instead__ |
Definition at line 570 of file lock.h.
Referenced by connect_sphinx().
#define pthread_cond_broadcast use_ast_cond_broadcast_instead_of_pthread_cond_broadcast |
Definition at line 564 of file lock.h.
Referenced by __ast_cond_broadcast().
#define pthread_cond_destroy use_ast_cond_destroy_instead_of_pthread_cond_destroy |
Definition at line 562 of file lock.h.
Referenced by __ast_cond_destroy().
#define pthread_cond_init use_ast_cond_init_instead_of_pthread_cond_init |
Definition at line 561 of file lock.h.
Referenced by __ast_cond_init().
#define pthread_cond_signal use_ast_cond_signal_instead_of_pthread_cond_signal |
Definition at line 563 of file lock.h.
Referenced by __ast_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 |
Definition at line 566 of file lock.h.
Referenced by __ast_cond_timedwait().
#define pthread_cond_wait use_ast_cond_wait_instead_of_pthread_cond_wait |
Definition at line 565 of file lock.h.
Referenced by __ast_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(), 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(), 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(), dummy_start(), find_free_chan_in_stack(), handle_event_nt(), handle_frm_nt(), handle_l1(), handle_timers(), 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(), dummy_start(), find_free_chan_in_stack(), handle_event_nt(), handle_frm_nt(), handle_l1(), handle_timers(), 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 |
int __ast_cond_broadcast | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
const char * | cond_name, | |||
ast_cond_t * | cond | |||
) |
Definition at line 496 of file lock.c.
References pthread_cond_broadcast.
00498 { 00499 return pthread_cond_broadcast(cond); 00500 }
int __ast_cond_destroy | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
const char * | cond_name, | |||
ast_cond_t * | cond | |||
) |
Definition at line 502 of file lock.c.
References pthread_cond_destroy.
00504 { 00505 return pthread_cond_destroy(cond); 00506 }
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 484 of file lock.c.
References pthread_cond_init.
00486 { 00487 return pthread_cond_init(cond, cond_attr); 00488 }
int __ast_cond_signal | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
const char * | cond_name, | |||
ast_cond_t * | cond | |||
) |
Definition at line 490 of file lock.c.
References pthread_cond_signal.
00492 { 00493 return pthread_cond_signal(cond); 00494 }
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 589 of file lock.c.
References __ast_pthread_mutex_init(), ast_lock_track::backtrace, 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::reentr_mutex, ast_lock_track::reentrancy, ROFFSET, ast_lock_track::thread, ast_mutex_info::track, and ast_mutex_info::tracking.
00592 { 00593 int res; 00594 00595 #ifdef DEBUG_THREADS 00596 struct ast_lock_track *lt; 00597 struct ast_lock_track lt_orig; 00598 int canlog = strcmp(filename, "logger.c") & t->tracking; 00599 00600 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00601 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00602 __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n", 00603 filename, lineno, func, mutex_name); 00604 res = __ast_pthread_mutex_init(t->tracking, filename, lineno, func, mutex_name, t); 00605 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00606 __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n", 00607 filename, lineno, func, mutex_name); 00608 } 00609 return res; 00610 } 00611 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00612 00613 if (t->tracking && !t->track) { 00614 ast_reentrancy_init(&t->track); 00615 } 00616 lt = t->track; 00617 00618 if (t->tracking) { 00619 ast_reentrancy_lock(lt); 00620 if (lt->reentrancy && (lt->thread[ROFFSET] != pthread_self())) { 00621 __ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n", 00622 filename, lineno, func, mutex_name); 00623 __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n", 00624 lt->file[ROFFSET], lt->lineno[ROFFSET], lt->func[ROFFSET], mutex_name); 00625 #ifdef HAVE_BKTR 00626 __dump_backtrace(<->backtrace[ROFFSET], canlog); 00627 #endif 00628 DO_THREAD_CRASH; 00629 } else if (lt->reentrancy <= 0) { 00630 __ast_mutex_logger("%s line %d (%s): attempted to wait on an unlocked mutex '%s'\n", 00631 filename, lineno, func, mutex_name); 00632 DO_THREAD_CRASH; 00633 } 00634 00635 /* Waiting on a condition completely suspends a recursive mutex, 00636 * even if it's been recursively locked multiple times. Make a 00637 * copy of the lock tracking, and reset reentrancy to zero */ 00638 lt_orig = *lt; 00639 lt->reentrancy = 0; 00640 ast_reentrancy_unlock(lt); 00641 00642 ast_suspend_lock_info(t); 00643 } 00644 #endif /* DEBUG_THREADS */ 00645 00646 res = pthread_cond_timedwait(cond, &t->mutex, abstime); 00647 00648 #ifdef DEBUG_THREADS 00649 if (res && (res != ETIMEDOUT)) { 00650 __ast_mutex_logger("%s line %d (%s): Error waiting on condition mutex '%s'\n", 00651 filename, lineno, func, strerror(res)); 00652 DO_THREAD_CRASH; 00653 } else if (t->tracking) { 00654 pthread_mutex_t reentr_mutex_orig; 00655 ast_reentrancy_lock(lt); 00656 /* Restore lock tracking to what it was prior to the wait */ 00657 reentr_mutex_orig = lt->reentr_mutex; 00658 *lt = lt_orig; 00659 /* un-trash the mutex we just copied over */ 00660 lt->reentr_mutex = reentr_mutex_orig; 00661 ast_reentrancy_unlock(lt); 00662 00663 ast_suspend_lock_info(t); 00664 } 00665 #endif /* DEBUG_THREADS */ 00666 00667 return res; 00668 }
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 508 of file lock.c.
References __ast_pthread_mutex_init(), ast_lock_track::backtrace, 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::reentr_mutex, ast_lock_track::reentrancy, ROFFSET, ast_lock_track::thread, ast_mutex_info::track, and ast_mutex_info::tracking.
00511 { 00512 int res; 00513 00514 #ifdef DEBUG_THREADS 00515 struct ast_lock_track *lt; 00516 struct ast_lock_track lt_orig; 00517 int canlog = strcmp(filename, "logger.c") & t->tracking; 00518 00519 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00520 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00521 __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n", 00522 filename, lineno, func, mutex_name); 00523 res = __ast_pthread_mutex_init(t->tracking, filename, lineno, func, mutex_name, t); 00524 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00525 __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n", 00526 filename, lineno, func, mutex_name); 00527 } 00528 return res; 00529 } 00530 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00531 00532 if (t->tracking && !t->track) { 00533 ast_reentrancy_init(&t->track); 00534 } 00535 lt = t->track; 00536 00537 if (t->tracking) { 00538 ast_reentrancy_lock(lt); 00539 if (lt->reentrancy && (lt->thread[ROFFSET] != pthread_self())) { 00540 __ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n", 00541 filename, lineno, func, mutex_name); 00542 __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n", 00543 lt->file[ROFFSET], lt->lineno[ROFFSET], lt->func[ROFFSET], mutex_name); 00544 #ifdef HAVE_BKTR 00545 __dump_backtrace(<->backtrace[ROFFSET], canlog); 00546 #endif 00547 DO_THREAD_CRASH; 00548 } else if (lt->reentrancy <= 0) { 00549 __ast_mutex_logger("%s line %d (%s): attempted to wait on an unlocked mutex '%s'\n", 00550 filename, lineno, func, mutex_name); 00551 DO_THREAD_CRASH; 00552 } 00553 00554 /* Waiting on a condition completely suspends a recursive mutex, 00555 * even if it's been recursively locked multiple times. Make a 00556 * copy of the lock tracking, and reset reentrancy to zero */ 00557 lt_orig = *lt; 00558 lt->reentrancy = 0; 00559 ast_reentrancy_unlock(lt); 00560 00561 ast_suspend_lock_info(t); 00562 } 00563 #endif /* DEBUG_THREADS */ 00564 00565 res = pthread_cond_wait(cond, &t->mutex); 00566 00567 #ifdef DEBUG_THREADS 00568 if (res) { 00569 __ast_mutex_logger("%s line %d (%s): Error waiting on condition mutex '%s'\n", 00570 filename, lineno, func, strerror(res)); 00571 DO_THREAD_CRASH; 00572 } else if (t->tracking) { 00573 pthread_mutex_t reentr_mutex_orig; 00574 ast_reentrancy_lock(lt); 00575 /* Restore lock tracking to what it was prior to the wait */ 00576 reentr_mutex_orig = lt->reentr_mutex; 00577 *lt = lt_orig; 00578 /* un-trash the mutex we just copied over */ 00579 lt->reentr_mutex = reentr_mutex_orig; 00580 ast_reentrancy_unlock(lt); 00581 00582 ast_restore_lock_info(t); 00583 } 00584 #endif /* DEBUG_THREADS */ 00585 00586 return res; 00587 }
int __ast_pthread_mutex_destroy | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
const char * | mutex_name, | |||
ast_mutex_t * | t | |||
) |
Definition at line 99 of file lock.c.
References ast_lock_track::backtrace, 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.
00101 { 00102 int res; 00103 00104 #ifdef DEBUG_THREADS 00105 struct ast_lock_track *lt; 00106 int canlog = strcmp(filename, "logger.c") & t->tracking; 00107 00108 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00109 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00110 /* Don't try to uninitialize non initialized mutex 00111 * This may no effect on linux 00112 * And always ganerate core on *BSD with 00113 * linked libpthread 00114 * This not error condition if the mutex created on the fly. 00115 */ 00116 __ast_mutex_logger("%s line %d (%s): NOTICE: mutex '%s' is uninitialized.\n", 00117 filename, lineno, func, mutex_name); 00118 return 0; 00119 } 00120 #endif 00121 00122 if (t->tracking && !t->track) { 00123 ast_reentrancy_init(&t->track); 00124 } 00125 lt = t->track; 00126 00127 res = pthread_mutex_trylock(&t->mutex); 00128 switch (res) { 00129 case 0: 00130 pthread_mutex_unlock(&t->mutex); 00131 break; 00132 case EINVAL: 00133 __ast_mutex_logger("%s line %d (%s): Error: attempt to destroy invalid mutex '%s'.\n", 00134 filename, lineno, func, mutex_name); 00135 break; 00136 case EBUSY: 00137 __ast_mutex_logger("%s line %d (%s): Error: attempt to destroy locked mutex '%s'.\n", 00138 filename, lineno, func, mutex_name); 00139 if (t->tracking) { 00140 ast_reentrancy_lock(lt); 00141 __ast_mutex_logger("%s line %d (%s): Error: '%s' was locked here.\n", 00142 lt->file[ROFFSET], lt->lineno[ROFFSET], lt->func[ROFFSET], mutex_name); 00143 #ifdef HAVE_BKTR 00144 __dump_backtrace(<->backtrace[ROFFSET], canlog); 00145 #endif 00146 ast_reentrancy_unlock(lt); 00147 } 00148 break; 00149 } 00150 #endif /* DEBUG_THREADS */ 00151 00152 res = pthread_mutex_destroy(&t->mutex); 00153 00154 #ifdef DEBUG_THREADS 00155 if (res) { 00156 __ast_mutex_logger("%s line %d (%s): Error destroying mutex %s: %s\n", 00157 filename, lineno, func, mutex_name, strerror(res)); 00158 } 00159 if (t->tracking) { 00160 ast_reentrancy_lock(lt); 00161 lt->file[0] = filename; 00162 lt->lineno[0] = lineno; 00163 lt->func[0] = func; 00164 lt->reentrancy = 0; 00165 lt->thread[0] = 0; 00166 #ifdef HAVE_BKTR 00167 memset(<->backtrace[0], 0, sizeof(lt->backtrace[0])); 00168 #endif 00169 ast_reentrancy_unlock(lt); 00170 delete_reentrancy_cs(&t->track); 00171 } 00172 #endif /* DEBUG_THREADS */ 00173 00174 return res; 00175 }
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 65 of file lock.c.
References AST_MUTEX_KIND, 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().
00067 { 00068 int res; 00069 pthread_mutexattr_t attr; 00070 00071 #ifdef DEBUG_THREADS 00072 t->track = NULL; 00073 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00074 if ((t->mutex) != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00075 /* 00076 int canlog = strcmp(filename, "logger.c") & track; 00077 __ast_mutex_logger("%s line %d (%s): NOTICE: mutex '%s' is already initialized.\n", 00078 filename, lineno, func, mutex_name); 00079 DO_THREAD_CRASH; 00080 */ 00081 return 0; 00082 } 00083 00084 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00085 00086 if ((t->tracking = tracking)) { 00087 ast_reentrancy_init(&t->track); 00088 } 00089 #endif /* DEBUG_THREADS */ 00090 00091 pthread_mutexattr_init(&attr); 00092 pthread_mutexattr_settype(&attr, AST_MUTEX_KIND); 00093 00094 res = pthread_mutex_init(&t->mutex, &attr); 00095 pthread_mutexattr_destroy(&attr); 00096 return res; 00097 }
int __ast_pthread_mutex_lock | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
const char * | mutex_name, | |||
ast_mutex_t * | t | |||
) |
Definition at line 177 of file lock.c.
References __ast_pthread_mutex_init(), ast_bt_get_addresses(), ast_mark(), AST_MAX_REENTRANCY, ast_lock_track::backtrace, 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_lock_track::thread, ast_mutex_info::track, and ast_mutex_info::tracking.
Referenced by __ao2_lock().
00179 { 00180 int res; 00181 00182 #ifdef DEBUG_THREADS 00183 struct ast_lock_track *lt; 00184 int canlog = strcmp(filename, "logger.c") & t->tracking; 00185 #ifdef HAVE_BKTR 00186 struct ast_bt *bt = NULL; 00187 #endif 00188 00189 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00190 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00191 /* Don't warn abount uninitialized mutex. 00192 * Simple try to initialize it. 00193 * May be not needed in linux system. 00194 */ 00195 res = __ast_pthread_mutex_init(t->tracking, filename, lineno, func, mutex_name, t); 00196 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00197 __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n", 00198 filename, lineno, func, mutex_name); 00199 return res; 00200 } 00201 } 00202 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00203 00204 if (t->tracking && !t->track) { 00205 ast_reentrancy_init(&t->track); 00206 } 00207 lt = t->track; 00208 00209 if (t->tracking) { 00210 #ifdef HAVE_BKTR 00211 struct ast_bt tmp; 00212 00213 /* The implementation of backtrace() may have its own locks. 00214 * Capture the backtrace outside of the reentrancy lock to 00215 * avoid deadlocks. See ASTERISK-22455. */ 00216 ast_bt_get_addresses(&tmp); 00217 00218 ast_reentrancy_lock(lt); 00219 if (lt->reentrancy != AST_MAX_REENTRANCY) { 00220 lt->backtrace[lt->reentrancy] = tmp; 00221 bt = <->backtrace[lt->reentrancy]; 00222 } 00223 ast_reentrancy_unlock(lt); 00224 00225 ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t, bt); 00226 #else 00227 ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t); 00228 #endif 00229 } 00230 #endif /* DEBUG_THREADS */ 00231 00232 #if defined(DETECT_DEADLOCKS) && defined(DEBUG_THREADS) 00233 { 00234 time_t seconds = time(NULL); 00235 time_t wait_time, reported_wait = 0; 00236 do { 00237 #ifdef HAVE_MTX_PROFILE 00238 ast_mark(mtx_prof, 1); 00239 #endif 00240 res = pthread_mutex_trylock(&t->mutex); 00241 #ifdef HAVE_MTX_PROFILE 00242 ast_mark(mtx_prof, 0); 00243 #endif 00244 if (res == EBUSY) { 00245 wait_time = time(NULL) - seconds; 00246 if (wait_time > reported_wait && (wait_time % 5) == 0) { 00247 __ast_mutex_logger("%s line %d (%s): Deadlock? waited %d sec for mutex '%s'?\n", 00248 filename, lineno, func, (int) wait_time, mutex_name); 00249 ast_reentrancy_lock(lt); 00250 #ifdef HAVE_BKTR 00251 __dump_backtrace(<->backtrace[lt->reentrancy], canlog); 00252 #endif 00253 __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n", 00254 lt->file[ROFFSET], lt->lineno[ROFFSET], 00255 lt->func[ROFFSET], mutex_name); 00256 #ifdef HAVE_BKTR 00257 __dump_backtrace(<->backtrace[ROFFSET], canlog); 00258 #endif 00259 ast_reentrancy_unlock(lt); 00260 reported_wait = wait_time; 00261 } 00262 usleep(200); 00263 } 00264 } while (res == EBUSY); 00265 } 00266 #else /* !DETECT_DEADLOCKS || !DEBUG_THREADS */ 00267 #ifdef HAVE_MTX_PROFILE 00268 ast_mark(mtx_prof, 1); 00269 res = pthread_mutex_trylock(&t->mutex); 00270 ast_mark(mtx_prof, 0); 00271 if (res) 00272 #endif 00273 res = pthread_mutex_lock(&t->mutex); 00274 #endif /* !DETECT_DEADLOCKS || !DEBUG_THREADS */ 00275 00276 #ifdef DEBUG_THREADS 00277 if (t->tracking && !res) { 00278 ast_reentrancy_lock(lt); 00279 if (lt->reentrancy < AST_MAX_REENTRANCY) { 00280 lt->file[lt->reentrancy] = filename; 00281 lt->lineno[lt->reentrancy] = lineno; 00282 lt->func[lt->reentrancy] = func; 00283 lt->thread[lt->reentrancy] = pthread_self(); 00284 lt->reentrancy++; 00285 } else { 00286 __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n", 00287 filename, lineno, func, mutex_name); 00288 } 00289 ast_reentrancy_unlock(lt); 00290 if (t->tracking) { 00291 ast_mark_lock_acquired(t); 00292 } 00293 } else if (t->tracking) { 00294 #ifdef HAVE_BKTR 00295 if (lt->reentrancy) { 00296 ast_reentrancy_lock(lt); 00297 bt = <->backtrace[lt->reentrancy-1]; 00298 ast_reentrancy_unlock(lt); 00299 } else { 00300 bt = NULL; 00301 } 00302 ast_remove_lock_info(t, bt); 00303 #else 00304 ast_remove_lock_info(t); 00305 #endif 00306 } 00307 if (res) { 00308 __ast_mutex_logger("%s line %d (%s): Error obtaining mutex: %s\n", 00309 filename, lineno, func, strerror(res)); 00310 DO_THREAD_CRASH; 00311 } 00312 #endif /* DEBUG_THREADS */ 00313 00314 return res; 00315 }
int __ast_pthread_mutex_trylock | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
const char * | mutex_name, | |||
ast_mutex_t * | t | |||
) |
Definition at line 317 of file lock.c.
References __ast_pthread_mutex_init(), ast_bt_get_addresses(), AST_MAX_REENTRANCY, ast_lock_track::backtrace, ast_lock_track::file, ast_lock_track::func, ast_lock_track::lineno, ast_mutex_info::mutex, pthread_mutex_t, pthread_mutex_trylock, ast_lock_track::reentrancy, ast_lock_track::thread, ast_mutex_info::track, and ast_mutex_info::tracking.
Referenced by __ao2_trylock().
00319 { 00320 int res; 00321 00322 #ifdef DEBUG_THREADS 00323 struct ast_lock_track *lt; 00324 int canlog = strcmp(filename, "logger.c") & t->tracking; 00325 #ifdef HAVE_BKTR 00326 struct ast_bt *bt = NULL; 00327 #endif 00328 00329 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00330 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00331 /* Don't warn abount uninitialized mutex. 00332 * Simple try to initialize it. 00333 * May be not needed in linux system. 00334 */ 00335 res = __ast_pthread_mutex_init(t->tracking, filename, lineno, func, mutex_name, t); 00336 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00337 __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n", 00338 filename, lineno, func, mutex_name); 00339 return res; 00340 } 00341 } 00342 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00343 00344 if (t->tracking && !t->track) { 00345 ast_reentrancy_init(&t->track); 00346 } 00347 lt = t->track; 00348 00349 if (t->tracking) { 00350 #ifdef HAVE_BKTR 00351 struct ast_bt tmp; 00352 00353 /* The implementation of backtrace() may have its own locks. 00354 * Capture the backtrace outside of the reentrancy lock to 00355 * avoid deadlocks. See ASTERISK-22455. */ 00356 ast_bt_get_addresses(&tmp); 00357 00358 ast_reentrancy_lock(lt); 00359 if (lt->reentrancy != AST_MAX_REENTRANCY) { 00360 lt->backtrace[lt->reentrancy] = tmp; 00361 bt = <->backtrace[lt->reentrancy]; 00362 } 00363 ast_reentrancy_unlock(lt); 00364 00365 ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t, bt); 00366 #else 00367 ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t); 00368 #endif 00369 } 00370 #endif /* DEBUG_THREADS */ 00371 00372 res = pthread_mutex_trylock(&t->mutex); 00373 00374 #ifdef DEBUG_THREADS 00375 if (t->tracking && !res) { 00376 ast_reentrancy_lock(lt); 00377 if (lt->reentrancy < AST_MAX_REENTRANCY) { 00378 lt->file[lt->reentrancy] = filename; 00379 lt->lineno[lt->reentrancy] = lineno; 00380 lt->func[lt->reentrancy] = func; 00381 lt->thread[lt->reentrancy] = pthread_self(); 00382 lt->reentrancy++; 00383 } else { 00384 __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n", 00385 filename, lineno, func, mutex_name); 00386 } 00387 ast_reentrancy_unlock(lt); 00388 if (t->tracking) { 00389 ast_mark_lock_acquired(t); 00390 } 00391 } else if (t->tracking) { 00392 ast_mark_lock_failed(t); 00393 } 00394 #endif /* DEBUG_THREADS */ 00395 00396 return res; 00397 }
int __ast_pthread_mutex_unlock | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
const char * | mutex_name, | |||
ast_mutex_t * | t | |||
) |
Definition at line 399 of file lock.c.
References __ast_pthread_mutex_init(), AST_MAX_REENTRANCY, ast_lock_track::backtrace, 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().
00401 { 00402 int res; 00403 00404 #ifdef DEBUG_THREADS 00405 struct ast_lock_track *lt; 00406 int canlog = strcmp(filename, "logger.c") & t->tracking; 00407 #ifdef HAVE_BKTR 00408 struct ast_bt *bt = NULL; 00409 #endif 00410 00411 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00412 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00413 __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n", 00414 filename, lineno, func, mutex_name); 00415 res = __ast_pthread_mutex_init(t->tracking, filename, lineno, func, mutex_name, t); 00416 if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) { 00417 __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n", 00418 filename, lineno, func, mutex_name); 00419 } 00420 return res; 00421 } 00422 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00423 00424 if (t->tracking && !t->track) { 00425 ast_reentrancy_init(&t->track); 00426 } 00427 lt = t->track; 00428 00429 if (t->tracking) { 00430 ast_reentrancy_lock(lt); 00431 if (lt->reentrancy && (lt->thread[ROFFSET] != pthread_self())) { 00432 __ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n", 00433 filename, lineno, func, mutex_name); 00434 __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n", 00435 lt->file[ROFFSET], lt->lineno[ROFFSET], lt->func[ROFFSET], mutex_name); 00436 #ifdef HAVE_BKTR 00437 __dump_backtrace(<->backtrace[ROFFSET], canlog); 00438 #endif 00439 DO_THREAD_CRASH; 00440 } 00441 00442 if (--lt->reentrancy < 0) { 00443 __ast_mutex_logger("%s line %d (%s): mutex '%s' freed more times than we've locked!\n", 00444 filename, lineno, func, mutex_name); 00445 lt->reentrancy = 0; 00446 } 00447 00448 if (lt->reentrancy < AST_MAX_REENTRANCY) { 00449 lt->file[lt->reentrancy] = NULL; 00450 lt->lineno[lt->reentrancy] = 0; 00451 lt->func[lt->reentrancy] = NULL; 00452 lt->thread[lt->reentrancy] = 0; 00453 } 00454 00455 #ifdef HAVE_BKTR 00456 if (lt->reentrancy) { 00457 bt = <->backtrace[lt->reentrancy - 1]; 00458 } 00459 #endif 00460 ast_reentrancy_unlock(lt); 00461 00462 #ifdef HAVE_BKTR 00463 ast_remove_lock_info(t, bt); 00464 #else 00465 ast_remove_lock_info(t); 00466 #endif 00467 } 00468 #endif /* DEBUG_THREADS */ 00469 00470 res = pthread_mutex_unlock(&t->mutex); 00471 00472 #ifdef DEBUG_THREADS 00473 if (res) { 00474 __ast_mutex_logger("%s line %d (%s): Error releasing mutex: %s\n", 00475 filename, lineno, func, strerror(res)); 00476 DO_THREAD_CRASH; 00477 } 00478 #endif /* DEBUG_THREADS */ 00479 00480 return res; 00481 }
int __ast_rwlock_destroy | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
const char * | rwlock_name, | |||
ast_rwlock_t * | t | |||
) |
Definition at line 703 of file lock.c.
References __AST_RWLOCK_INIT_VALUE, 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.
00704 { 00705 int res; 00706 00707 #ifdef DEBUG_THREADS 00708 struct ast_lock_track *lt = t->track; 00709 int canlog = strcmp(filename, "logger.c") & t->tracking; 00710 00711 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00712 if (t->lock == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 00713 __ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is uninitialized.\n", 00714 filename, lineno, func, rwlock_name); 00715 return 0; 00716 } 00717 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00718 00719 #endif /* DEBUG_THREADS */ 00720 00721 res = pthread_rwlock_destroy(&t->lock); 00722 00723 #ifdef DEBUG_THREADS 00724 if (res) { 00725 __ast_mutex_logger("%s line %d (%s): Error destroying rwlock %s: %s\n", 00726 filename, lineno, func, rwlock_name, strerror(res)); 00727 } 00728 if (t->tracking && lt) { 00729 ast_reentrancy_lock(lt); 00730 lt->file[0] = filename; 00731 lt->lineno[0] = lineno; 00732 lt->func[0] = func; 00733 lt->reentrancy = 0; 00734 lt->thread[0] = 0; 00735 #ifdef HAVE_BKTR 00736 memset(<->backtrace[0], 0, sizeof(lt->backtrace[0])); 00737 #endif 00738 ast_reentrancy_unlock(lt); 00739 delete_reentrancy_cs(&t->track); 00740 } 00741 #endif /* DEBUG_THREADS */ 00742 00743 return res; 00744 }
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 670 of file lock.c.
References __AST_RWLOCK_INIT_VALUE, 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().
00671 { 00672 int res; 00673 pthread_rwlockattr_t attr; 00674 00675 #ifdef DEBUG_THREADS 00676 00677 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00678 int canlog = strcmp(filename, "logger.c") & t->tracking; 00679 00680 if (t->lock != ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 00681 __ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is already initialized.\n", 00682 filename, lineno, func, rwlock_name); 00683 return 0; 00684 } 00685 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00686 00687 if ((t->tracking = tracking)) { 00688 ast_reentrancy_init(&t->track); 00689 } 00690 #endif /* DEBUG_THREADS */ 00691 00692 pthread_rwlockattr_init(&attr); 00693 00694 #ifdef HAVE_PTHREAD_RWLOCK_PREFER_WRITER_NP 00695 pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NP); 00696 #endif 00697 00698 res = pthread_rwlock_init(&t->lock, &attr); 00699 pthread_rwlockattr_destroy(&attr); 00700 return res; 00701 }
int __ast_rwlock_rdlock | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
ast_rwlock_t * | t, | |||
const char * | name | |||
) |
Definition at line 832 of file lock.c.
References __ast_rwlock_init(), __AST_RWLOCK_INIT_VALUE, ast_bt_get_addresses(), AST_MAX_REENTRANCY, 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.
Referenced by __ast_heap_rdlock().
00833 { 00834 int res; 00835 00836 #ifdef DEBUG_THREADS 00837 struct ast_lock_track *lt; 00838 int canlog = strcmp(filename, "logger.c") & t->tracking; 00839 #ifdef HAVE_BKTR 00840 struct ast_bt *bt = NULL; 00841 #endif 00842 00843 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00844 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 00845 /* Don't warn abount uninitialized lock. 00846 * Simple try to initialize it. 00847 * May be not needed in linux system. 00848 */ 00849 res = __ast_rwlock_init(t->tracking, filename, line, func, name, t); 00850 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 00851 __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n", 00852 filename, line, func, name); 00853 return res; 00854 } 00855 } 00856 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00857 00858 if (t->tracking && !t->track) { 00859 ast_reentrancy_init(&t->track); 00860 } 00861 lt = t->track; 00862 00863 if (t->tracking) { 00864 #ifdef HAVE_BKTR 00865 struct ast_bt tmp; 00866 00867 /* The implementation of backtrace() may have its own locks. 00868 * Capture the backtrace outside of the reentrancy lock to 00869 * avoid deadlocks. See ASTERISK-22455. */ 00870 ast_bt_get_addresses(&tmp); 00871 00872 ast_reentrancy_lock(lt); 00873 if (lt->reentrancy != AST_MAX_REENTRANCY) { 00874 lt->backtrace[lt->reentrancy] = tmp; 00875 bt = <->backtrace[lt->reentrancy]; 00876 } 00877 ast_reentrancy_unlock(lt); 00878 00879 ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t, bt); 00880 #else 00881 ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t); 00882 #endif 00883 } 00884 #endif /* DEBUG_THREADS */ 00885 00886 #if defined(DETECT_DEADLOCKS) && defined(DEBUG_THREADS) 00887 { 00888 time_t seconds = time(NULL); 00889 time_t wait_time, reported_wait = 0; 00890 do { 00891 res = pthread_rwlock_tryrdlock(&t->lock); 00892 if (res == EBUSY) { 00893 wait_time = time(NULL) - seconds; 00894 if (wait_time > reported_wait && (wait_time % 5) == 0) { 00895 __ast_mutex_logger("%s line %d (%s): Deadlock? waited %d sec for readlock '%s'?\n", 00896 filename, line, func, (int)wait_time, name); 00897 if (t->tracking) { 00898 ast_reentrancy_lock(lt); 00899 #ifdef HAVE_BKTR 00900 __dump_backtrace(<->backtrace[lt->reentrancy], canlog); 00901 #endif 00902 __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n", 00903 lt->file[lt->reentrancy-1], lt->lineno[lt->reentrancy-1], 00904 lt->func[lt->reentrancy-1], name); 00905 #ifdef HAVE_BKTR 00906 __dump_backtrace(<->backtrace[lt->reentrancy-1], canlog); 00907 #endif 00908 ast_reentrancy_unlock(lt); 00909 } 00910 reported_wait = wait_time; 00911 } 00912 usleep(200); 00913 } 00914 } while (res == EBUSY); 00915 } 00916 #else /* !DETECT_DEADLOCKS || !DEBUG_THREADS */ 00917 res = pthread_rwlock_rdlock(&t->lock); 00918 #endif /* !DETECT_DEADLOCKS || !DEBUG_THREADS */ 00919 00920 #ifdef DEBUG_THREADS 00921 if (!res && t->tracking) { 00922 ast_reentrancy_lock(lt); 00923 if (lt->reentrancy < AST_MAX_REENTRANCY) { 00924 lt->file[lt->reentrancy] = filename; 00925 lt->lineno[lt->reentrancy] = line; 00926 lt->func[lt->reentrancy] = func; 00927 lt->thread[lt->reentrancy] = pthread_self(); 00928 lt->reentrancy++; 00929 } 00930 ast_reentrancy_unlock(lt); 00931 if (t->tracking) { 00932 ast_mark_lock_acquired(t); 00933 } 00934 } else if (t->tracking) { 00935 #ifdef HAVE_BKTR 00936 if (lt->reentrancy) { 00937 ast_reentrancy_lock(lt); 00938 bt = <->backtrace[lt->reentrancy-1]; 00939 ast_reentrancy_unlock(lt); 00940 } else { 00941 bt = NULL; 00942 } 00943 ast_remove_lock_info(t, bt); 00944 #else 00945 ast_remove_lock_info(t); 00946 #endif 00947 } 00948 00949 if (res) { 00950 __ast_mutex_logger("%s line %d (%s): Error obtaining read lock: %s\n", 00951 filename, line, func, strerror(res)); 00952 DO_THREAD_CRASH; 00953 } 00954 #endif /* DEBUG_THREADS */ 00955 00956 return res; 00957 }
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_rwlock_init(), __AST_RWLOCK_INIT_VALUE, ast_bt_get_addresses(), AST_MAX_REENTRANCY, ast_tvnow(), 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.
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 struct ast_bt tmp; 01124 01125 /* The implementation of backtrace() may have its own locks. 01126 * Capture the backtrace outside of the reentrancy lock to 01127 * avoid deadlocks. See ASTERISK-22455. */ 01128 ast_bt_get_addresses(&tmp); 01129 01130 ast_reentrancy_lock(lt); 01131 if (lt->reentrancy != AST_MAX_REENTRANCY) { 01132 lt->backtrace[lt->reentrancy] = tmp; 01133 bt = <->backtrace[lt->reentrancy]; 01134 } 01135 ast_reentrancy_unlock(lt); 01136 01137 ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt); 01138 #else 01139 ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t); 01140 #endif 01141 } 01142 #endif /* DEBUG_THREADS */ 01143 01144 #ifdef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK 01145 res = pthread_rwlock_timedrdlock(&t->lock, abs_timeout); 01146 #else 01147 do { 01148 struct timeval _now; 01149 for (;;) { 01150 if (!(res = pthread_rwlock_tryrdlock(&t->lock))) { 01151 break; 01152 } 01153 _now = ast_tvnow(); 01154 if (_now.tv_sec > abs_timeout->tv_sec || (_now.tv_sec == abs_timeout->tv_sec && _now.tv_usec * 1000 > abs_timeout->tv_nsec)) { 01155 break; 01156 } 01157 usleep(1); 01158 } 01159 } while (0); 01160 #endif 01161 01162 #ifdef DEBUG_THREADS 01163 if (!res && t->tracking) { 01164 ast_reentrancy_lock(lt); 01165 if (lt->reentrancy < AST_MAX_REENTRANCY) { 01166 lt->file[lt->reentrancy] = filename; 01167 lt->lineno[lt->reentrancy] = line; 01168 lt->func[lt->reentrancy] = func; 01169 lt->thread[lt->reentrancy] = pthread_self(); 01170 lt->reentrancy++; 01171 } 01172 ast_reentrancy_unlock(lt); 01173 if (t->tracking) { 01174 ast_mark_lock_acquired(t); 01175 } 01176 } else if (t->tracking) { 01177 #ifdef HAVE_BKTR 01178 if (lt->reentrancy) { 01179 ast_reentrancy_lock(lt); 01180 bt = <->backtrace[lt->reentrancy-1]; 01181 ast_reentrancy_unlock(lt); 01182 } else { 01183 bt = NULL; 01184 } 01185 ast_remove_lock_info(t, bt); 01186 #else 01187 ast_remove_lock_info(t); 01188 #endif 01189 } 01190 if (res) { 01191 __ast_mutex_logger("%s line %d (%s): Error obtaining read lock: %s\n", 01192 filename, line, func, strerror(res)); 01193 DO_THREAD_CRASH; 01194 } 01195 #endif /* DEBUG_THREADS */ 01196 01197 return res; 01198 }
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 1200 of file lock.c.
References __ast_rwlock_init(), __AST_RWLOCK_INIT_VALUE, ast_bt_get_addresses(), AST_MAX_REENTRANCY, ast_tvnow(), 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.
01202 { 01203 int res; 01204 01205 #ifdef DEBUG_THREADS 01206 struct ast_lock_track *lt; 01207 int canlog = strcmp(filename, "logger.c") & t->tracking; 01208 #ifdef HAVE_BKTR 01209 struct ast_bt *bt = NULL; 01210 #endif 01211 01212 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 01213 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 01214 /* Don't warn abount uninitialized lock. 01215 * Simple try to initialize it. 01216 * May be not needed in linux system. 01217 */ 01218 res = __ast_rwlock_init(t->tracking, filename, line, func, name, t); 01219 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 01220 __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n", 01221 filename, line, func, name); 01222 return res; 01223 } 01224 } 01225 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 01226 01227 if (t->tracking && !t->track) { 01228 ast_reentrancy_init(&t->track); 01229 } 01230 lt = t->track; 01231 01232 if (t->tracking) { 01233 #ifdef HAVE_BKTR 01234 struct ast_bt tmp; 01235 01236 /* The implementation of backtrace() may have its own locks. 01237 * Capture the backtrace outside of the reentrancy lock to 01238 * avoid deadlocks. See ASTERISK-22455. */ 01239 ast_bt_get_addresses(&tmp); 01240 01241 ast_reentrancy_lock(lt); 01242 if (lt->reentrancy != AST_MAX_REENTRANCY) { 01243 lt->backtrace[lt->reentrancy] = tmp; 01244 bt = <->backtrace[lt->reentrancy]; 01245 } 01246 ast_reentrancy_unlock(lt); 01247 01248 ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt); 01249 #else 01250 ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t); 01251 #endif 01252 } 01253 #endif /* DEBUG_THREADS */ 01254 01255 #ifdef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK 01256 res = pthread_rwlock_timedwrlock(&t->lock, abs_timeout); 01257 #else 01258 do { 01259 struct timeval _now; 01260 for (;;) { 01261 if (!(res = pthread_rwlock_trywrlock(&t->lock))) { 01262 break; 01263 } 01264 _now = ast_tvnow(); 01265 if (_now.tv_sec > abs_timeout->tv_sec || (_now.tv_sec == abs_timeout->tv_sec && _now.tv_usec * 1000 > abs_timeout->tv_nsec)) { 01266 break; 01267 } 01268 usleep(1); 01269 } 01270 } while (0); 01271 #endif 01272 01273 #ifdef DEBUG_THREADS 01274 if (!res && t->tracking) { 01275 ast_reentrancy_lock(lt); 01276 if (lt->reentrancy < AST_MAX_REENTRANCY) { 01277 lt->file[lt->reentrancy] = filename; 01278 lt->lineno[lt->reentrancy] = line; 01279 lt->func[lt->reentrancy] = func; 01280 lt->thread[lt->reentrancy] = pthread_self(); 01281 lt->reentrancy++; 01282 } 01283 ast_reentrancy_unlock(lt); 01284 if (t->tracking) { 01285 ast_mark_lock_acquired(t); 01286 } 01287 } else if (t->tracking) { 01288 #ifdef HAVE_BKTR 01289 if (lt->reentrancy) { 01290 ast_reentrancy_lock(lt); 01291 bt = <->backtrace[lt->reentrancy-1]; 01292 ast_reentrancy_unlock(lt); 01293 } else { 01294 bt = NULL; 01295 } 01296 if (t->tracking) { 01297 ast_remove_lock_info(t, bt); 01298 } 01299 #else 01300 if (t->tracking) { 01301 ast_remove_lock_info(t); 01302 } 01303 #endif 01304 } 01305 if (res) { 01306 __ast_mutex_logger("%s line %d (%s): Error obtaining read lock: %s\n", 01307 filename, line, func, strerror(res)); 01308 DO_THREAD_CRASH; 01309 } 01310 #endif /* DEBUG_THREADS */ 01311 01312 return res; 01313 }
int __ast_rwlock_tryrdlock | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
ast_rwlock_t * | t, | |||
const char * | name | |||
) |
Definition at line 1315 of file lock.c.
References __ast_rwlock_init(), __AST_RWLOCK_INIT_VALUE, ast_bt_get_addresses(), AST_MAX_REENTRANCY, 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.
01316 { 01317 int res; 01318 01319 #ifdef DEBUG_THREADS 01320 struct ast_lock_track *lt; 01321 #ifdef HAVE_BKTR 01322 struct ast_bt *bt = NULL; 01323 #endif 01324 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 01325 int canlog = strcmp(filename, "logger.c") & t->tracking; 01326 01327 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 01328 /* Don't warn abount uninitialized lock. 01329 * Simple try to initialize it. 01330 * May be not needed in linux system. 01331 */ 01332 res = __ast_rwlock_init(t->tracking, filename, line, func, name, t); 01333 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 01334 __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n", 01335 filename, line, func, name); 01336 return res; 01337 } 01338 } 01339 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 01340 01341 if (t->tracking && !t->track) { 01342 ast_reentrancy_init(&t->track); 01343 } 01344 lt = t->track; 01345 01346 if (t->tracking) { 01347 #ifdef HAVE_BKTR 01348 struct ast_bt tmp; 01349 01350 /* The implementation of backtrace() may have its own locks. 01351 * Capture the backtrace outside of the reentrancy lock to 01352 * avoid deadlocks. See ASTERISK-22455. */ 01353 ast_bt_get_addresses(&tmp); 01354 01355 ast_reentrancy_lock(lt); 01356 if (lt->reentrancy != AST_MAX_REENTRANCY) { 01357 lt->backtrace[lt->reentrancy] = tmp; 01358 bt = <->backtrace[lt->reentrancy]; 01359 } 01360 ast_reentrancy_unlock(lt); 01361 01362 ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t, bt); 01363 #else 01364 ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t); 01365 #endif 01366 } 01367 #endif /* DEBUG_THREADS */ 01368 01369 res = pthread_rwlock_tryrdlock(&t->lock); 01370 01371 #ifdef DEBUG_THREADS 01372 if (!res && t->tracking) { 01373 ast_reentrancy_lock(lt); 01374 if (lt->reentrancy < AST_MAX_REENTRANCY) { 01375 lt->file[lt->reentrancy] = filename; 01376 lt->lineno[lt->reentrancy] = line; 01377 lt->func[lt->reentrancy] = func; 01378 lt->thread[lt->reentrancy] = pthread_self(); 01379 lt->reentrancy++; 01380 } 01381 ast_reentrancy_unlock(lt); 01382 if (t->tracking) { 01383 ast_mark_lock_acquired(t); 01384 } 01385 } else if (t->tracking) { 01386 ast_mark_lock_failed(t); 01387 } 01388 #endif /* DEBUG_THREADS */ 01389 01390 return res; 01391 }
int __ast_rwlock_trywrlock | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
ast_rwlock_t * | t, | |||
const char * | name | |||
) |
Definition at line 1393 of file lock.c.
References __ast_rwlock_init(), __AST_RWLOCK_INIT_VALUE, ast_bt_get_addresses(), AST_MAX_REENTRANCY, 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.
01394 { 01395 int res; 01396 01397 #ifdef DEBUG_THREADS 01398 struct ast_lock_track *lt; 01399 #ifdef HAVE_BKTR 01400 struct ast_bt *bt = NULL; 01401 #endif 01402 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 01403 int canlog = strcmp(filename, "logger.c") & t->tracking; 01404 01405 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 01406 /* Don't warn abount uninitialized lock. 01407 * Simple try to initialize it. 01408 * May be not needed in linux system. 01409 */ 01410 res = __ast_rwlock_init(t->tracking, filename, line, func, name, t); 01411 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 01412 __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n", 01413 filename, line, func, name); 01414 return res; 01415 } 01416 } 01417 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 01418 01419 if (t->tracking && !t->track) { 01420 ast_reentrancy_init(&t->track); 01421 } 01422 lt = t->track; 01423 01424 if (t->tracking) { 01425 #ifdef HAVE_BKTR 01426 struct ast_bt tmp; 01427 01428 /* The implementation of backtrace() may have its own locks. 01429 * Capture the backtrace outside of the reentrancy lock to 01430 * avoid deadlocks. See ASTERISK-22455. */ 01431 ast_bt_get_addresses(&tmp); 01432 01433 ast_reentrancy_lock(lt); 01434 if (lt->reentrancy != AST_MAX_REENTRANCY) { 01435 lt->backtrace[lt->reentrancy] = tmp; 01436 bt = <->backtrace[lt->reentrancy]; 01437 } 01438 ast_reentrancy_unlock(lt); 01439 01440 ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt); 01441 #else 01442 ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t); 01443 #endif 01444 } 01445 #endif /* DEBUG_THREADS */ 01446 01447 res = pthread_rwlock_trywrlock(&t->lock); 01448 01449 #ifdef DEBUG_THREADS 01450 if (!res && t->tracking) { 01451 ast_reentrancy_lock(lt); 01452 if (lt->reentrancy < AST_MAX_REENTRANCY) { 01453 lt->file[lt->reentrancy] = filename; 01454 lt->lineno[lt->reentrancy] = line; 01455 lt->func[lt->reentrancy] = func; 01456 lt->thread[lt->reentrancy] = pthread_self(); 01457 lt->reentrancy++; 01458 } 01459 ast_reentrancy_unlock(lt); 01460 ast_mark_lock_acquired(t); 01461 } else if (t->tracking) { 01462 ast_mark_lock_failed(t); 01463 } 01464 #endif /* DEBUG_THREADS */ 01465 01466 return res; 01467 }
int __ast_rwlock_unlock | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
ast_rwlock_t * | t, | |||
const char * | name | |||
) |
Definition at line 746 of file lock.c.
References __ast_rwlock_init(), __AST_RWLOCK_INIT_VALUE, AST_PTHREADT_NULL, 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.
Referenced by __ast_heap_unlock().
00747 { 00748 int res; 00749 00750 #ifdef DEBUG_THREADS 00751 struct ast_lock_track *lt; 00752 int canlog = strcmp(filename, "logger.c") & t->tracking; 00753 #ifdef HAVE_BKTR 00754 struct ast_bt *bt = NULL; 00755 #endif 00756 int lock_found = 0; 00757 00758 00759 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00760 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 00761 __ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is uninitialized.\n", 00762 filename, line, func, name); 00763 res = __ast_rwlock_init(t->tracking, filename, line, func, name, t); 00764 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 00765 __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n", 00766 filename, line, func, name); 00767 } 00768 return res; 00769 } 00770 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00771 00772 if (t->tracking && !t->track) { 00773 ast_reentrancy_init(&t->track); 00774 } 00775 lt = t->track; 00776 00777 if (t->tracking) { 00778 ast_reentrancy_lock(lt); 00779 if (lt->reentrancy) { 00780 int i; 00781 pthread_t self = pthread_self(); 00782 for (i = lt->reentrancy - 1; i >= 0; --i) { 00783 if (lt->thread[i] == self) { 00784 lock_found = 1; 00785 if (i != lt->reentrancy - 1) { 00786 lt->file[i] = lt->file[lt->reentrancy - 1]; 00787 lt->lineno[i] = lt->lineno[lt->reentrancy - 1]; 00788 lt->func[i] = lt->func[lt->reentrancy - 1]; 00789 lt->thread[i] = lt->thread[lt->reentrancy - 1]; 00790 } 00791 #ifdef HAVE_BKTR 00792 bt = <->backtrace[i]; 00793 #endif 00794 lt->file[lt->reentrancy - 1] = NULL; 00795 lt->lineno[lt->reentrancy - 1] = 0; 00796 lt->func[lt->reentrancy - 1] = NULL; 00797 lt->thread[lt->reentrancy - 1] = AST_PTHREADT_NULL; 00798 break; 00799 } 00800 } 00801 } 00802 00803 if (lock_found && --lt->reentrancy < 0) { 00804 __ast_mutex_logger("%s line %d (%s): rwlock '%s' freed more times than we've locked!\n", 00805 filename, line, func, name); 00806 lt->reentrancy = 0; 00807 } 00808 00809 ast_reentrancy_unlock(lt); 00810 00811 #ifdef HAVE_BKTR 00812 ast_remove_lock_info(t, bt); 00813 #else 00814 ast_remove_lock_info(t); 00815 #endif 00816 } 00817 #endif /* DEBUG_THREADS */ 00818 00819 res = pthread_rwlock_unlock(&t->lock); 00820 00821 #ifdef DEBUG_THREADS 00822 if (res) { 00823 __ast_mutex_logger("%s line %d (%s): Error releasing rwlock: %s\n", 00824 filename, line, func, strerror(res)); 00825 DO_THREAD_CRASH; 00826 } 00827 #endif /* DEBUG_THREADS */ 00828 00829 return res; 00830 }
int __ast_rwlock_wrlock | ( | const char * | filename, | |
int | lineno, | |||
const char * | func, | |||
ast_rwlock_t * | t, | |||
const char * | name | |||
) |
Definition at line 959 of file lock.c.
References __ast_rwlock_init(), __AST_RWLOCK_INIT_VALUE, ast_bt_get_addresses(), AST_MAX_REENTRANCY, 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.
Referenced by __ast_heap_wrlock().
00960 { 00961 int res; 00962 00963 #ifdef DEBUG_THREADS 00964 struct ast_lock_track *lt; 00965 int canlog = strcmp(filename, "logger.c") & t->tracking; 00966 #ifdef HAVE_BKTR 00967 struct ast_bt *bt = NULL; 00968 #endif 00969 00970 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE) 00971 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 00972 /* Don't warn abount uninitialized lock. 00973 * Simple try to initialize it. 00974 * May be not needed in linux system. 00975 */ 00976 res = __ast_rwlock_init(t->tracking, filename, line, func, name, t); 00977 if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) { 00978 __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n", 00979 filename, line, func, name); 00980 return res; 00981 } 00982 } 00983 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */ 00984 00985 if (t->tracking && !t->track) { 00986 ast_reentrancy_init(&t->track); 00987 } 00988 lt = t->track; 00989 00990 if (t->tracking) { 00991 #ifdef HAVE_BKTR 00992 struct ast_bt tmp; 00993 00994 /* The implementation of backtrace() may have its own locks. 00995 * Capture the backtrace outside of the reentrancy lock to 00996 * avoid deadlocks. See ASTERISK-22455. */ 00997 ast_bt_get_addresses(&tmp); 00998 00999 ast_reentrancy_lock(lt); 01000 if (lt->reentrancy != AST_MAX_REENTRANCY) { 01001 lt->backtrace[lt->reentrancy] = tmp; 01002 bt = <->backtrace[lt->reentrancy]; 01003 } 01004 ast_reentrancy_unlock(lt); 01005 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 }
__inline__ 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.
Definition at line 649 of file lock.h.
Referenced by dispose_conf(), iax2_process_thread_cleanup(), run_station(), and sla_station_exec().
__inline__ 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.
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(), acf_odbc_read(), action_login(), add_subscribe_event(), admin_exec(), advance_event(), append_event(), ast_channel_destructor(), ast_cli_command_full(), ast_dial_append(), ast_event_subscribe_new(), ast_module_ref(), ast_module_unref(), ast_undestroyed_channels(), authenticate_verify(), build_conf(), build_peer(), cc_device_monitor_init(), cc_extension_monitor_init(), cc_interfaces_datastore_init(), cdr_seq_inc(), container_destruct(), container_destruct_debug(), 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(), find_transcoders(), 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_iterator_next(), internal_ao2_link(), internal_ao2_ref(), load_realtime_queue(), local_new(), receivefax_exec(), reload_single_queue(), run_station(), sendfax_exec(), session_destructor(), session_do(), 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(), 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 2078 of file utils.c.
References ast_mutex_lock, ast_mutex_unlock, and fetchadd_m.
02079 { 02080 int ret; 02081 ast_mutex_lock(&fetchadd_m); 02082 ret = *p; 02083 *p += v; 02084 ast_mutex_unlock(&fetchadd_m); 02085 return ret; 02086 }