Wed Apr 6 11:30:06 2011

Asterisk developer's documentation


lock.h File Reference

Asterisk locking-related definitions: More...

#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   { AST_LOCK_TRACK_INIT_VALUE, 1, PTHREAD_MUTEX_INIT_VALUE }
#define AST_MUTEX_INIT_VALUE_NOTRACKING   { AST_LOCK_TRACK_INIT_VALUE, 0, PTHREAD_MUTEX_INIT_VALUE }
#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_LOCK_TRACK_INIT_VALUE, 1, __AST_RWLOCK_INIT_VALUE }
#define AST_RWLOCK_INIT_VALUE_NOTRACKING   { AST_LOCK_TRACK_INIT_VALUE, 0, __AST_RWLOCK_INIT_VALUE }
#define ast_rwlock_rdlock(a)   __ast_rwlock_rdlock(a, #a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ast_rwlock_timedrdlock(a, b)   __ast_rwlock_timedrdlock(a, #a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ast_rwlock_timedwrlock(a, b)   __ast_rwlock_timedwrlock(a, #a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ast_rwlock_tryrdlock(a)   __ast_rwlock_tryrdlock(a, #a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ast_rwlock_trywrlock(a)   __ast_rwlock_trywrlock(a, #a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ast_rwlock_unlock(a)   __ast_rwlock_unlock(a, #a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ast_rwlock_wrlock(a)   __ast_rwlock_wrlock(a, #a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#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 ast_mutex_info ast_mutex_t
typedef 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 (ast_rwlock_t *t, const char *name, const char *filename, int line, const char *func)
int __ast_rwlock_timedrdlock (ast_rwlock_t *t, const char *name, const struct timespec *abs_timeout, const char *filename, int line, const char *func)
int __ast_rwlock_timedwrlock (ast_rwlock_t *t, const char *name, const struct timespec *abs_timeout, const char *filename, int line, const char *func)
int __ast_rwlock_tryrdlock (ast_rwlock_t *t, const char *name, const char *filename, int line, const char *func)
int __ast_rwlock_trywrlock (ast_rwlock_t *t, const char *name, const char *filename, int line, const char *func)
int __ast_rwlock_unlock (ast_rwlock_t *t, const char *name, const char *filename, int line, const char *func)
int __ast_rwlock_wrlock (ast_rwlock_t *t, const char *name, const char *filename, int line, const char *func)
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)


Detailed Description

Asterisk locking-related definitions:

Definition in file lock.h.


Define Documentation

#define __AST_MUTEX_DEFINE ( scope,
mutex,
init_val,
track   )     scope ast_mutex_t mutex = init_val

Definition at line 512 of file lock.h.

#define __AST_RWLOCK_DEFINE ( scope,
rwlock,
init_val,
track   )     scope ast_rwlock_t rwlock = init_val

Definition at line 535 of file lock.h.

#define __AST_RWLOCK_INIT_VALUE   PTHREAD_RWLOCK_INITIALIZER

Definition at line 83 of file lock.h.

Referenced by __ast_rwlock_destroy(), __ast_rwlock_init(), __ast_rwlock_rdlock(), __ast_rwlock_timedrdlock(), __ast_rwlock_timedwrlock(), __ast_rwlock_tryrdlock(), __ast_rwlock_trywrlock(), __ast_rwlock_unlock(), and __ast_rwlock_wrlock().

#define ast_cond_broadcast ( cond   )     __ast_cond_broadcast(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond)

Definition at line 170 of file lock.h.

Referenced by aji_handle_message(), ast_smdi_md_message_push(), ast_smdi_md_message_putback(), ast_smdi_mwi_message_push(), ast_smdi_mwi_message_putback(), and inotify_daemon().

#define ast_cond_destroy ( cond   )     __ast_cond_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond)

Definition at line 168 of file lock.h.

Referenced by __unload_module(), agent_cleanup(), agent_hangup(), ast_audiohook_destroy(), ast_bridge_impart(), ast_bridge_join(), ast_sched_thread_destroy(), ast_smdi_interface_destroy(), bridge_channel_thread(), do_reload(), find_idle_thread(), get_lock(), iax2_process_thread_cleanup(), init_logger(), login_exec(), mixmonitor_free(), read_agent_config(), setup_mixmonitor_ds(), sla_destroy(), sla_handle_dial_state_event(), sla_station_exec(), start_network_thread(), tps_taskprocessor_destroy(), and unload_module().

#define ast_cond_init ( cond,
attr   )     __ast_cond_init(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond, attr)

Definition at line 167 of file lock.h.

Referenced by add_agent(), add_notify(), alloc_smdi_interface(), ast_audiohook_init(), ast_autoservice_init(), ast_bridge_impart(), ast_bridge_join(), ast_device_state_engine_init(), ast_enable_distributed_devstate(), ast_sched_thread_create(), ast_taskprocessor_get(), ast_tps_init(), astdb_init(), do_reload(), find_idle_thread(), get_lock(), init_logger(), init_timing_thread(), load_module(), setup_mixmonitor_ds(), sla_handle_dial_state_event(), sla_load_config(), sla_station_exec(), and start_network_thread().

#define ast_cond_signal ( cond   )     __ast_cond_signal(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond)

Definition at line 169 of file lock.h.

Referenced by _unload_module(), agent_cleanup(), agent_hangup(), agent_new(), ast_audiohook_update_status(), ast_audiohook_write_frame(), ast_autoservice_start(), ast_bridge_change_state(), ast_bridge_merge(), ast_devstate_changed_literal(), ast_log(), ast_sched_thread_add(), ast_sched_thread_add_variable(), ast_sched_thread_destroy(), ast_sched_thread_poke(), ast_taskprocessor_push(), calendar_destructor(), close_logger(), conf_free(), conf_run(), db_sync(), devstate_change_collector_cb(), dial_trunk(), lock_broker(), mixmonitor_ds_destroy(), my_decrease_ss_count(), pthread_timer_open(), run_station(), schedule_calendar_event(), signal_condition(), sla_destroy(), sla_queue_event_full(), smart_bridge_operation(), stop_mixmonitor_exec(), stop_poll_thread(), submit_unscheduled_batch(), tps_ping_handler(), tps_taskprocessor_destroy(), and unload_module().

#define ast_cond_timedwait ( cond,
mutex,
time   )     __ast_cond_timedwait(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #mutex, cond, mutex, time)

Definition at line 172 of file lock.h.

Referenced by acf_jabberreceive_read(), ast_audiohook_trigger_wait(), caldav_load_calendar(), cli_tps_ping(), do_cdr(), do_refresh(), do_timing(), ewscal_load_calendar(), exchangecal_load_calendar(), get_lock(), iax2_process_thread(), ical_load_calendar(), mb_poll_thread(), mwi_monitor_handler(), sched_run(), sla_thread(), and smdi_message_wait().

#define ast_cond_wait ( cond,
mutex   )     __ast_cond_wait(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #mutex, cond, mutex)

Definition at line 171 of file lock.h.

Referenced by add_notify(), announce_thread(), ast_localtime_wakeup_monitor(), autoservice_run(), bridge_channel_join_singlethreaded(), db_sync_thread(), do_devstate_changes(), do_timing(), find_idle_thread(), logger_thread(), login_exec(), mixmonitor_thread(), run_devstate_collector(), sched_run(), sla_handle_dial_state_event(), sla_station_exec(), sla_thread(), and tps_processing_function().

#define AST_LOCK_TRACK_INIT_VALUE   { { NULL }, { 0 }, 0, { NULL }, { 0 }, {{{ 0 }}}, PTHREAD_MUTEX_INIT_VALUE }

Definition at line 89 of file lock.h.

#define AST_MAX_REENTRANCY   10

Definition at line 100 of file lock.h.

Referenced by __ast_cond_timedwait(), __ast_cond_wait(), __ast_pthread_mutex_lock(), __ast_pthread_mutex_trylock(), __ast_pthread_mutex_unlock(), __ast_rwlock_rdlock(), __ast_rwlock_timedrdlock(), __ast_rwlock_timedwrlock(), __ast_rwlock_tryrdlock(), __ast_rwlock_trywrlock(), and __ast_rwlock_wrlock().

#define AST_MUTEX_DEFINE_STATIC ( mutex   )     __AST_MUTEX_DEFINE(static, mutex, AST_MUTEX_INIT_VALUE, 1)

Definition at line 515 of file lock.h.

#define AST_MUTEX_DEFINE_STATIC_NOTRACKING ( mutex   )     __AST_MUTEX_DEFINE(static, mutex, AST_MUTEX_INIT_VALUE_NOTRACKING, 0)

Definition at line 516 of file lock.h.

#define ast_mutex_destroy (  )     __ast_pthread_mutex_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a)

Definition at line 154 of file lock.h.

Referenced by __oh323_destroy(), __unload_module(), agent_cleanup(), agent_hangup(), ast_audiohook_destroy(), ast_bridge_impart(), ast_bridge_join(), ast_dnsmgr_release(), ast_sched_thread_destroy(), ast_smdi_interface_destroy(), ast_speech_destroy(), ast_speech_new(), bridge_channel_thread(), bridge_hangup(), build_device(), chan_list_destructor(), close_client(), destroy_conference_bridge(), destroy_dahdi_pvt(), destroy_session(), do_monitor(), find_idle_thread(), find_realtime(), free_config(), get_lock(), iax2_process_thread_cleanup(), internal_ao2_ref(), load_module(), login_exec(), misdn_cfg_destroy(), misdn_jb_destroy(), mixmonitor_free(), odbc_obj_destructor(), read_agent_config(), reload_config(), sched_context_destroy(), session_instance_destructor(), setup_mixmonitor_ds(), sla_destroy(), sla_handle_dial_state_event(), sla_station_exec(), softmix_bridge_leave(), start_network_thread(), timing_read(), tps_taskprocessor_destroy(), unalloc_sub(), and unload_module().

#define ast_mutex_init ( pmutex   )     __ast_pthread_mutex_init(1, __FILE__, __LINE__, __PRETTY_FUNCTION__, #pmutex, pmutex)

Definition at line 152 of file lock.h.

Referenced by _ast_odbc_request_obj2(), accept_thread(), add_agent(), add_notify(), alloc_profile(), alloc_smdi_interface(), alloc_sub(), ast_audiohook_init(), ast_bridge_impart(), ast_bridge_join(), ast_context_find_or_create(), ast_dial_create(), ast_dnsmgr_get(), ast_enable_distributed_devstate(), ast_sched_thread_create(), ast_speech_new(), ast_ssl_init(), ast_taskprocessor_get(), ast_tcptls_client_create(), ast_tcptls_server_root(), bridge_request(), build_conf(), build_device(), caldav_load_calendar(), conf_run(), config_device(), config_line(), config_parse_variables(), create_client(), duplicate_pseudo(), ewscal_load_calendar(), exchangecal_load_calendar(), find_idle_thread(), find_tpeer(), get_lock(), gtalk_alloc(), ical_load_calendar(), init_timing_thread(), internal_ao2_alloc(), jingle_alloc(), join_conference_bridge(), load_config(), load_module(), misdn_cfg_init(), misdn_jb_init(), oh323_alloc(), read_config(), rpt_master(), sched_context_create(), session_do(), setup_mixmonitor_ds(), sig_pri_init_pri(), sig_pri_start_pri(), sig_ss7_init_linkset(), skinny_new(), sla_handle_dial_state_event(), sla_load_config(), sla_station_exec(), softmix_bridge_join(), start_network_thread(), and store_config().

#define ast_mutex_init_notracking ( pmutex   )     __ast_pthread_mutex_init(0, __FILE__, __LINE__, __PRETTY_FUNCTION__, #pmutex, pmutex)

Definition at line 153 of file lock.h.

#define AST_MUTEX_INIT_VALUE   { AST_LOCK_TRACK_INIT_VALUE, 1, PTHREAD_MUTEX_INIT_VALUE }

Definition at line 94 of file lock.h.

#define AST_MUTEX_INIT_VALUE_NOTRACKING   { AST_LOCK_TRACK_INIT_VALUE, 0, PTHREAD_MUTEX_INIT_VALUE }

Definition at line 95 of file lock.h.

#define AST_MUTEX_INITIALIZER   __use_AST_MUTEX_DEFINE_STATIC_rather_than_AST_MUTEX_INITIALIZER__

Definition at line 557 of file lock.h.

#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 (  )     __ast_pthread_mutex_lock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a)

Definition at line 155 of file lock.h.

Referenced by __attempt_transmit(), __auth_reject(), __auto_congest(), __auto_hangup(), __find_callno(), __get_from_jb(), __iax2_poke_noanswer(), __oh323_new(), __reload(), __send_lagrq(), __send_ping(), __unload_module(), _sip_tcp_helper_thread(), _unload_module(), acf_channel_read(), acf_jabberreceive_read(), action_agents(), action_dahdishowchannels(), add_notify(), agent_ack_sleep(), agent_call(), agent_cont_sleep(), agent_devicestate(), agent_digit_begin(), agent_digit_end(), agent_fixup(), agent_hangup(), agent_indicate(), agent_logoff(), agent_new(), agent_read(), agent_request(), agent_sendhtml(), agent_sendtext(), agent_write(), agents_data_provider_get(), agents_show(), agents_show_online(), aji_handle_message(), alsa_answer(), alsa_call(), alsa_digit(), alsa_fixup(), alsa_hangup(), alsa_indicate(), alsa_read(), alsa_request(), alsa_text(), alsa_write(), analog_ss_thread(), announce_thread(), answer_exec_run(), aoro2_obj_cb(), app_exec(), append_mailbox_mapping(), ast_atomic_fetchadd_int_slow(), ast_bridge_change_state(), ast_bridge_merge(), ast_cdr_detach(), ast_cdr_engine_init(), ast_cdr_submit_batch(), ast_cel_report_event(), ast_cli_netstats(), ast_config_engine_deregister(), ast_config_engine_register(), ast_context_lockmacro(), ast_db_del(), ast_db_deltree(), ast_db_get(), ast_db_gettree(), ast_db_put(), ast_dial_join(), ast_dnsmgr_changed(), ast_get_enum(), ast_iax2_new(), ast_monitor_start(), ast_random(), ast_rdlock_contexts(), ast_replace_sigchld(), ast_sched_add_variable(), ast_sched_del(), ast_sched_dump(), ast_sched_report(), ast_sched_runq(), ast_sched_thread_add(), ast_sched_thread_add_variable(), ast_sched_thread_destroy(), ast_sched_thread_poke(), ast_sched_wait(), ast_sched_when(), ast_search_dns(), ast_smdi_md_message_push(), ast_smdi_md_message_putback(), ast_smdi_mwi_message_push(), ast_smdi_mwi_message_putback(), ast_taskprocessor_push(), ast_unreplace_sigchld(), ast_wrlock_contexts(), auth_reject(), authenticate_reply(), auto_hangup(), blr_ebl(), blr_txt(), bridge_channel_join_singlethreaded(), bridge_hangup(), bridge_write(), build_device(), caldav_load_calendar(), cb_events(), cdr_handler(), check_availability(), check_beep(), cl_dequeue_chan(), cl_queue_chan(), clear_config_maps(), cli_tps_ping(), close_client(), conf_free(), conf_run(), config_device(), config_handler(), config_line(), config_load(), config_pgsql(), console_answer(), console_autoanswer(), console_dial(), console_hangup(), console_sendtext(), create_channel_name(), create_client(), csv_log(), custom_log(), dahdi_answer(), dahdi_bridge(), dahdi_call(), dahdi_cc_callback(), dahdi_channels_data_provider_get(), dahdi_destroy_channel_bynum(), dahdi_digit_begin(), dahdi_digit_end(), dahdi_exception(), dahdi_fixup(), dahdi_func_read(), dahdi_func_write(), dahdi_handle_dtmf(), dahdi_hangup(), dahdi_indicate(), dahdi_pri_error(), dahdi_pri_message(), dahdi_r2_disconnect_call(), dahdi_r2_on_call_disconnect(), dahdi_r2_on_call_end(), dahdi_r2_on_call_init(), dahdi_r2_on_call_offered(), dahdi_r2_on_hardware_alarm(), dahdi_r2_on_line_blocked(), dahdi_r2_on_line_idle(), dahdi_r2_on_protocol_error(), dahdi_request(), dahdi_restart(), dahdi_set_dnd(), dahdi_set_hwgain(), dahdi_set_swgain(), dahdi_show_channel(), dahdi_show_channels(), dahdi_softhangup_all(), dahdi_unlink(), dahdi_unlink_pri_pvt(), dahdi_unlink_ss7_pvt(), data_odbc_provider_handler(), db_sync_thread(), decrease_call_count(), defer_full_frame(), delete_users(), destroy_all_channels(), destroy_all_mailbox_mappings(), destroy_endpoint(), destroy_monitor_audiohook(), destroy_pgsql(), devstate_change_collector_cb(), dial_trunk(), dnsmgr_refresh(), do_cdr(), do_monitor(), do_refresh(), do_reload(), do_timing(), donodelog(), dp_lookup(), dump_cmd_queues(), dump_queue(), ewscal_load_calendar(), exchangecal_load_calendar(), find_call_locked(), find_chan_by_bc(), find_channel(), find_command(), find_engine(), find_hold_active_call(), find_hold_call(), find_hold_call_l3(), find_idle_thread(), find_subchannel_and_lock(), find_subchannel_by_name(), find_tpeer(), function_remote(), get_chan_by_ast(), get_chan_by_ast_name(), get_input(), get_lock(), gtalk_alloc(), gtalk_answer(), gtalk_digit_begin(), gtalk_digit_end(), gtalk_fixup(), gtalk_get_rtp_peer(), gtalk_hangup(), gtalk_newcall(), gtalk_read(), gtalk_ringing_ack(), gtalk_set_rtp_peer(), gtalk_show_channels(), gtalk_write(), h323_reload(), handle_capabilities_res_message(), handle_cli_core_show_config_mappings(), handle_cli_database_show(), handle_cli_database_showkey(), handle_cli_dialplan_save(), handle_cli_iax2_show_channels(), handle_cli_iax2_show_stats(), handle_cli_misdn_show_channel(), handle_cli_misdn_show_channels(), handle_cli_odbc_show(), handle_cli_osp_show(), handle_deferred_full_frames(), handle_mfcr2_call_files(), handle_mfcr2_set_blocked(), handle_mfcr2_set_debug(), handle_mfcr2_set_idle(), handle_mfcr2_show_channels(), handle_mgcp_audit_endpoint(), handle_mgcp_show_endpoints(), handle_modlist(), handle_pri_set_debug_file(), handle_register_message(), handle_request(), handle_request_do(), handle_speechrecognize(), handle_ss7_block_cic(), handle_ss7_block_linkset(), handle_ss7_unblock_cic(), handle_ss7_unblock_linkset(), hidthread(), iax2_answer(), iax2_bridge(), iax2_call(), iax2_do_register(), iax2_fixup(), iax2_hangup(), iax2_indicate(), iax2_key_rotate(), iax2_poke_peer(), iax2_process_thread(), iax2_queryoption(), iax2_setoption(), iax2_write(), iax_process_template(), iax_prov_complete_template(), iax_provision_build(), iax_provision_free_templates(), iax_provision_version(), iax_show_provisioning(), iax_template_parse(), ical_load_calendar(), increase_call_count(), inotify_daemon(), jingle_alloc(), jingle_answer(), jingle_digit(), jingle_fixup(), jingle_get_rtp_peer(), jingle_hangup(), jingle_newcall(), jingle_read(), jingle_set_rtp_peer(), jingle_show_channels(), jingle_write(), key_main_page(), key_select_extension(), leave_voicemail(), load_config(), load_module(), load_rpt_vars(), lock_both(), lock_broker(), lock_msg_q(), log_jitterstats(), login_exec(), lua_free_extensions(), lua_load_extensions(), lua_reload_extensions(), make_trunk(), mansession_lock(), mb_poll_thread(), mgcp_answer(), mgcp_call(), mgcp_devicestate(), mgcp_fixup(), mgcp_hangup(), mgcp_indicate(), mgcp_pktcgate_open(), mgcp_pktcgate_remove(), mgcp_postrequest(), mgcp_prune_realtime_gateway(), mgcp_read(), mgcp_reload(), mgcp_senddigit_begin(), mgcp_senddigit_end(), mgcp_write(), mgcpsock_read(), misdn_cfg_lock(), misdn_chan_is_valid(), misdn_hangup(), misdn_jb_empty(), misdn_jb_fill(), misdn_overlap_dial_task(), mixmonitor_ds_destroy(), mixmonitor_thread(), mwi_monitor_handler(), my_decrease_ss_count(), my_handle_dtmf(), my_increase_ss_count(), my_lock_private(), node_lookup(), odbc_obj_connect(), odbc_obj_disconnect(), oh323_alloc(), oh323_answer(), oh323_call(), oh323_destroy(), oh323_digit_begin(), oh323_digit_end(), oh323_fixup(), oh323_get_rtp_peer(), oh323_hangup(), oh323_indicate(), oh323_read(), oh323_request(), oh323_simulate_dtmf_end(), oh323_update_info(), oh323_write(), osp_create_transaction(), osp_get_provider(), osp_unload(), parse_config(), parsing(), peer_destructor(), pgsql_log(), phone_request(), play_sound_file(), pri_dchannel(), private_enum_init(), prune_gateways(), pthread_timer_open(), pvt_destructor(), queue_ringing_trunk(), radio_tune(), rcv_mac_addr(), realtime_destroy_handler(), realtime_handler(), realtime_ldap_base_ap(), realtime_multi_handler(), realtime_multi_pgsql(), realtime_pgsql(), realtime_store_handler(), realtime_update2_handler(), realtime_update_handler(), recordthread(), register_verify(), registry_authrequest(), release_chan(), release_chan_early(), reload(), reload_config(), reload_followme(), require_pgsql(), restart_monitor(), restart_pktc_thread(), retrans_pkt(), rpt_master(), rpt_tele_thread(), run_devstate_collector(), run_station(), save_to_folder(), sched_context_destroy(), sched_run(), schedule_calendar_event(), scheduled_destroy(), send_client(), send_command_locked(), send_lagrq(), send_ping(), send_request(), send_retransmit(), set_config(), set_pvt_defaults(), setup_dahdi_int(), sig_pri_attempt_transfer(), sig_pri_new_ast_channel(), signal_condition(), sip_reload(), sip_tcptls_write(), skinny_get_rtp_peer(), skinny_hangup(), skinny_read(), skinny_req_parse(), skinny_write(), sla_check_reload(), sla_destroy(), sla_handle_dial_state_event(), sla_handle_ringing_trunk_event(), sla_hangup_stations(), sla_queue_event_full(), sla_station_exec(), sla_thread(), sla_trunk_exec(), smart_bridge_operation(), socket_process(), softmix_bridge_poke(), softmix_bridge_thread(), softmix_bridge_write(), spandsp_fax_cli_show_stats(), speech_background(), sqlite_log(), ss7_linkset(), ss7_start_call(), ssl_lock(), start_rtp(), statpost(), stop_mixmonitor_exec(), stop_poll_thread(), store_config(), store_pgsql(), stun_monitor_request(), submit_unscheduled_batch(), syslog_log(), tds_load_module(), tds_log(), tds_unload_module(), timing_read(), tps_ping_handler(), tps_processing_function(), tps_taskprocessor_destroy(), tps_taskprocessor_pop(), transmit_frame(), transmit_response(), tune_write(), unistim_fixup(), unistim_hangup(), unistim_info(), unistim_new(), unistim_read(), unistim_register(), unistim_reload(), unistim_write(), unistimsock_read(), unload_module(), update2_ldap(), update2_pgsql(), update_ldap(), update_pgsql(), update_registry(), vm_execmain(), write_cdr(), and writefile().

#define ast_mutex_trylock (  )     __ast_pthread_mutex_trylock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a)

Definition at line 157 of file lock.h.

Referenced by ast_cli_perms_init(), ast_module_reload(), bridge_queue_hangup(), bridge_write(), cache_get_callno_locked(), dahdi_bridge(), dahdi_read(), dahdi_unlink(), do_monitor(), lock_both(), mgcp_prune_realtime_gateway(), pri_grab(), refresh_list(), ss7_grab(), and unload_module().

#define ast_mutex_unlock (  )     __ast_pthread_mutex_unlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a)

Definition at line 156 of file lock.h.

Referenced by __attempt_transmit(), __auth_reject(), __auto_congest(), __auto_hangup(), __find_callno(), __get_from_jb(), __iax2_poke_noanswer(), __oh323_destroy(), __oh323_new(), __oh323_rtp_create(), __reload(), __send_lagrq(), __send_ping(), __unload_module(), _sip_tcp_helper_thread(), _unload_module(), acf_channel_read(), acf_jabberreceive_read(), action_agents(), add_notify(), agent_ack_sleep(), agent_call(), agent_cont_sleep(), agent_devicestate(), agent_digit_begin(), agent_digit_end(), agent_fixup(), agent_hangup(), agent_indicate(), agent_logoff(), agent_new(), agent_read(), agent_request(), agent_sendhtml(), agent_sendtext(), agent_write(), agents_data_provider_get(), agents_show(), agents_show_online(), aji_handle_message(), alsa_answer(), alsa_call(), alsa_digit(), alsa_fixup(), alsa_hangup(), alsa_indicate(), alsa_read(), alsa_request(), alsa_text(), alsa_write(), analog_ss_thread(), announce_thread(), answer_call(), answer_exec_run(), aoro2_obj_cb(), app_exec(), append_mailbox_mapping(), ast_atomic_fetchadd_int_slow(), ast_bridge_change_state(), ast_bridge_merge(), ast_cdr_detach(), ast_cdr_engine_init(), ast_cdr_submit_batch(), ast_cel_report_event(), ast_cli_netstats(), ast_cli_perms_init(), ast_config_engine_deregister(), ast_config_engine_register(), ast_context_unlockmacro(), ast_db_del(), ast_db_deltree(), ast_db_get(), ast_db_gettree(), ast_db_put(), ast_dial_join(), ast_dnsmgr_changed(), ast_get_enum(), ast_iax2_new(), ast_module_reload(), ast_monitor_start(), ast_random(), ast_replace_sigchld(), ast_sched_add_variable(), ast_sched_del(), ast_sched_dump(), ast_sched_runq(), ast_sched_thread_add(), ast_sched_thread_add_variable(), ast_sched_thread_destroy(), ast_sched_thread_poke(), ast_sched_wait(), ast_sched_when(), ast_search_dns(), ast_smdi_md_message_push(), ast_smdi_md_message_putback(), ast_smdi_mwi_message_push(), ast_smdi_mwi_message_putback(), ast_taskprocessor_push(), ast_unlock_contexts(), ast_unreplace_sigchld(), auth_reject(), authenticate_reply(), auto_hangup(), blr_ebl(), blr_txt(), bridge_channel_join_singlethreaded(), bridge_hangup(), bridge_queue_hangup(), bridge_write(), build_device(), cache_get_callno_locked(), caldav_load_calendar(), cb_events(), cdr_handler(), chan_ringing(), check_availability(), check_beep(), cl_dequeue_chan(), cl_queue_chan(), cleanup_connection(), clear_config_maps(), cli_tps_ping(), close_client(), conf_free(), conf_run(), config_device(), config_handler(), config_line(), config_load(), config_pgsql(), connection_made(), console_answer(), console_autoanswer(), console_dial(), console_hangup(), console_sendtext(), create_channel_name(), create_client(), csv_log(), custom_log(), dahdi_answer(), dahdi_bridge(), dahdi_call(), dahdi_cc_callback(), dahdi_channels_data_provider_get(), dahdi_destroy_channel_bynum(), dahdi_digit_begin(), dahdi_digit_end(), dahdi_exception(), dahdi_func_read(), dahdi_func_write(), dahdi_handle_dtmf(), dahdi_hangup(), dahdi_indicate(), dahdi_pri_error(), dahdi_pri_message(), dahdi_r2_disconnect_call(), dahdi_r2_on_call_disconnect(), dahdi_r2_on_call_end(), dahdi_r2_on_call_init(), dahdi_r2_on_call_offered(), dahdi_r2_on_hardware_alarm(), dahdi_r2_on_line_blocked(), dahdi_r2_on_line_idle(), dahdi_r2_on_protocol_error(), dahdi_read(), dahdi_request(), dahdi_set_dnd(), dahdi_set_hwgain(), dahdi_set_swgain(), dahdi_softhangup_all(), dahdi_unlink_pri_pvt(), dahdi_unlink_ss7_pvt(), data_odbc_provider_handler(), db_sync_thread(), decrease_call_count(), defer_full_frame(), delete_users(), destroy_all_channels(), destroy_all_mailbox_mappings(), destroy_monitor_audiohook(), destroy_pgsql(), devstate_change_collector_cb(), dial_trunk(), dnsmgr_refresh(), do_cdr(), do_monitor(), do_refresh(), do_reload(), do_timing(), donodelog(), dp_lookup(), dump_cmd_queues(), dump_queue(), ewscal_load_calendar(), exchangecal_load_calendar(), external_rtp_create(), find_cache(), find_call_locked(), find_chan_by_bc(), find_hold_active_call(), find_hold_call(), find_hold_call_l3(), find_idle_thread(), find_subchannel_and_lock(), find_subchannel_by_name(), function_remote(), get_chan_by_ast(), get_chan_by_ast_name(), get_input(), get_lock(), gtalk_alloc(), gtalk_answer(), gtalk_digit_begin(), gtalk_digit_end(), gtalk_fixup(), gtalk_get_rtp_peer(), gtalk_hangup(), gtalk_newcall(), gtalk_read(), gtalk_ringing_ack(), gtalk_set_rtp_peer(), gtalk_show_channels(), gtalk_write(), h323_reload(), handle_capabilities_res_message(), handle_cli_database_show(), handle_cli_database_showkey(), handle_cli_dialplan_save(), handle_cli_iax2_show_channels(), handle_cli_iax2_show_stats(), handle_cli_misdn_show_channels(), handle_cli_odbc_show(), handle_deferred_full_frames(), handle_modlist(), handle_pri_set_debug_file(), handle_register_message(), handle_request(), handle_request_do(), handle_speechrecognize(), handle_ss7_block_cic(), handle_ss7_block_linkset(), handle_ss7_unblock_cic(), handle_ss7_unblock_linkset(), hangup_connection(), hidthread(), iax2_answer(), iax2_bridge(), iax2_call(), iax2_do_register(), iax2_fixup(), iax2_hangup(), iax2_indicate(), iax2_key_rotate(), iax2_poke_peer(), iax2_process_thread(), iax2_provision(), iax2_queryoption(), iax2_request(), iax2_setoption(), iax2_trunk_queue(), iax2_write(), iax_process_template(), iax_prov_complete_template(), iax_provision_build(), iax_provision_free_templates(), iax_provision_version(), iax_show_provisioning(), iax_template_parse(), ical_load_calendar(), increase_call_count(), inotify_daemon(), jingle_alloc(), jingle_answer(), jingle_digit(), jingle_fixup(), jingle_get_rtp_peer(), jingle_hangup(), jingle_newcall(), jingle_read(), jingle_set_rtp_peer(), jingle_show_channels(), jingle_write(), key_main_page(), key_select_extension(), ldap_loadentry(), leave_voicemail(), load_config(), load_module(), load_rpt_vars(), lock_broker(), log_jitterstats(), login_exec(), lua_free_extensions(), lua_load_extensions(), lua_reload_extensions(), make_trunk(), mansession_unlock(), mb_poll_thread(), mgcp_answer(), mgcp_call(), mgcp_fixup(), mgcp_hangup(), mgcp_indicate(), mgcp_pktcgate_open(), mgcp_pktcgate_remove(), mgcp_postrequest(), mgcp_prune_realtime_gateway(), mgcp_read(), mgcp_reload(), mgcp_request(), mgcp_senddigit_begin(), mgcp_senddigit_end(), mgcp_write(), mgcpsock_read(), misdn_cfg_unlock(), misdn_chan_is_valid(), misdn_hangup(), misdn_jb_empty(), misdn_overlap_dial_task(), mixmonitor_ds_destroy(), mixmonitor_thread(), mwi_monitor_handler(), my_decrease_ss_count(), my_handle_dtmf(), my_increase_ss_count(), my_unlock_private(), node_lookup(), odbc_obj_connect(), odbc_obj_disconnect(), oh323_alloc(), oh323_answer(), oh323_call(), oh323_destroy(), oh323_digit_begin(), oh323_digit_end(), oh323_fixup(), oh323_get_rtp_peer(), oh323_hangup(), oh323_indicate(), oh323_read(), oh323_request(), oh323_simulate_dtmf_end(), oh323_update_info(), oh323_write(), osp_unload(), parse_config(), parsing(), peer_destructor(), pgsql_log(), phone_request(), play_sound_file(), pri_dchannel(), pri_rel(), private_enum_init(), progress(), pthread_timer_open(), pvt_destructor(), queue_ringing_trunk(), radio_tune(), rcv_mac_addr(), realtime_destroy_handler(), realtime_handler(), realtime_ldap_base_ap(), realtime_multi_handler(), realtime_multi_pgsql(), realtime_pgsql(), realtime_store_handler(), realtime_update2_handler(), realtime_update_handler(), receive_digit(), recordthread(), refresh_list(), register_verify(), registry_authrequest(), release_chan(), release_chan_early(), reload(), reload_config(), reload_followme(), remote_hold(), require_pgsql(), restart_monitor(), restart_pktc_thread(), retrans_pkt(), rpt_master(), rpt_tele_thread(), run_devstate_collector(), run_station(), save_to_folder(), sched_context_destroy(), sched_run(), schedule_calendar_event(), scheduled_destroy(), send_client(), send_command_locked(), send_lagrq(), send_ping(), send_request(), send_retransmit(), set_config(), set_dtmf_payload(), set_local_capabilities(), set_pvt_defaults(), setup_dahdi_int(), setup_rtp_connection(), sig_pri_attempt_transfer(), sig_pri_new_ast_channel(), signal_condition(), sip_reload(), sip_tcptls_write(), skinny_get_rtp_peer(), skinny_hangup(), skinny_read(), skinny_req_parse(), skinny_write(), sla_check_reload(), sla_destroy(), sla_handle_dial_state_event(), sla_handle_ringing_trunk_event(), sla_hangup_stations(), sla_queue_event_full(), sla_station_exec(), sla_thread(), sla_trunk_exec(), smart_bridge_operation(), socket_process(), socket_process_meta(), softmix_bridge_poke(), softmix_bridge_thread(), softmix_bridge_write(), spandsp_fax_cli_show_stats(), speech_background(), sqlite_log(), ss7_rel(), ss7_start_call(), ssl_lock(), start_rtp(), statpost(), stop_mixmonitor_exec(), stop_poll_thread(), store_config(), store_pgsql(), stun_monitor_request(), submit_unscheduled_batch(), syslog_log(), tds_load_module(), tds_log(), tds_unload_module(), timing_read(), tps_ping_handler(), tps_processing_function(), tps_taskprocessor_destroy(), tps_taskprocessor_pop(), transmit_frame(), transmit_response(), tune_write(), unistim_fixup(), unistim_hangup(), unistim_info(), unistim_new(), unistim_read(), unistim_register(), unistim_reload(), unistim_write(), unistimsock_read(), unload_module(), unlock_both(), unlock_msg_q(), update2_ldap(), update2_pgsql(), update_ldap(), update_pgsql(), update_registry(), vm_execmain(), write_cdr(), and writefile().

#define AST_PTHREADT_NULL   (pthread_t) -1

Definition at line 65 of file lock.h.

Referenced by __ast_manager_event_multichan(), __ast_rwlock_unlock(), __sip_reliable_xmit(), __unload_module(), _unload_module(), action_waitevent(), add_notify(), ast_autoservice_start(), ast_autoservice_stop(), ast_bridge_new(), ast_cdr_submit_batch(), ast_dial_create(), ast_dial_join(), ast_localtime_wakeup_monitor(), ast_log(), ast_sched_thread_create(), ast_sched_thread_destroy(), ast_smdi_interface_destroy(), ast_taskprocessor_get(), ast_tcptls_server_start(), ast_tcptls_server_stop(), bridge_channel_join(), bridge_poke(), bridge_thread(), build_conf(), build_mansession(), calendar_event_notify(), close_logger(), conf_free(), conf_run(), console_verboser(), dahdi_r2_destroy_links(), dahdi_r2_get_link(), dahdi_restart(), do_reload(), init_pvt(), inotify_daemon(), load_config(), load_rpt_vars(), moh_class_destructor(), multiplexed_add_or_remove(), multiplexed_bridge_create(), multiplexed_nudge(), multiplexed_thread_function(), network_thread(), process_precache(), quit_handler(), restart_monitor(), restart_pktc_thread(), rpt_master(), sig_pri_init_pri(), sig_ss7_init_linkset(), sla_destroy(), sla_load_config(), sla_queue_event_full(), smart_bridge_operation(), ss7_grab(), stop_poll_thread(), stop_stream(), tps_taskprocessor_destroy(), and unload_module().

#define AST_PTHREADT_STOP   (pthread_t) -2

Definition at line 66 of file lock.h.

Referenced by __unload_module(), answer_exec_run(), ast_bridge_merge(), ast_dial_join(), ast_smdi_interface_destroy(), bridge_poke(), monitor_dial(), multiplexed_thread_function(), restart_monitor(), restart_pktc_thread(), rpt(), rpt_master(), and unload_module().

#define AST_RWLOCK_DEFINE_STATIC ( rwlock   )     __AST_RWLOCK_DEFINE(static, rwlock, AST_RWLOCK_INIT_VALUE, 1)

Definition at line 538 of file lock.h.

#define AST_RWLOCK_DEFINE_STATIC_NOTRACKING ( rwlock   )     __AST_RWLOCK_DEFINE(static, rwlock, AST_RWLOCK_INIT_VALUE_NOTRACKING, 0)

Definition at line 539 of file lock.h.

#define ast_rwlock_destroy ( rwlock   )     __ast_rwlock_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, #rwlock, rwlock)

Definition at line 199 of file lock.h.

Referenced by __ast_internal_context_destroy(), ast_hashtab_destroy(), ast_hashtab_destroylock(), ast_heap_destroy(), and destroy_table().

#define ast_rwlock_init ( rwlock   )     __ast_rwlock_init(1, __FILE__, __LINE__, __PRETTY_FUNCTION__, #rwlock, rwlock)

wrapper for rwlock with tracking enabled

Returns:
0 on success, non zero for error
Since:
1.6.1

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)

wrapper for ast_rwlock_init with tracking disabled

Returns:
0 on success, non zero for error
Since:
1.6.1

Definition at line 197 of file lock.h.

#define AST_RWLOCK_INIT_VALUE   { AST_LOCK_TRACK_INIT_VALUE, 1, __AST_RWLOCK_INIT_VALUE }

Definition at line 97 of file lock.h.

#define AST_RWLOCK_INIT_VALUE_NOTRACKING   { AST_LOCK_TRACK_INIT_VALUE, 0, __AST_RWLOCK_INIT_VALUE }

Definition at line 98 of file lock.h.

#define ast_rwlock_rdlock (  )     __ast_rwlock_rdlock(a, #a, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Definition at line 201 of file lock.h.

Referenced by ast_calendar_config_acquire(), ast_hashtab_get_stats(), ast_hashtab_lookup(), ast_hashtab_lookup_with_hash(), ast_hashtab_rdlock(), ast_hashtab_start_traversal(), ast_rdlock_call_features(), ast_rdlock_context(), ast_str_retrieve_variable(), feature_interpret_helper(), feature_request_and_dial(), find_table(), get_active_pvt(), handle_feature_show(), handle_show_globals(), manager_log(), pbx_builtin_getvar_helper(), and set_config_flags().

#define ast_rwlock_timedrdlock ( a,
 )     __ast_rwlock_timedrdlock(a, #a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Definition at line 205 of file lock.h.

#define ast_rwlock_timedwrlock ( a,
 )     __ast_rwlock_timedwrlock(a, #a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Definition at line 206 of file lock.h.

#define ast_rwlock_tryrdlock (  )     __ast_rwlock_tryrdlock(a, #a, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Definition at line 203 of file lock.h.

#define ast_rwlock_trywrlock (  )     __ast_rwlock_trywrlock(a, #a, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Definition at line 204 of file lock.h.

#define ast_rwlock_unlock (  )     __ast_rwlock_unlock(a, #a, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Definition at line 200 of file lock.h.

Referenced by ast_calendar_config_acquire(), ast_calendar_config_release(), ast_hashtab_destroy(), ast_hashtab_end_traversal(), ast_hashtab_get_stats(), ast_hashtab_insert_immediate(), ast_hashtab_insert_safe(), ast_hashtab_lookup(), ast_hashtab_lookup_with_hash(), ast_hashtab_remove_object_via_lookup(), ast_hashtab_remove_this_object(), ast_hashtab_unlock(), ast_str_retrieve_variable(), ast_unlock_call_features(), ast_unlock_context(), destroy_pvts(), destroy_table(), feature_interpret_helper(), feature_request_and_dial(), get_active_pvt(), handle_feature_show(), handle_show_globals(), load_config(), load_tech_calendars(), manager_log(), pbx_builtin_clear_globals(), pbx_builtin_getvar_helper(), pbx_builtin_pushvar_helper(), pbx_builtin_setvar_helper(), remap_feature(), set_active(), set_config_flags(), and unmap_features().

#define ast_rwlock_wrlock (  )     __ast_rwlock_wrlock(a, #a, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Definition at line 202 of file lock.h.

Referenced by ast_hashtab_destroy(), ast_hashtab_insert_immediate(), ast_hashtab_insert_safe(), ast_hashtab_remove_object_via_lookup(), ast_hashtab_remove_this_object(), ast_hashtab_start_write_traversal(), ast_hashtab_wrlock(), ast_wrlock_context(), destroy_pvts(), destroy_table(), load_config(), load_tech_calendars(), pbx_builtin_clear_globals(), pbx_builtin_pushvar_helper(), pbx_builtin_setvar_helper(), remap_feature(), set_active(), and unmap_features().

#define CHANNEL_DEADLOCK_AVOIDANCE ( chan   ) 

Value:

ast_channel_unlock(chan); \
   usleep(1); \
   ast_channel_lock(chan);

Definition at line 469 of file lock.h.

Referenced by ast_call_forward(), ast_do_masquerade(), bridge_queue_hangup(), bridge_write(), dahdi_bridge(), dahdi_handle_event(), dahdi_read(), dial_exec_full(), do_forward(), local_queue_frame(), manager_park(), misdn_attempt_transfer(), ring_entry(), and sip_hangup().

#define DEADLOCK_AVOIDANCE ( lock   ) 

Definition at line 474 of file lock.h.

Referenced by agent_logoff(), agent_read(), dahdi_queue_frame(), dahdi_unlink(), grab_owner(), iax2_destroy(), iax2_lock_owner(), lock_both(), mgcp_queue_frame(), mgcp_queue_hangup(), my_deadlock_avoidance_private(), oh323_simulate_dtmf_end(), release_chan(), release_chan_early(), and wait_for_peercallno().

#define DLA_LOCK ( lock   )     ast_mutex_lock(lock)

Definition at line 487 of file lock.h.

Referenced by dahdi_handle_event().

#define DLA_UNLOCK ( lock   )     ast_mutex_unlock(lock)

Definition at line 485 of file lock.h.

Referenced by dahdi_handle_event().

#define gethostbyname   __gethostbyname__is__not__reentrant__use__ast_gethostbyname__instead__

Definition at line 559 of file lock.h.

Referenced by connect_sphinx().

#define pthread_cond_broadcast   use_ast_cond_broadcast_instead_of_pthread_cond_broadcast

Definition at line 553 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 551 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 550 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 552 of file lock.h.

Referenced by __ast_cond_signal().

#define pthread_cond_t   use_ast_cond_t_instead_of_pthread_cond_t

Definition at line 543 of file lock.h.

#define pthread_cond_timedwait   use_ast_cond_timedwait_instead_of_pthread_cond_timedwait

Definition at line 555 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 554 of file lock.h.

Referenced by __ast_cond_wait().

#define pthread_create   __use_ast_pthread_create_instead__

Definition at line 562 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 549 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 548 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

Definition at line 75 of file lock.h.

#define pthread_mutex_lock   use_ast_mutex_lock_instead_of_pthread_mutex_lock

Definition at line 545 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 542 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 547 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 546 of file lock.h.

Referenced by __ast_pthread_mutex_destroy(), __ast_pthread_mutex_unlock(), dummy_start(), 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 Documentation

typedef pthread_cond_t ast_cond_t

Definition at line 144 of file lock.h.

typedef struct ast_mutex_info ast_mutex_t

Definition at line 140 of file lock.h.

typedef struct ast_rwlock_info ast_rwlock_t

Definition at line 142 of file lock.h.


Function Documentation

int __ast_cond_broadcast ( const char *  filename,
int  lineno,
const char *  func,
const char *  cond_name,
ast_cond_t cond 
)

Definition at line 437 of file lock.c.

References pthread_cond_broadcast.

00439 {
00440    return pthread_cond_broadcast(cond);
00441 }

int __ast_cond_destroy ( const char *  filename,
int  lineno,
const char *  func,
const char *  cond_name,
ast_cond_t cond 
)

Definition at line 443 of file lock.c.

References pthread_cond_destroy.

00445 {
00446    return pthread_cond_destroy(cond);
00447 }

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 425 of file lock.c.

References pthread_cond_init.

00427 {
00428    return pthread_cond_init(cond, cond_attr);
00429 }

int __ast_cond_signal ( const char *  filename,
int  lineno,
const char *  func,
const char *  cond_name,
ast_cond_t cond 
)

Definition at line 431 of file lock.c.

References pthread_cond_signal.

00433 {
00434    return pthread_cond_signal(cond);
00435 }

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 554 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_cond_timedwait, pthread_mutex_t, ast_lock_track::reentrancy, ROFFSET, ast_lock_track::thread, ast_mutex_info::track, and ast_mutex_info::tracking.

00557 {
00558    int res;
00559 
00560 #ifdef DEBUG_THREADS
00561    struct ast_lock_track *lt = &t->track;
00562    int canlog = strcmp(filename, "logger.c") & t->tracking;
00563 #ifdef HAVE_BKTR
00564    struct ast_bt *bt = NULL;
00565 #endif
00566 
00567 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00568    if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00569       __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
00570                filename, lineno, func, mutex_name);
00571       res = __ast_pthread_mutex_init(t->tracking, filename, lineno, func, mutex_name, t);
00572       if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00573          __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n",
00574                 filename, lineno, func, mutex_name);
00575       }
00576       return res;
00577    }
00578 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00579 
00580    ast_reentrancy_lock(lt);
00581    if (lt->reentrancy && (lt->thread[ROFFSET] != pthread_self())) {
00582       __ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n",
00583                filename, lineno, func, mutex_name);
00584       __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n",
00585                lt->file[ROFFSET], lt->lineno[ROFFSET], lt->func[ROFFSET], mutex_name);
00586 #ifdef HAVE_BKTR
00587       __dump_backtrace(&lt->backtrace[ROFFSET], canlog);
00588 #endif
00589       DO_THREAD_CRASH;
00590    }
00591 
00592    if (--lt->reentrancy < 0) {
00593       __ast_mutex_logger("%s line %d (%s): mutex '%s' freed more times than we've locked!\n",
00594                filename, lineno, func, mutex_name);
00595       lt->reentrancy = 0;
00596    }
00597 
00598    if (lt->reentrancy < AST_MAX_REENTRANCY) {
00599       lt->file[lt->reentrancy] = NULL;
00600       lt->lineno[lt->reentrancy] = 0;
00601       lt->func[lt->reentrancy] = NULL;
00602       lt->thread[lt->reentrancy] = 0;
00603    }
00604 #ifdef HAVE_BKTR
00605    if (lt->reentrancy) {
00606       bt = &lt->backtrace[lt->reentrancy - 1];
00607    }
00608 #endif
00609    ast_reentrancy_unlock(lt);
00610 
00611    if (t->tracking) {
00612 #ifdef HAVE_BKTR
00613       ast_remove_lock_info(t, bt);
00614 #else
00615       ast_remove_lock_info(t);
00616 #endif
00617    }
00618 #endif /* DEBUG_THREADS */
00619 
00620    res = pthread_cond_timedwait(cond, &t->mutex, abstime);
00621 
00622 #ifdef DEBUG_THREADS
00623    if (res && (res != ETIMEDOUT)) {
00624       __ast_mutex_logger("%s line %d (%s): Error waiting on condition mutex '%s'\n",
00625                filename, lineno, func, strerror(res));
00626       DO_THREAD_CRASH;
00627    } else {
00628       ast_reentrancy_lock(lt);
00629       if (lt->reentrancy < AST_MAX_REENTRANCY) {
00630          lt->file[lt->reentrancy] = filename;
00631          lt->lineno[lt->reentrancy] = lineno;
00632          lt->func[lt->reentrancy] = func;
00633          lt->thread[lt->reentrancy] = pthread_self();
00634 #ifdef HAVE_BKTR
00635          ast_bt_get_addresses(&lt->backtrace[lt->reentrancy]);
00636          bt = &lt->backtrace[lt->reentrancy];
00637 #endif
00638          lt->reentrancy++;
00639       } else {
00640          __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n",
00641                         filename, lineno, func, mutex_name);
00642       }
00643       ast_reentrancy_unlock(lt);
00644 
00645       if (t->tracking) {
00646 #ifdef HAVE_BKTR
00647          ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t, bt);
00648 #else
00649          ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t);
00650 #endif
00651       }
00652    }
00653 #endif /* DEBUG_THREADS */
00654 
00655    return res;
00656 }

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 449 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_cond_wait, pthread_mutex_t, ast_lock_track::reentrancy, ROFFSET, ast_lock_track::thread, ast_mutex_info::track, and ast_mutex_info::tracking.

00452 {
00453    int res;
00454 
00455 #ifdef DEBUG_THREADS
00456    struct ast_lock_track *lt= &t->track;
00457    int canlog = strcmp(filename, "logger.c") & t->tracking;
00458 #ifdef HAVE_BKTR
00459    struct ast_bt *bt = NULL;
00460 #endif
00461 
00462 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00463    if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00464       __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
00465                filename, lineno, func, mutex_name);
00466       res = __ast_pthread_mutex_init(t->tracking, filename, lineno, func, mutex_name, t);
00467       if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00468          __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n",
00469                 filename, lineno, func, mutex_name);
00470       }
00471       return res;
00472    }
00473 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00474 
00475    ast_reentrancy_lock(lt);
00476    if (lt->reentrancy && (lt->thread[ROFFSET] != pthread_self())) {
00477       __ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n",
00478                filename, lineno, func, mutex_name);
00479       __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n",
00480                lt->file[ROFFSET], lt->lineno[ROFFSET], lt->func[ROFFSET], mutex_name);
00481 #ifdef HAVE_BKTR
00482       __dump_backtrace(&lt->backtrace[ROFFSET], canlog);
00483 #endif
00484       DO_THREAD_CRASH;
00485    }
00486 
00487    if (--lt->reentrancy < 0) {
00488       __ast_mutex_logger("%s line %d (%s): mutex '%s' freed more times than we've locked!\n",
00489                filename, lineno, func, mutex_name);
00490       lt->reentrancy = 0;
00491    }
00492 
00493    if (lt->reentrancy < AST_MAX_REENTRANCY) {
00494       lt->file[lt->reentrancy] = NULL;
00495       lt->lineno[lt->reentrancy] = 0;
00496       lt->func[lt->reentrancy] = NULL;
00497       lt->thread[lt->reentrancy] = 0;
00498    }
00499 
00500 #ifdef HAVE_BKTR
00501    if (lt->reentrancy) {
00502       bt = &lt->backtrace[lt->reentrancy - 1];
00503    }
00504 #endif
00505    ast_reentrancy_unlock(lt);
00506 
00507    if (t->tracking) {
00508 #ifdef HAVE_BKTR
00509       ast_remove_lock_info(t, bt);
00510 #else
00511       ast_remove_lock_info(t);
00512 #endif
00513    }
00514 #endif /* DEBUG_THREADS */
00515 
00516    res = pthread_cond_wait(cond, &t->mutex);
00517 
00518 #ifdef DEBUG_THREADS
00519    if (res) {
00520       __ast_mutex_logger("%s line %d (%s): Error waiting on condition mutex '%s'\n",
00521                filename, lineno, func, strerror(res));
00522       DO_THREAD_CRASH;
00523    } else {
00524       ast_reentrancy_lock(lt);
00525       if (lt->reentrancy < AST_MAX_REENTRANCY) {
00526          lt->file[lt->reentrancy] = filename;
00527          lt->lineno[lt->reentrancy] = lineno;
00528          lt->func[lt->reentrancy] = func;
00529          lt->thread[lt->reentrancy] = pthread_self();
00530 #ifdef HAVE_BKTR
00531          ast_bt_get_addresses(&lt->backtrace[lt->reentrancy]);
00532          bt = &lt->backtrace[lt->reentrancy];
00533 #endif
00534          lt->reentrancy++;
00535       } else {
00536          __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n",
00537                         filename, lineno, func, mutex_name);
00538       }
00539       ast_reentrancy_unlock(lt);
00540 
00541       if (t->tracking) {
00542 #ifdef HAVE_BKTR
00543          ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t, bt);
00544 #else
00545          ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t);
00546 #endif
00547       }
00548    }
00549 #endif /* DEBUG_THREADS */
00550 
00551    return res;
00552 }

int __ast_pthread_mutex_destroy ( const char *  filename,
int  lineno,
const char *  func,
const char *  mutex_name,
ast_mutex_t t 
)

Definition at line 76 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.

00078 {
00079    int res;
00080 
00081 #ifdef DEBUG_THREADS
00082    struct ast_lock_track *lt;
00083    int canlog = strcmp(filename, "logger.c") & t->tracking;
00084 
00085 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00086    if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00087       /* Don't try to uninitialize non initialized mutex
00088        * This may no effect on linux
00089        * And always ganerate core on *BSD with
00090        * linked libpthread
00091        * This not error condition if the mutex created on the fly.
00092        */
00093       __ast_mutex_logger("%s line %d (%s): NOTICE: mutex '%s' is uninitialized.\n",
00094                filename, lineno, func, mutex_name);
00095       return 0;
00096    }
00097 #endif
00098 
00099    lt = &t->track;
00100 
00101    res = pthread_mutex_trylock(&t->mutex);
00102    switch (res) {
00103    case 0:
00104       pthread_mutex_unlock(&t->mutex);
00105       break;
00106    case EINVAL:
00107       __ast_mutex_logger("%s line %d (%s): Error: attempt to destroy invalid mutex '%s'.\n",
00108               filename, lineno, func, mutex_name);
00109       break;
00110    case EBUSY:
00111       __ast_mutex_logger("%s line %d (%s): Error: attempt to destroy locked mutex '%s'.\n",
00112                filename, lineno, func, mutex_name);
00113       ast_reentrancy_lock(lt);
00114       __ast_mutex_logger("%s line %d (%s): Error: '%s' was locked here.\n",
00115              lt->file[ROFFSET], lt->lineno[ROFFSET], lt->func[ROFFSET], mutex_name);
00116 #ifdef HAVE_BKTR
00117       __dump_backtrace(&lt->backtrace[ROFFSET], canlog);
00118 #endif
00119       ast_reentrancy_unlock(lt);
00120       break;
00121    }
00122 #endif /* DEBUG_THREADS */
00123 
00124    res = pthread_mutex_destroy(&t->mutex);
00125 
00126 #ifdef DEBUG_THREADS
00127    if (res) {
00128       __ast_mutex_logger("%s line %d (%s): Error destroying mutex %s: %s\n",
00129                filename, lineno, func, mutex_name, strerror(res));
00130    }
00131    ast_reentrancy_lock(lt);
00132    lt->file[0] = filename;
00133    lt->lineno[0] = lineno;
00134    lt->func[0] = func;
00135    lt->reentrancy = 0;
00136    lt->thread[0] = 0;
00137 #ifdef HAVE_BKTR
00138    memset(&lt->backtrace[0], 0, sizeof(lt->backtrace[0]));
00139 #endif
00140    ast_reentrancy_unlock(lt);
00141    delete_reentrancy_cs(lt);
00142 #endif /* DEBUG_THREADS */
00143 
00144    return res;
00145 }

int __ast_pthread_mutex_init ( int  tracking,
const char *  filename,
int  lineno,
const char *  func,
const char *  mutex_name,
ast_mutex_t t 
)

Definition at line 44 of file lock.c.

References AST_MUTEX_KIND, ast_mutex_info::mutex, pthread_mutex_init, pthread_mutex_t, ast_mutex_info::track, and ast_mutex_info::tracking.

Referenced by __ast_cond_timedwait(), __ast_cond_wait(), __ast_pthread_mutex_lock(), __ast_pthread_mutex_trylock(), and __ast_pthread_mutex_unlock().

00046 {
00047    int res;
00048    pthread_mutexattr_t  attr;
00049 
00050 #ifdef DEBUG_THREADS
00051 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00052    if ((t->mutex) != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00053 /*
00054       int canlog = strcmp(filename, "logger.c") & track;
00055       __ast_mutex_logger("%s line %d (%s): NOTICE: mutex '%s' is already initialized.\n",
00056                filename, lineno, func, mutex_name);
00057       DO_THREAD_CRASH;
00058 */
00059       return 0;
00060    }
00061 
00062 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00063 
00064    ast_reentrancy_init(&t->track);
00065    t->tracking = tracking;
00066 #endif /* DEBUG_THREADS */
00067 
00068    pthread_mutexattr_init(&attr);
00069    pthread_mutexattr_settype(&attr, AST_MUTEX_KIND);
00070 
00071    res = pthread_mutex_init(&t->mutex, &attr);
00072    pthread_mutexattr_destroy(&attr);
00073    return res;
00074 }

int __ast_pthread_mutex_lock ( const char *  filename,
int  lineno,
const char *  func,
const char *  mutex_name,
ast_mutex_t t 
)

Definition at line 147 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_mutex_info::track, and ast_mutex_info::tracking.

Referenced by __ao2_lock().

00149 {
00150    int res;
00151 
00152 #ifdef DEBUG_THREADS
00153    struct ast_lock_track *lt = &t->track;
00154    int canlog = strcmp(filename, "logger.c") & t->tracking;
00155 #ifdef HAVE_BKTR
00156    struct ast_bt *bt = NULL;
00157 #endif
00158 
00159 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00160    if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00161       /* Don't warn abount uninitialized mutex.
00162        * Simple try to initialize it.
00163        * May be not needed in linux system.
00164        */
00165       res = __ast_pthread_mutex_init(t->tracking, filename, lineno, func, mutex_name, t);
00166       if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00167          __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n",
00168                 filename, lineno, func, mutex_name);
00169          return res;
00170       }
00171    }
00172 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00173 
00174    if (t->tracking) {
00175 #ifdef HAVE_BKTR
00176       ast_reentrancy_lock(lt);
00177       if (lt->reentrancy != AST_MAX_REENTRANCY) {
00178          ast_bt_get_addresses(&lt->backtrace[lt->reentrancy]);
00179          bt = &lt->backtrace[lt->reentrancy];
00180       }
00181       ast_reentrancy_unlock(lt);
00182       ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t, bt);
00183 #else
00184       ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t);
00185 #endif
00186    }
00187 #endif /* DEBUG_THREADS */
00188 
00189 #if defined(DETECT_DEADLOCKS) && defined(DEBUG_THREADS)
00190    {
00191       time_t seconds = time(NULL);
00192       time_t wait_time, reported_wait = 0;
00193       do {
00194 #ifdef   HAVE_MTX_PROFILE
00195          ast_mark(mtx_prof, 1);
00196 #endif
00197          res = pthread_mutex_trylock(&t->mutex);
00198 #ifdef   HAVE_MTX_PROFILE
00199          ast_mark(mtx_prof, 0);
00200 #endif
00201          if (res == EBUSY) {
00202             wait_time = time(NULL) - seconds;
00203             if (wait_time > reported_wait && (wait_time % 5) == 0) {
00204                __ast_mutex_logger("%s line %d (%s): Deadlock? waited %d sec for mutex '%s'?\n",
00205                         filename, lineno, func, (int) wait_time, mutex_name);
00206                ast_reentrancy_lock(lt);
00207 #ifdef HAVE_BKTR
00208                __dump_backtrace(&lt->backtrace[lt->reentrancy], canlog);
00209 #endif
00210                __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n",
00211                         lt->file[ROFFSET], lt->lineno[ROFFSET],
00212                         lt->func[ROFFSET], mutex_name);
00213 #ifdef HAVE_BKTR
00214                __dump_backtrace(&lt->backtrace[ROFFSET], canlog);
00215 #endif
00216                ast_reentrancy_unlock(lt);
00217                reported_wait = wait_time;
00218             }
00219             usleep(200);
00220          }
00221       } while (res == EBUSY);
00222    }
00223 #else /* !DETECT_DEADLOCKS || !DEBUG_THREADS */
00224 #ifdef   HAVE_MTX_PROFILE
00225    ast_mark(mtx_prof, 1);
00226    res = pthread_mutex_trylock(&t->mutex);
00227    ast_mark(mtx_prof, 0);
00228    if (res)
00229 #endif
00230    res = pthread_mutex_lock(&t->mutex);
00231 #endif /* !DETECT_DEADLOCKS || !DEBUG_THREADS */
00232 
00233 #ifdef DEBUG_THREADS
00234    if (!res) {
00235       ast_reentrancy_lock(lt);
00236       if (lt->reentrancy < AST_MAX_REENTRANCY) {
00237          lt->file[lt->reentrancy] = filename;
00238          lt->lineno[lt->reentrancy] = lineno;
00239          lt->func[lt->reentrancy] = func;
00240          lt->thread[lt->reentrancy] = pthread_self();
00241          lt->reentrancy++;
00242       } else {
00243          __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n",
00244                         filename, lineno, func, mutex_name);
00245       }
00246       ast_reentrancy_unlock(lt);
00247       if (t->tracking) {
00248          ast_mark_lock_acquired(t);
00249       }
00250    } else {
00251 #ifdef HAVE_BKTR
00252       if (lt->reentrancy) {
00253          ast_reentrancy_lock(lt);
00254          bt = &lt->backtrace[lt->reentrancy-1];
00255          ast_reentrancy_unlock(lt);
00256       } else {
00257          bt = NULL;
00258       }
00259       if (t->tracking) {
00260          ast_remove_lock_info(t, bt);
00261       }
00262 #else
00263       if (t->tracking) {
00264          ast_remove_lock_info(t);
00265       }
00266 #endif
00267       __ast_mutex_logger("%s line %d (%s): Error obtaining mutex: %s\n",
00268                filename, lineno, func, strerror(res));
00269       DO_THREAD_CRASH;
00270    }
00271 #endif /* DEBUG_THREADS */
00272 
00273    return res;
00274 }

int __ast_pthread_mutex_trylock ( const char *  filename,
int  lineno,
const char *  func,
const char *  mutex_name,
ast_mutex_t t 
)

Definition at line 276 of file lock.c.

References __ast_pthread_mutex_init(), ast_bt_get_addresses(), AST_MAX_REENTRANCY, ast_lock_track::backtrace, ast_mutex_info::mutex, pthread_mutex_t, pthread_mutex_trylock, ast_lock_track::reentrancy, ast_mutex_info::track, and ast_mutex_info::tracking.

Referenced by __ao2_trylock().

00278 {
00279    int res;
00280 
00281 #ifdef DEBUG_THREADS
00282    struct ast_lock_track *lt= &t->track;
00283    int canlog = strcmp(filename, "logger.c") & t->tracking;
00284 #ifdef HAVE_BKTR
00285    struct ast_bt *bt = NULL;
00286 #endif
00287 
00288 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00289    if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00290       /* Don't warn abount uninitialized mutex.
00291        * Simple try to initialize it.
00292        * May be not needed in linux system.
00293        */
00294       res = __ast_pthread_mutex_init(t->tracking, filename, lineno, func, mutex_name, t);
00295       if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00296          __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n",
00297                 filename, lineno, func, mutex_name);
00298          return res;
00299       }
00300    }
00301 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00302 
00303    if (t->tracking) {
00304 #ifdef HAVE_BKTR
00305       ast_reentrancy_lock(lt);
00306       if (lt->reentrancy != AST_MAX_REENTRANCY) {
00307          ast_bt_get_addresses(&lt->backtrace[lt->reentrancy]);
00308          bt = &lt->backtrace[lt->reentrancy];
00309       }
00310       ast_reentrancy_unlock(lt);
00311       ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t, bt);
00312 #else
00313       ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, t);
00314 #endif
00315    }
00316 #endif /* DEBUG_THREADS */
00317 
00318    res = pthread_mutex_trylock(&t->mutex);
00319 
00320 #ifdef DEBUG_THREADS
00321    if (!res) {
00322       ast_reentrancy_lock(lt);
00323       if (lt->reentrancy < AST_MAX_REENTRANCY) {
00324          lt->file[lt->reentrancy] = filename;
00325          lt->lineno[lt->reentrancy] = lineno;
00326          lt->func[lt->reentrancy] = func;
00327          lt->thread[lt->reentrancy] = pthread_self();
00328          lt->reentrancy++;
00329       } else {
00330          __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n",
00331                   filename, lineno, func, mutex_name);
00332       }
00333       ast_reentrancy_unlock(lt);
00334       if (t->tracking) {
00335          ast_mark_lock_acquired(t);
00336       }
00337    } else if (t->tracking) {
00338       ast_mark_lock_failed(t);
00339    }
00340 #endif /* DEBUG_THREADS */
00341 
00342    return res;
00343 }

int __ast_pthread_mutex_unlock ( const char *  filename,
int  lineno,
const char *  func,
const char *  mutex_name,
ast_mutex_t t 
)

Definition at line 345 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().

00347 {
00348    int res;
00349 
00350 #ifdef DEBUG_THREADS
00351    struct ast_lock_track *lt = &t->track;
00352    int canlog = strcmp(filename, "logger.c") & t->tracking;
00353 #ifdef HAVE_BKTR
00354    struct ast_bt *bt = NULL;
00355 #endif
00356 
00357 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00358    if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00359       __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
00360                filename, lineno, func, mutex_name);
00361       res = __ast_pthread_mutex_init(t->tracking, filename, lineno, func, mutex_name, t);
00362       if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00363          __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n",
00364                 filename, lineno, func, mutex_name);
00365       }
00366       return res;
00367    }
00368 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00369 
00370    ast_reentrancy_lock(lt);
00371    if (lt->reentrancy && (lt->thread[ROFFSET] != pthread_self())) {
00372       __ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n",
00373                filename, lineno, func, mutex_name);
00374       __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n",
00375                lt->file[ROFFSET], lt->lineno[ROFFSET], lt->func[ROFFSET], mutex_name);
00376 #ifdef HAVE_BKTR
00377       __dump_backtrace(&lt->backtrace[ROFFSET], canlog);
00378 #endif
00379       DO_THREAD_CRASH;
00380    }
00381 
00382    if (--lt->reentrancy < 0) {
00383       __ast_mutex_logger("%s line %d (%s): mutex '%s' freed more times than we've locked!\n",
00384                filename, lineno, func, mutex_name);
00385       lt->reentrancy = 0;
00386    }
00387 
00388    if (lt->reentrancy < AST_MAX_REENTRANCY) {
00389       lt->file[lt->reentrancy] = NULL;
00390       lt->lineno[lt->reentrancy] = 0;
00391       lt->func[lt->reentrancy] = NULL;
00392       lt->thread[lt->reentrancy] = 0;
00393    }
00394 
00395 #ifdef HAVE_BKTR
00396    if (lt->reentrancy) {
00397       bt = &lt->backtrace[lt->reentrancy - 1];
00398    }
00399 #endif
00400    ast_reentrancy_unlock(lt);
00401 
00402    if (t->tracking) {
00403 #ifdef HAVE_BKTR
00404       ast_remove_lock_info(t, bt);
00405 #else
00406       ast_remove_lock_info(t);
00407 #endif
00408    }
00409 #endif /* DEBUG_THREADS */
00410 
00411    res = pthread_mutex_unlock(&t->mutex);
00412 
00413 #ifdef DEBUG_THREADS
00414    if (res) {
00415       __ast_mutex_logger("%s line %d (%s): Error releasing mutex: %s\n",
00416                filename, lineno, func, strerror(res));
00417       DO_THREAD_CRASH;
00418    }
00419 #endif /* DEBUG_THREADS */
00420 
00421    return res;
00422 }

int __ast_rwlock_destroy ( const char *  filename,
int  lineno,
const char *  func,
const char *  rwlock_name,
ast_rwlock_t t 
)

Definition at line 691 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.

00692 {
00693    int res;
00694 
00695 #ifdef DEBUG_THREADS
00696    struct ast_lock_track *lt = &t->track;
00697    int canlog = strcmp(filename, "logger.c") & t->tracking;
00698 
00699 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00700    if (t->lock == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
00701       __ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is uninitialized.\n",
00702                filename, lineno, func, rwlock_name);
00703       return 0;
00704    }
00705 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00706 
00707 #endif /* DEBUG_THREADS */
00708 
00709    res = pthread_rwlock_destroy(&t->lock);
00710 
00711 #ifdef DEBUG_THREADS
00712    if (res) {
00713       __ast_mutex_logger("%s line %d (%s): Error destroying rwlock %s: %s\n",
00714             filename, lineno, func, rwlock_name, strerror(res));
00715    }
00716    ast_reentrancy_lock(lt);
00717    lt->file[0] = filename;
00718    lt->lineno[0] = lineno;
00719    lt->func[0] = func;
00720    lt->reentrancy = 0;
00721    lt->thread[0] = 0;
00722 #ifdef HAVE_BKTR
00723    memset(&lt->backtrace[0], 0, sizeof(lt->backtrace[0]));
00724 #endif
00725    ast_reentrancy_unlock(lt);
00726    delete_reentrancy_cs(lt);
00727 #endif /* DEBUG_THREADS */
00728 
00729    return res;
00730 }

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 658 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().

00659 {
00660    int res;
00661    pthread_rwlockattr_t attr;
00662 
00663 #ifdef DEBUG_THREADS
00664    struct ast_lock_track *lt= &t->track;
00665 
00666 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00667         int canlog = strcmp(filename, "logger.c") & t->tracking;
00668 
00669    if (t->lock != ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
00670       __ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is already initialized.\n",
00671             filename, lineno, func, rwlock_name);
00672       return 0;
00673    }
00674 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00675 
00676    ast_reentrancy_init(lt);
00677    t->tracking = tracking;
00678 #endif /* DEBUG_THREADS */
00679 
00680    pthread_rwlockattr_init(&attr);
00681 
00682 #ifdef HAVE_PTHREAD_RWLOCK_PREFER_WRITER_NP
00683    pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NP);
00684 #endif
00685 
00686    res = pthread_rwlock_init(&t->lock, &attr);
00687    pthread_rwlockattr_destroy(&attr);
00688    return res;
00689 }

int __ast_rwlock_rdlock ( ast_rwlock_t t,
const char *  name,
const char *  filename,
int  line,
const char *  func 
)

Definition at line 814 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_rwlock_info::track, and ast_rwlock_info::tracking.

Referenced by __ast_heap_rdlock().

00816 {
00817    int res;
00818 
00819 #ifdef DEBUG_THREADS
00820    struct ast_lock_track *lt = &t->track;
00821    int canlog = strcmp(filename, "logger.c") & t->tracking;
00822 #ifdef HAVE_BKTR
00823    struct ast_bt *bt = NULL;
00824 #endif
00825 
00826 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00827    if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
00828        /* Don't warn abount uninitialized lock.
00829         * Simple try to initialize it.
00830         * May be not needed in linux system.
00831         */
00832       res = __ast_rwlock_init(t->tracking, filename, line, func, name, t);
00833       if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
00834          __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n",
00835                filename, line, func, name);
00836          return res;
00837       }
00838    }
00839 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00840 
00841    if (t->tracking) {
00842 #ifdef HAVE_BKTR
00843       ast_reentrancy_lock(lt);
00844       if (lt->reentrancy != AST_MAX_REENTRANCY) {
00845          ast_bt_get_addresses(&lt->backtrace[lt->reentrancy]);
00846          bt = &lt->backtrace[lt->reentrancy];
00847       }
00848       ast_reentrancy_unlock(lt);
00849       ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t, bt);
00850 #else
00851       ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t);
00852 #endif
00853    }
00854 #endif /* DEBUG_THREADS */
00855 
00856 #if defined(DETECT_DEADLOCKS) && defined(DEBUG_THREADS)
00857    {
00858       time_t seconds = time(NULL);
00859       time_t wait_time, reported_wait = 0;
00860       do {
00861          res = pthread_rwlock_tryrdlock(&t->lock);
00862          if (res == EBUSY) {
00863             wait_time = time(NULL) - seconds;
00864             if (wait_time > reported_wait && (wait_time % 5) == 0) {
00865                __ast_mutex_logger("%s line %d (%s): Deadlock? waited %d sec for readlock '%s'?\n",
00866                   filename, line, func, (int)wait_time, name);
00867                ast_reentrancy_lock(lt);
00868 #ifdef HAVE_BKTR
00869                __dump_backtrace(&lt->backtrace[lt->reentrancy], canlog);
00870 #endif
00871                __ast_mutex_logger("%s line %d (%s): '%s' was locked  here.\n",
00872                      lt->file[lt->reentrancy-1], lt->lineno[lt->reentrancy-1],
00873                      lt->func[lt->reentrancy-1], name);
00874 #ifdef HAVE_BKTR
00875                __dump_backtrace(&lt->backtrace[lt->reentrancy-1], canlog);
00876 #endif
00877                ast_reentrancy_unlock(lt);
00878                reported_wait = wait_time;
00879             }
00880             usleep(200);
00881          }
00882       } while (res == EBUSY);
00883    }
00884 #else /* !DETECT_DEADLOCKS || !DEBUG_THREADS */
00885    res = pthread_rwlock_rdlock(&t->lock);
00886 #endif /* !DETECT_DEADLOCKS || !DEBUG_THREADS */
00887 
00888 #ifdef DEBUG_THREADS
00889    if (!res) {
00890       ast_reentrancy_lock(lt);
00891       if (lt->reentrancy < AST_MAX_REENTRANCY) {
00892          lt->file[lt->reentrancy] = filename;
00893          lt->lineno[lt->reentrancy] = line;
00894          lt->func[lt->reentrancy] = func;
00895          lt->thread[lt->reentrancy] = pthread_self();
00896          lt->reentrancy++;
00897       }
00898       ast_reentrancy_unlock(lt);
00899       if (t->tracking) {
00900          ast_mark_lock_acquired(t);
00901       }
00902    } else {
00903 #ifdef HAVE_BKTR
00904       if (lt->reentrancy) {
00905          ast_reentrancy_lock(lt);
00906          bt = &lt->backtrace[lt->reentrancy-1];
00907          ast_reentrancy_unlock(lt);
00908       } else {
00909          bt = NULL;
00910       }
00911       if (t->tracking) {
00912          ast_remove_lock_info(t, bt);
00913       }
00914 #else
00915       if (t->tracking) {
00916          ast_remove_lock_info(t);
00917       }
00918 #endif
00919       __ast_mutex_logger("%s line %d (%s): Error obtaining read lock: %s\n",
00920             filename, line, func, strerror(res));
00921       DO_THREAD_CRASH;
00922    }
00923 #endif /* DEBUG_THREADS */
00924 
00925    return res;
00926 }

int __ast_rwlock_timedrdlock ( ast_rwlock_t t,
const char *  name,
const struct timespec *  abs_timeout,
const char *  filename,
int  line,
const char *  func 
)

Definition at line 1042 of file lock.c.

References __ast_rwlock_init(), __AST_RWLOCK_INIT_VALUE, ast_bt_get_addresses(), AST_MAX_REENTRANCY, ast_tvnow(), ast_tvsub(), ast_lock_track::backtrace, ast_rwlock_info::lock, ast_lock_track::reentrancy, ast_rwlock_info::track, and ast_rwlock_info::tracking.

01044 {
01045    int res;
01046 
01047 #ifdef DEBUG_THREADS
01048    struct ast_lock_track *lt = &t->track;
01049    int canlog = strcmp(filename, "logger.c") & t->tracking;
01050 #ifdef HAVE_BKTR
01051    struct ast_bt *bt = NULL;
01052 #endif
01053 
01054 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
01055    if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
01056        /* Don't warn abount uninitialized lock.
01057         * Simple try to initialize it.
01058         * May be not needed in linux system.
01059         */
01060       res = __ast_rwlock_init(t->tracking, filename, line, func, name, t);
01061       if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
01062          __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n",
01063                filename, line, func, name);
01064          return res;
01065       }
01066    }
01067 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
01068 
01069    if (t->tracking) {
01070 #ifdef HAVE_BKTR
01071       ast_reentrancy_lock(lt);
01072       if (lt->reentrancy != AST_MAX_REENTRANCY) {
01073          ast_bt_get_addresses(&lt->backtrace[lt->reentrancy]);
01074          bt = &lt->backtrace[lt->reentrancy];
01075       }
01076       ast_reentrancy_unlock(lt);
01077       ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt);
01078 #else
01079       ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t);
01080 #endif
01081    }
01082 #endif /* DEBUG_THREADS */
01083 
01084 #ifdef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK
01085    res = pthread_rwlock_timedrdlock(&t->lock, abs_timeout);
01086 #else
01087    do {
01088       struct timeval _start = ast_tvnow(), _diff;
01089       for (;;) {
01090          if (!(res = pthread_rwlock_tryrdlock(&t->lock))) {
01091             break;
01092          }
01093          _diff = ast_tvsub(ast_tvnow(), _start);
01094          if (_diff.tv_sec > abs_timeout->tv_sec || (_diff.tv_sec == abs_timeout->tv_sec && _diff.tv_usec * 1000 > abs_timeout->tv_nsec)) {
01095             break;
01096          }
01097          usleep(1);
01098       }
01099    } while (0);
01100 #endif
01101 
01102 #ifdef DEBUG_THREADS
01103    if (!res) {
01104       ast_reentrancy_lock(lt);
01105       if (lt->reentrancy < AST_MAX_REENTRANCY) {
01106          lt->file[lt->reentrancy] = filename;
01107          lt->lineno[lt->reentrancy] = line;
01108          lt->func[lt->reentrancy] = func;
01109          lt->thread[lt->reentrancy] = pthread_self();
01110          lt->reentrancy++;
01111       }
01112       ast_reentrancy_unlock(lt);
01113       if (t->tracking) {
01114          ast_mark_lock_acquired(t);
01115       }
01116    } else {
01117 #ifdef HAVE_BKTR
01118       if (lt->reentrancy) {
01119          ast_reentrancy_lock(lt);
01120          bt = &lt->backtrace[lt->reentrancy-1];
01121          ast_reentrancy_unlock(lt);
01122       } else {
01123          bt = NULL;
01124       }
01125       if (t->tracking) {
01126          ast_remove_lock_info(t, bt);
01127       }
01128 #else
01129       if (t->tracking) {
01130          ast_remove_lock_info(t);
01131       }
01132 #endif
01133       __ast_mutex_logger("%s line %d (%s): Error obtaining read lock: %s\n",
01134             filename, line, func, strerror(res));
01135       DO_THREAD_CRASH;
01136    }
01137 #endif /* DEBUG_THREADS */
01138 
01139    return res;
01140 }

int __ast_rwlock_timedwrlock ( ast_rwlock_t t,
const char *  name,
const struct timespec *  abs_timeout,
const char *  filename,
int  line,
const char *  func 
)

Definition at line 1142 of file lock.c.

References __ast_rwlock_init(), __AST_RWLOCK_INIT_VALUE, ast_bt_get_addresses(), AST_MAX_REENTRANCY, ast_tvnow(), ast_tvsub(), ast_lock_track::backtrace, ast_rwlock_info::lock, ast_lock_track::reentrancy, ast_rwlock_info::track, and ast_rwlock_info::tracking.

01144 {
01145    int res;
01146 
01147 #ifdef DEBUG_THREADS
01148    struct ast_lock_track *lt = &t->track;
01149    int canlog = strcmp(filename, "logger.c") & t->tracking;
01150 #ifdef HAVE_BKTR
01151    struct ast_bt *bt = NULL;
01152 #endif
01153 
01154 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
01155    if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
01156        /* Don't warn abount uninitialized lock.
01157         * Simple try to initialize it.
01158         * May be not needed in linux system.
01159         */
01160       res = __ast_rwlock_init(t->tracking, filename, line, func, name, t);
01161       if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
01162          __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n",
01163                filename, line, func, name);
01164          return res;
01165       }
01166    }
01167 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
01168 
01169    if (t->tracking) {
01170 #ifdef HAVE_BKTR
01171       ast_reentrancy_lock(lt);
01172       if (lt->reentrancy != AST_MAX_REENTRANCY) {
01173          ast_bt_get_addresses(&lt->backtrace[lt->reentrancy]);
01174          bt = &lt->backtrace[lt->reentrancy];
01175       }
01176       ast_reentrancy_unlock(lt);
01177       ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt);
01178 #else
01179       ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t);
01180 #endif
01181    }
01182 #endif /* DEBUG_THREADS */
01183 
01184 #ifdef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK
01185    res = pthread_rwlock_timedwrlock(&t->lock, abs_timeout);
01186 #else
01187    do {
01188       struct timeval _start = ast_tvnow(), _diff;
01189       for (;;) {
01190          if (!(res = pthread_rwlock_trywrlock(&t->lock))) {
01191             break;
01192          }
01193          _diff = ast_tvsub(ast_tvnow(), _start);
01194          if (_diff.tv_sec > abs_timeout->tv_sec || (_diff.tv_sec == abs_timeout->tv_sec && _diff.tv_usec * 1000 > abs_timeout->tv_nsec)) {
01195             break;
01196          }
01197          usleep(1);
01198       }
01199    } while (0);
01200 #endif
01201 
01202 #ifdef DEBUG_THREADS
01203    if (!res) {
01204       ast_reentrancy_lock(lt);
01205       if (lt->reentrancy < AST_MAX_REENTRANCY) {
01206          lt->file[lt->reentrancy] = filename;
01207          lt->lineno[lt->reentrancy] = line;
01208          lt->func[lt->reentrancy] = func;
01209          lt->thread[lt->reentrancy] = pthread_self();
01210          lt->reentrancy++;
01211       }
01212       ast_reentrancy_unlock(lt);
01213       if (t->tracking) {
01214          ast_mark_lock_acquired(t);
01215       }
01216    } else {
01217 #ifdef HAVE_BKTR
01218       if (lt->reentrancy) {
01219          ast_reentrancy_lock(lt);
01220          bt = &lt->backtrace[lt->reentrancy-1];
01221          ast_reentrancy_unlock(lt);
01222       } else {
01223          bt = NULL;
01224       }
01225       if (t->tracking) {
01226          ast_remove_lock_info(t, bt);
01227       }
01228 #else
01229       if (t->tracking) {
01230          ast_remove_lock_info(t);
01231       }
01232 #endif
01233       __ast_mutex_logger("%s line %d (%s): Error obtaining read lock: %s\n",
01234             filename, line, func, strerror(res));
01235       DO_THREAD_CRASH;
01236    }
01237 #endif /* DEBUG_THREADS */
01238 
01239    return res;
01240 }

int __ast_rwlock_tryrdlock ( ast_rwlock_t t,
const char *  name,
const char *  filename,
int  line,
const char *  func 
)

Definition at line 1242 of file lock.c.

References __ast_rwlock_init(), __AST_RWLOCK_INIT_VALUE, ast_bt_get_addresses(), AST_MAX_REENTRANCY, ast_lock_track::backtrace, ast_rwlock_info::lock, ast_lock_track::reentrancy, ast_rwlock_info::track, and ast_rwlock_info::tracking.

01244 {
01245    int res;
01246 
01247 #ifdef DEBUG_THREADS
01248    struct ast_lock_track *lt = &t->track;
01249 #ifdef HAVE_BKTR
01250    struct ast_bt *bt = NULL;
01251 #endif
01252 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
01253    int canlog = strcmp(filename, "logger.c") & t->tracking;
01254 
01255    if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
01256        /* Don't warn abount uninitialized lock.
01257         * Simple try to initialize it.
01258         * May be not needed in linux system.
01259         */
01260       res = __ast_rwlock_init(t->tracking, filename, line, func, name, t);
01261       if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
01262          __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n",
01263                filename, line, func, name);
01264          return res;
01265       }
01266    }
01267 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
01268 
01269    if (t->tracking) {
01270 #ifdef HAVE_BKTR
01271       ast_reentrancy_lock(lt);
01272       if (lt->reentrancy != AST_MAX_REENTRANCY) {
01273          ast_bt_get_addresses(&lt->backtrace[lt->reentrancy]);
01274          bt = &lt->backtrace[lt->reentrancy];
01275       }
01276       ast_reentrancy_unlock(lt);
01277       ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t, bt);
01278 #else
01279       ast_store_lock_info(AST_RDLOCK, filename, line, func, name, t);
01280 #endif
01281    }
01282 #endif /* DEBUG_THREADS */
01283 
01284    res = pthread_rwlock_tryrdlock(&t->lock);
01285 
01286 #ifdef DEBUG_THREADS
01287    if (!res) {
01288       ast_reentrancy_lock(lt);
01289       if (lt->reentrancy < AST_MAX_REENTRANCY) {
01290          lt->file[lt->reentrancy] = filename;
01291          lt->lineno[lt->reentrancy] = line;
01292          lt->func[lt->reentrancy] = func;
01293          lt->thread[lt->reentrancy] = pthread_self();
01294          lt->reentrancy++;
01295       }
01296       ast_reentrancy_unlock(lt);
01297       if (t->tracking) {
01298          ast_mark_lock_acquired(t);
01299       }
01300    } else if (t->tracking) {
01301       ast_mark_lock_failed(t);
01302    }
01303 #endif /* DEBUG_THREADS */
01304 
01305    return res;
01306 }

int __ast_rwlock_trywrlock ( ast_rwlock_t t,
const char *  name,
const char *  filename,
int  line,
const char *  func 
)

Definition at line 1308 of file lock.c.

References __ast_rwlock_init(), __AST_RWLOCK_INIT_VALUE, ast_bt_get_addresses(), AST_MAX_REENTRANCY, ast_lock_track::backtrace, ast_rwlock_info::lock, ast_lock_track::reentrancy, ast_rwlock_info::track, and ast_rwlock_info::tracking.

01310 {
01311    int res;
01312 
01313 #ifdef DEBUG_THREADS
01314    struct ast_lock_track *lt= &t->track;
01315 #ifdef HAVE_BKTR
01316    struct ast_bt *bt = NULL;
01317 #endif
01318 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
01319    int canlog = strcmp(filename, "logger.c") & t->tracking;
01320 
01321    if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
01322        /* Don't warn abount uninitialized lock.
01323         * Simple try to initialize it.
01324         * May be not needed in linux system.
01325         */
01326       res = __ast_rwlock_init(t->tracking, filename, line, func, name, t);
01327       if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
01328          __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n",
01329                filename, line, func, name);
01330          return res;
01331       }
01332    }
01333 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
01334 
01335    if (t->tracking) {
01336 #ifdef HAVE_BKTR
01337       ast_reentrancy_lock(lt);
01338       if (lt->reentrancy != AST_MAX_REENTRANCY) {
01339          ast_bt_get_addresses(&lt->backtrace[lt->reentrancy]);
01340          bt = &lt->backtrace[lt->reentrancy];
01341       }
01342       ast_reentrancy_unlock(lt);
01343       ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt);
01344 #else
01345       ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t);
01346 #endif
01347    }
01348 #endif /* DEBUG_THREADS */
01349 
01350    res = pthread_rwlock_trywrlock(&t->lock);
01351 
01352 #ifdef DEBUG_THREADS
01353    if (!res) {
01354       ast_reentrancy_lock(lt);
01355       if (lt->reentrancy < AST_MAX_REENTRANCY) {
01356          lt->file[lt->reentrancy] = filename;
01357          lt->lineno[lt->reentrancy] = line;
01358          lt->func[lt->reentrancy] = func;
01359          lt->thread[lt->reentrancy] = pthread_self();
01360          lt->reentrancy++;
01361       }
01362       ast_reentrancy_unlock(lt);
01363       if (t->tracking) {
01364          ast_mark_lock_acquired(t);
01365       }
01366    } else if (t->tracking) {
01367       ast_mark_lock_failed(t);
01368    }
01369 #endif /* DEBUG_THREADS */
01370 
01371    return res;
01372 }

int __ast_rwlock_unlock ( ast_rwlock_t t,
const char *  name,
const char *  filename,
int  line,
const char *  func 
)

Definition at line 732 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().

00734 {
00735    int res;
00736 
00737 #ifdef DEBUG_THREADS
00738    struct ast_lock_track *lt = &t->track;
00739    int canlog = strcmp(filename, "logger.c") & t->tracking;
00740 #ifdef HAVE_BKTR
00741    struct ast_bt *bt = NULL;
00742 #endif
00743    int lock_found = 0;
00744 
00745 
00746 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00747    if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
00748       __ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is uninitialized.\n",
00749                filename, line, func, name);
00750       res = __ast_rwlock_init(t->tracking, filename, line, func, name, t);
00751       if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
00752          __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n",
00753                filename, line, func, name);
00754       }
00755       return res;
00756    }
00757 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00758 
00759    ast_reentrancy_lock(lt);
00760    if (lt->reentrancy) {
00761       int i;
00762       pthread_t self = pthread_self();
00763       for (i = lt->reentrancy - 1; i >= 0; --i) {
00764          if (lt->thread[i] == self) {
00765             lock_found = 1;
00766             if (i != lt->reentrancy - 1) {
00767                lt->file[i] = lt->file[lt->reentrancy - 1];
00768                lt->lineno[i] = lt->lineno[lt->reentrancy - 1];
00769                lt->func[i] = lt->func[lt->reentrancy - 1];
00770                lt->thread[i] = lt->thread[lt->reentrancy - 1];
00771             }
00772 #ifdef HAVE_BKTR
00773             bt = &lt->backtrace[i];
00774 #endif
00775             lt->file[lt->reentrancy - 1] = NULL;
00776             lt->lineno[lt->reentrancy - 1] = 0;
00777             lt->func[lt->reentrancy - 1] = NULL;
00778             lt->thread[lt->reentrancy - 1] = AST_PTHREADT_NULL;
00779             break;
00780          }
00781       }
00782    }
00783 
00784    if (lock_found && --lt->reentrancy < 0) {
00785       __ast_mutex_logger("%s line %d (%s): rwlock '%s' freed more times than we've locked!\n",
00786             filename, line, func, name);
00787       lt->reentrancy = 0;
00788    }
00789 
00790    ast_reentrancy_unlock(lt);
00791 
00792    if (t->tracking) {
00793 #ifdef HAVE_BKTR
00794       ast_remove_lock_info(t, bt);
00795 #else
00796       ast_remove_lock_info(t);
00797 #endif
00798    }
00799 #endif /* DEBUG_THREADS */
00800 
00801    res = pthread_rwlock_unlock(&t->lock);
00802 
00803 #ifdef DEBUG_THREADS
00804    if (res) {
00805       __ast_mutex_logger("%s line %d (%s): Error releasing rwlock: %s\n",
00806             filename, line, func, strerror(res));
00807       DO_THREAD_CRASH;
00808    }
00809 #endif /* DEBUG_THREADS */
00810 
00811    return res;
00812 }

int __ast_rwlock_wrlock ( ast_rwlock_t t,
const char *  name,
const char *  filename,
int  line,
const char *  func 
)

Definition at line 928 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_rwlock_info::track, and ast_rwlock_info::tracking.

Referenced by __ast_heap_wrlock().

00930 {
00931    int res;
00932 
00933 #ifdef DEBUG_THREADS
00934    struct ast_lock_track *lt = &t->track;
00935    int canlog = strcmp(filename, "logger.c") & t->tracking;
00936 #ifdef HAVE_BKTR
00937    struct ast_bt *bt = NULL;
00938 #endif
00939 
00940 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00941    if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
00942        /* Don't warn abount uninitialized lock.
00943         * Simple try to initialize it.
00944         * May be not needed in linux system.
00945         */
00946       res = __ast_rwlock_init(t->tracking, filename, line, func, name, t);
00947       if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
00948          __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n",
00949                filename, line, func, name);
00950          return res;
00951       }
00952    }
00953 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00954 
00955    if (t->tracking) {
00956 #ifdef HAVE_BKTR
00957       ast_reentrancy_lock(lt);
00958       if (lt->reentrancy != AST_MAX_REENTRANCY) {
00959          ast_bt_get_addresses(&lt->backtrace[lt->reentrancy]);
00960          bt = &lt->backtrace[lt->reentrancy];
00961       }
00962       ast_reentrancy_unlock(lt);
00963       ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t, bt);
00964 #else
00965       ast_store_lock_info(AST_WRLOCK, filename, line, func, name, t);
00966 #endif
00967    }
00968 #endif /* DEBUG_THREADS */
00969 
00970 #if defined(DETECT_DEADLOCKS) && defined(DEBUG_THREADS)
00971    {
00972       time_t seconds = time(NULL);
00973       time_t wait_time, reported_wait = 0;
00974       do {
00975          res = pthread_rwlock_trywrlock(&t->lock);
00976          if (res == EBUSY) {
00977             wait_time = time(NULL) - seconds;
00978             if (wait_time > reported_wait && (wait_time % 5) == 0) {
00979                __ast_mutex_logger("%s line %d (%s): Deadlock? waited %d sec for writelock '%s'?\n",
00980                   filename, line, func, (int)wait_time, name);
00981                ast_reentrancy_lock(lt);
00982 #ifdef HAVE_BKTR
00983                __dump_backtrace(&lt->backtrace[lt->reentrancy], canlog);
00984 #endif
00985                __ast_mutex_logger("%s line %d (%s): '%s' was locked  here.\n",
00986                      lt->file[lt->reentrancy-1], lt->lineno[lt->reentrancy-1],
00987                      lt->func[lt->reentrancy-1], name);
00988 #ifdef HAVE_BKTR
00989                __dump_backtrace(&lt->backtrace[lt->reentrancy-1], canlog);
00990 #endif
00991                ast_reentrancy_unlock(lt);
00992                reported_wait = wait_time;
00993             }
00994             usleep(200);
00995          }
00996       } while (res == EBUSY);
00997    }
00998 #else /* !DETECT_DEADLOCKS || !DEBUG_THREADS */
00999    res = pthread_rwlock_wrlock(&t->lock);
01000 #endif /* !DETECT_DEADLOCKS || !DEBUG_THREADS */
01001 
01002 #ifdef DEBUG_THREADS
01003    if (!res) {
01004       ast_reentrancy_lock(lt);
01005       if (lt->reentrancy < AST_MAX_REENTRANCY) {
01006          lt->file[lt->reentrancy] = filename;
01007          lt->lineno[lt->reentrancy] = line;
01008          lt->func[lt->reentrancy] = func;
01009          lt->thread[lt->reentrancy] = pthread_self();
01010          lt->reentrancy++;
01011       }
01012       ast_reentrancy_unlock(lt);
01013       if (t->tracking) {
01014          ast_mark_lock_acquired(t);
01015       }
01016    } else {
01017 #ifdef HAVE_BKTR
01018       if (lt->reentrancy) {
01019          ast_reentrancy_lock(lt);
01020          bt = &lt->backtrace[lt->reentrancy-1];
01021          ast_reentrancy_unlock(lt);
01022       } else {
01023          bt = NULL;
01024       }
01025       if (t->tracking) {
01026          ast_remove_lock_info(t, bt);
01027       }
01028 #else
01029       if (t->tracking) {
01030          ast_remove_lock_info(t);
01031       }
01032 #endif
01033       __ast_mutex_logger("%s line %d (%s): Error obtaining write lock: %s\n",
01034             filename, line, func, strerror(res));
01035       DO_THREAD_CRASH;
01036    }
01037 #endif /* DEBUG_THREADS */
01038 
01039    return res;
01040 }

int ast_atomic_dec_and_test ( volatile int *  p  )  [inline]

decrement *p by 1 and return true if the variable has reached 0. Useful e.g. to check if a refcount has reached 0.

Definition at line 638 of file lock.h.

Referenced by dispose_conf(), iax2_process_thread_cleanup(), run_station(), and sla_station_exec().

00641 {

int ast_atomic_fetchadd_int ( volatile int *  p,
int  v 
) [inline]

Atomically add v to *p and return * the previous value of *p. This can be used to handle reference counts, and the return value can be used to generate unique identifiers.

Definition at line 592 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(), add_subscribe_event(), admin_exec(), advance_event(), append_event(), ast_cli_command_full(), ast_dial_append(), ast_event_subscribe_new(), ast_module_ref(), ast_module_unref(), authenticate_verify(), build_conf(), build_peer(), cc_device_monitor_init(), cc_extension_monitor_init(), cc_interfaces_datastore_init(), cdr_seq_inc(), create_new_sip_etag(), dahdi_destroy(), dahdi_request(), dahdi_translate(), destroy_session(), dundi_query_read(), enum_query_read(), fax_session_new(), fax_session_release(), fax_session_reserve(), find_idle_thread(), find_session(), generic_fax_exec(), grab_last(), iax2_destroy_helper(), iax2_process_thread(), iax_frame_free(), iax_frame_new(), inprocess_count(), internal_ao2_alloc(), internal_ao2_callback(), internal_ao2_container_alloc(), internal_ao2_link(), internal_ao2_ref(), load_realtime_queue(), receivefax_exec(), run_station(), sendfax_exec(), session_destructor(), sig_pri_hangup(), sip_destroy_peer(), sip_new(), sip_peer_hold(), sip_register(), sip_registry_destroy(), sla_add_trunk_to_station(), sla_handle_hold_event(), sla_station_exec(), sla_trunk_exec(), smdi_msg_retrieve_read(), spandsp_fax_switch_to_t38(), temp_peer(), and update_stats().

00595 {

int ast_atomic_fetchadd_int_slow ( volatile int *  p,
int  v 
)

Definition at line 1827 of file utils.c.

References ast_mutex_lock, ast_mutex_unlock, and fetchadd_m.

01828 {
01829    int ret;
01830    ast_mutex_lock(&fetchadd_m);
01831    ret = *p;
01832    *p += v;
01833    ast_mutex_unlock(&fetchadd_m);
01834    return ret;
01835 }


Generated on Wed Apr 6 11:30:06 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7