Thu Jun 7 02:14:56 2012

Asterisk developer's documentation


lock.h File Reference

General Asterisk channel locking definitions. More...

#include <pthread.h>
#include <netdb.h>
#include <time.h>
#include <sys/param.h>
#include <unistd.h>
#include "asterisk/logger.h"
#include "asterisk/compiler.h"
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include "asterisk/inline_api.h"

Go to the source code of this file.

Data Structures

struct  ast_mutex_info

Defines

#define __AST_MUTEX_DEFINE(scope, mutex, init_val, track)   scope ast_mutex_t mutex = init_val
#define __ast_mutex_logger(...)   do { if (canlog) ast_log(LOG_ERROR, __VA_ARGS__); else fprintf(stderr, __VA_ARGS__); } while (0)
#define __AST_RWLOCK_DEFINE(scope, rwlock)   scope ast_rwlock_t rwlock = AST_RWLOCK_INIT_VALUE
#define __MTX_PROF(a)   return pthread_mutex_lock((a))
#define ast_channel_lock(x)   ast_mutex_lock(&x->lock)
 Lock a channel. If DEBUG_CHANNEL_LOCKS is defined in the Makefile, print relevant output for debugging.
#define ast_channel_trylock(x)   ast_mutex_trylock(&x->lock)
 Try locking a channel. If DEBUG_CHANNEL_LOCKS is defined in the Makefile, print relevant output for debugging.
#define ast_channel_unlock(x)   ast_mutex_unlock(&x->lock)
 Unlock a channel. If DEBUG_CHANNEL_LOCKS is defined in the Makefile, print relevant output for debugging.
#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_MAX_REENTRANCY   10
#define AST_MUTEX_DEFINE_STATIC(mutex)   __AST_MUTEX_DEFINE(static, mutex, AST_MUTEX_INIT_VALUE, 1)
#define AST_MUTEX_DEFINE_STATIC_NOTRACKING(mutex)   __AST_MUTEX_DEFINE(static, mutex, AST_MUTEX_INIT_VALUE_NOTRACKING, 0)
#define ast_mutex_destroy(a)   __ast_pthread_mutex_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a)
#define ast_mutex_init(pmutex)   __ast_pthread_mutex_init(1, __FILE__, __LINE__, __PRETTY_FUNCTION__, #pmutex, pmutex)
#define ast_mutex_init_notracking(pmutex)   __ast_pthread_mutex_init(0, __FILE__, __LINE__, __PRETTY_FUNCTION__, #pmutex, pmutex)
#define AST_MUTEX_INIT_VALUE   { PTHREAD_MUTEX_INIT_VALUE, 1, { NULL }, { 0 }, 0, { NULL }, { 0 }, PTHREAD_MUTEX_INIT_VALUE }
#define AST_MUTEX_INIT_VALUE_NOTRACKING   { PTHREAD_MUTEX_INIT_VALUE, 0, { NULL }, { 0 }, 0, { NULL }, { 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
#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)
#define ast_rwlock_destroy(rwlock)   __ast_rwlock_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, #rwlock, rwlock)
#define ast_rwlock_init(rwlock)   __ast_rwlock_init(__FILE__, __LINE__, __PRETTY_FUNCTION__, #rwlock, rwlock)
#define AST_RWLOCK_INIT_VALUE   PTHREAD_RWLOCK_INITIALIZER
#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 DEADLOCK_AVOIDANCE(lock)
 Unlock a lock briefly.
#define DO_THREAD_CRASH   do { } while (0)
#define gethostbyname   __gethostbyname__is__not__reentrant__use__ast_gethostbyname__instead__
#define pthread_cond_broadcast   use_ast_cond_broadcast_instead_of_pthread_cond_broadcast
#define pthread_cond_destroy   use_ast_cond_destroy_instead_of_pthread_cond_destroy
#define pthread_cond_init   use_ast_cond_init_instead_of_pthread_cond_init
#define pthread_cond_signal   use_ast_cond_signal_instead_of_pthread_cond_signal
#define pthread_cond_t   use_ast_cond_t_instead_of_pthread_cond_t
#define pthread_cond_timedwait   use_ast_cond_timedwait_instead_of_pthread_cond_timedwait
#define pthread_cond_wait   use_ast_cond_wait_instead_of_pthread_cond_wait
#define pthread_create   __use_ast_pthread_create_instead__
#define pthread_mutex_destroy   use_ast_mutex_destroy_instead_of_pthread_mutex_destroy
#define pthread_mutex_init   use_ast_mutex_init_instead_of_pthread_mutex_init
#define PTHREAD_MUTEX_INIT_VALUE   PTHREAD_MUTEX_INITIALIZER
#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   ((t->reentrancy > 0) ? (t->reentrancy-1) : 0)

Typedefs

typedef pthread_cond_t ast_cond_t
typedef struct ast_mutex_info ast_mutex_t
typedef pthread_rwlock_t ast_rwlock_t

Enumerations

enum  ast_lock_type { AST_MUTEX, AST_RDLOCK, AST_WRLOCK }

Functions

static int __ast_cond_broadcast (const char *filename, int lineno, const char *func, const char *cond_name, ast_cond_t *cond)
static int __ast_cond_destroy (const char *filename, int lineno, const char *func, const char *cond_name, ast_cond_t *cond)
static 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)
static int __ast_cond_signal (const char *filename, int lineno, const char *func, const char *cond_name, ast_cond_t *cond)
static 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)
static 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)
static int __ast_pthread_mutex_destroy (const char *filename, int lineno, const char *func, const char *mutex_name, ast_mutex_t *t)
static int __ast_pthread_mutex_init (int track, const char *filename, int lineno, const char *func, const char *mutex_name, ast_mutex_t *t)
static int __ast_pthread_mutex_lock (const char *filename, int lineno, const char *func, const char *mutex_name, ast_mutex_t *t)
static int __ast_pthread_mutex_trylock (const char *filename, int lineno, const char *func, const char *mutex_name, ast_mutex_t *t) attribute_warn_unused_result
static int __ast_pthread_mutex_unlock (const char *filename, int lineno, const char *func, const char *mutex_name, ast_mutex_t *t)
static int __ast_rwlock_destroy (const char *filename, int lineno, const char *func, const char *rwlock_name, ast_rwlock_t *prwlock)
static int __ast_rwlock_init (const char *filename, int lineno, const char *func, const char *rwlock_name, ast_rwlock_t *prwlock)
static int _ast_rwlock_rdlock (ast_rwlock_t *lock, const char *name, const char *file, int line, const char *func)
static int _ast_rwlock_timedrdlock (ast_rwlock_t *lock, const char *name, const struct timespec *abs_timeout, const char *file, int line, const char *func)
static int _ast_rwlock_timedwrlock (ast_rwlock_t *lock, const char *name, const struct timespec *abs_timeout, const char *file, int line, const char *func)
static int _ast_rwlock_tryrdlock (ast_rwlock_t *lock, const char *name, const char *file, int line, const char *func)
static int _ast_rwlock_trywrlock (ast_rwlock_t *lock, const char *name, const char *file, int line, const char *func)
static int _ast_rwlock_unlock (ast_rwlock_t *lock, const char *name, const char *file, int line, const char *func)
static int _ast_rwlock_wrlock (ast_rwlock_t *lock, const char *name, const char *file, 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)
int ast_find_lock_info (void *lock_addr, char *filename, size_t filename_size, int *lineno, char *func, size_t func_size, char *mutex_name, size_t mutex_name_size)
 retrieve lock info for the specified mutex
void ast_mark_lock_acquired (void *lock_addr)
 Mark the last lock as acquired.
void ast_mark_lock_failed (void *lock_addr)
 Mark the last lock as failed (trylock).
static void ast_reentrancy_init (ast_mutex_t *p_ast_mutex)
static void ast_reentrancy_lock (ast_mutex_t *p_ast_mutex)
static void ast_reentrancy_unlock (ast_mutex_t *p_ast_mutex)
void ast_remove_lock_info (void *lock_addr)
 remove lock info for the current thread
void ast_store_lock_info (enum ast_lock_type type, const char *filename, int line_num, const char *func, const char *lock_name, void *lock_addr)
 Store lock info for the current thread.
static void delete_reentrancy_cs (ast_mutex_t *p_ast_mutex)
static void init_empty_mutex (void)

Variables

static pthread_mutex_t empty_mutex

Detailed Description

General Asterisk channel locking 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 832 of file lock.h.

#define __ast_mutex_logger ( ...   )     do { if (canlog) ast_log(LOG_ERROR, __VA_ARGS__); else fprintf(stderr, __VA_ARGS__); } while (0)
#define __AST_RWLOCK_DEFINE ( scope,
rwlock   )     scope ast_rwlock_t rwlock = AST_RWLOCK_INIT_VALUE

Definition at line 1284 of file lock.h.

#define __MTX_PROF (  )     return pthread_mutex_lock((a))

Definition at line 64 of file lock.h.

#define ast_channel_lock (  )     ast_mutex_lock(&x->lock)

Lock a channel. If DEBUG_CHANNEL_LOCKS is defined in the Makefile, print relevant output for debugging.

Definition at line 1384 of file lock.h.

Referenced by __ast_pbx_run(), __ast_queue_frame(), __login_exec(), __oh323_destroy(), __sip_destroy(), _macro_exec(), action_redirect(), add_features_datastores(), agent_hangup(), agent_indicate(), ast_activate_generator(), ast_answer(), ast_async_goto(), ast_audiohook_attach(), ast_audiohook_detach_source(), ast_audiohook_remove(), ast_autoservice_start(), ast_autoservice_stop(), ast_bridge_call(), ast_call(), ast_call_forward(), ast_channel_clear_softhangup(), ast_channel_free(), ast_channel_masquerade(), ast_check_hangup_locked(), ast_deactivate_generator(), ast_dial_join(), ast_do_masquerade(), ast_explicit_goto(), ast_hangup(), ast_indicate_data(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_read_generator_actions(), ast_rtp_bridge(), ast_rtp_early_bridge(), ast_rtp_make_compatible(), ast_safe_sleep_conditional(), ast_sendtext(), ast_set_callerid(), ast_settimeout(), ast_softhangup(), ast_stopstream(), ast_transfer(), ast_udptl_bridge(), ast_waitfor_nandfds(), ast_write(), asyncgoto_exec(), builtin_atxfer(), callerid_read(), callerid_write(), channel_spy(), clear_dialed_interfaces(), common_exec(), dahdi_handle_dtmf(), do_parking_thread(), end_bridge_callback(), feature_check(), feature_interpret(), feature_request_and_dial(), func_header_read(), func_inheritance_write(), function_agent(), function_sipchaninfo_read(), generator_force(), handle_request_invite(), local_ast_moh_stop(), local_hangup(), local_queue_frame(), local_setoption(), moh_files_generator(), p2p_callback_disable(), park_exec(), pbx_builtin_background(), pbx_builtin_getvar_helper(), pbx_builtin_pushvar_helper(), pbx_builtin_serialize_variables(), pbx_builtin_setvar_helper(), pbx_retrieve_variable(), ring_entry(), sendtext_exec(), set_ext_pri(), set_format(), setup_inheritance_datastore(), setup_mixmonitor_ds(), setup_transfer_datastore(), sip_addheader(), sip_dtmfmode(), sip_park(), sip_park_thread(), smdi_msg_read(), smdi_msg_retrieve_read(), stop_mixmonitor_exec(), transmit_invite(), try_calling(), and update_bridgepeer().

#define ast_channel_trylock (  )     ast_mutex_trylock(&x->lock)
#define ast_channel_unlock (  )     ast_mutex_unlock(&x->lock)

Unlock a channel. If DEBUG_CHANNEL_LOCKS is defined in the Makefile, print relevant output for debugging.

Definition at line 1387 of file lock.h.

Referenced by __ast_pbx_run(), __ast_queue_frame(), __ast_read(), __login_exec(), __oh323_destroy(), __oh323_rtp_create(), __sip_autodestruct(), __sip_destroy(), _macro_exec(), action_getvar(), action_hangup(), action_redirect(), action_setvar(), action_status(), action_timeout(), add_features_datastores(), agent_hangup(), agent_indicate(), agent_logoff(), agent_read(), ast_activate_generator(), ast_answer(), ast_async_goto(), ast_async_goto_by_name(), ast_audiohook_attach(), ast_audiohook_detach_source(), ast_audiohook_remove(), ast_autoservice_start(), ast_autoservice_stop(), ast_bridge_call(), ast_call(), ast_call_forward(), ast_channel_clear_softhangup(), ast_channel_free(), ast_channel_masquerade(), ast_check_hangup_locked(), ast_complete_channels(), ast_deactivate_generator(), ast_dial_join(), ast_do_masquerade(), ast_explicit_goto(), ast_hangup(), ast_indicate_data(), ast_parse_device_state(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_pickup_call(), ast_queue_hangup(), ast_read_generator_actions(), ast_rtp_bridge(), ast_rtp_early_bridge(), ast_rtp_make_compatible(), ast_safe_sleep_conditional(), ast_sendtext(), ast_set_callerid(), ast_settimeout(), ast_softhangup(), ast_stopstream(), ast_transfer(), ast_udptl_bridge(), ast_waitfor_nandfds(), ast_write(), asyncgoto_exec(), auto_congest(), bridge_native_loop(), bridge_p2p_loop(), builtin_atxfer(), callerid_read(), callerid_write(), change_monitor_action(), channel_spy(), chanspy_ds_free(), cleanup_connection(), clear_dialed_interfaces(), common_exec(), dahdi_handle_dtmf(), dahdi_softhangup_all(), do_monitor(), do_parking_thread(), do_pause_or_unpause(), end_bridge_callback(), fast_originate(), feature_check(), feature_interpret(), feature_request_and_dial(), func_header_read(), func_inheritance_write(), function_agent(), function_sipchaninfo_read(), generator_force(), handle_chanlist(), handle_chanlist_deprecated(), handle_channelstatus(), handle_core_set_debug_channel(), handle_debugchan_deprecated(), handle_getvariablefull(), handle_hangup(), handle_invite_replaces(), handle_nodebugchan_deprecated(), handle_request_invite(), handle_request_refer(), handle_showchan(), handle_showchan_deprecated(), handle_softhangup(), hangup_connection(), local_ast_moh_stop(), local_attended_transfer(), local_hangup(), local_queue_frame(), local_setoption(), manager_park(), mixmonitor_cli(), moh_files_generator(), next_channel(), oh323_rtp_read(), oh323_simulate_dtmf_end(), p2p_callback_disable(), park_call_full(), park_exec(), pbx_builtin_background(), pbx_builtin_getvar_helper(), pbx_builtin_importvar(), pbx_builtin_pushvar_helper(), pbx_builtin_serialize_variables(), pbx_builtin_setvar_helper(), pbx_retrieve_variable(), pickup_by_exten(), pickup_by_mark(), pri_queue_frame(), receive_digit(), retrans_pkt(), ring_entry(), scheduler_process_request_queue(), send_provisional_keepalive_full(), sendtext_exec(), set_ext_pri(), set_format(), setup_chanspy_ds(), setup_inheritance_datastore(), setup_mixmonitor_ds(), setup_rtp_connection(), setup_transfer_datastore(), sip_addheader(), sip_dtmfmode(), sip_park(), sip_park_thread(), sip_reinvite_retry(), sipsock_read(), smdi_msg_read(), smdi_msg_retrieve_read(), start_monitor_action(), stop_mixmonitor_exec(), stop_monitor_action(), transmit_invite(), try_calling(), update_bridgepeer(), and update_state().

#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_MAX_REENTRANCY   10
#define AST_MUTEX_DEFINE_STATIC ( mutex   )     __AST_MUTEX_DEFINE(static, mutex, AST_MUTEX_INIT_VALUE, 1)

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

#define ast_mutex_destroy (  )     __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)

Definition at line 298 of file lock.h.

#define AST_MUTEX_INIT_VALUE   { PTHREAD_MUTEX_INIT_VALUE, 1, { NULL }, { 0 }, 0, { NULL }, { 0 }, PTHREAD_MUTEX_INIT_VALUE }

Definition at line 110 of file lock.h.

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

Definition at line 111 of file lock.h.

#define AST_MUTEX_INITIALIZER   __use_AST_MUTEX_DEFINE_STATIC_rather_than_AST_MUTEX_INITIALIZER__

Definition at line 853 of file lock.h.

#define AST_MUTEX_KIND   PTHREAD_MUTEX_RECURSIVE

Definition at line 93 of file lock.h.

Referenced by __ast_pthread_mutex_init(), ast_reentrancy_init(), and dummy_start().

#define ast_mutex_lock (  )     __ast_pthread_mutex_lock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a)

Definition at line 713 of file lock.h.

Referenced by __action_showchannels(), __ao2_lock(), __ast_context_destroy(), __ast_key_get(), __attempt_transmit(), __auth_reject(), __auto_congest(), __auto_hangup(), __find_callno(), __get_from_jb(), __iax2_poke_noanswer(), __login_exec(), __oh323_new(), __send_lagrq(), __send_ping(), __sip_autodestruct(), __sip_destroy(), __sip_show_channels(), __unload_module(), accept_thread(), action_agent_callback_login(), action_agents(), action_waitevent(), agent_ack_sleep(), agent_call(), agent_cleanup(), agent_cont_sleep(), agent_devicestate(), agent_devicestate_cb(), agent_digit_begin(), agent_digit_end(), agent_fixup(), agent_hangup(), agent_indicate(), agent_logoff(), agent_read(), agent_request(), agent_sendhtml(), agent_sendtext(), agent_write(), agents_show(), agents_show_online(), alsa_answer(), alsa_call(), alsa_digit(), alsa_fixup(), alsa_hangup(), alsa_indicate(), alsa_read(), alsa_request(), alsa_text(), alsa_write(), announce_thread(), answer_exec_run(), ao2_lock(), app_exec(), append_mailbox_mapping(), ast_add_extension2(), ast_atomic_fetchadd_int_slow(), ast_cdr_detach(), ast_cdr_engine_init(), ast_cdr_submit_batch(), ast_cli_netstats(), ast_config_engine_deregister(), ast_config_engine_register(), ast_context_add_ignorepat2(), ast_context_add_include2(), ast_context_add_switch2(), ast_context_lockmacro(), ast_context_remove_extension_callerid2(), ast_context_remove_ignorepat2(), ast_context_remove_include2(), ast_context_remove_switch2(), ast_db_del(), ast_db_deltree(), ast_db_get(), ast_db_gettree(), ast_db_put(), ast_dial_join(), ast_dnsmgr_changed(), ast_enum_init(), ast_get_enum(), ast_get_indication_tone(), ast_get_indication_zone(), ast_get_txt(), ast_iax2_new(), ast_lock_context(), ast_lock_contexts(), ast_monitor_start(), ast_odbc_smart_execute(), ast_random(), ast_rdlock_contexts(), ast_register_indication(), ast_register_indication_country(), ast_replace_sigchld(), ast_rtp_get_bridged(), ast_rtp_get_current_formats(), ast_rtp_lookup_code(), ast_rtp_lookup_pt(), ast_rtp_pt_clear(), ast_rtp_pt_copy(), ast_rtp_pt_default(), ast_rtp_set_m_type(), ast_rtp_set_rtpmap_type(), ast_rtp_unset_m_type(), ast_sched_add_variable(), ast_sched_del(), ast_sched_runq(), 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_unregister_indication(), ast_unregister_indication_country(), ast_unreplace_sigchld(), ast_walk_indications(), ast_wrlock_contexts(), astman_append(), astman_verify_session_readpermissions(), astman_verify_session_writepermissions(), auth_reject(), authenticate_reply(), auto_congest(), auto_hangup(), cb_events(), channel_spy(), chanspy_ds_chan_fixup(), chanspy_ds_destroy(), chanspy_ds_free(), check_availability(), check_beep(), cl_dequeue_chan(), cl_queue_chan(), clear_config_maps(), common_exec(), complete_dpreply(), complete_sipch(), conf_free(), conf_run(), config_command(), config_pgsql(), console_answer(), console_answer_deprecated(), console_autoanswer(), console_autoanswer_deprecated(), console_dial(), console_dial_deprecated(), console_hangup(), console_hangup_deprecated(), console_sendtext(), console_sendtext_deprecated(), crypto_load(), csv_log(), custom_log(), dahdi_accept_r2_call_exec(), dahdi_answer(), dahdi_bridge(), dahdi_call(), dahdi_destroy_channel_bynum(), dahdi_digit_begin(), dahdi_digit_end(), dahdi_exception(), dahdi_fixup(), dahdi_func_read(), dahdi_handle_dtmf(), dahdi_hangup(), dahdi_indicate(), dahdi_pri_error(), dahdi_pri_message(), dahdi_queue_frame(), 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_show_channel(), dahdi_show_channels(), dahdi_softhangup_all(), dahdi_unlink(), database_show(), database_showkey(), decrease_call_count(), defer_full_frame(), delete_devices(), delete_users(), destroy_all_channels(), destroy_all_mailbox_mappings(), destroy_endpoint(), destroy_monitor_audiohook(), destroy_session(), device_state_thread(), dial_trunk(), dnsmgr_refresh(), do_cdr(), do_monitor(), do_parking_thread(), do_reload(), donodelog(), dp_lookup(), dump_cmd_queues(), dump_queue(), features_answer(), features_call(), features_digit_begin(), features_digit_end(), features_fixup(), features_hangup(), features_indicate(), features_read(), features_show(), features_write(), find_cache(), find_call(), find_call_locked(), find_command(), find_engine(), find_line_by_name(), find_session(), find_subchannel_and_lock(), find_tpeer(), function_remote(), generic_http_callback(), get_input(), get_sip_pvt_byid_locked(), gethostbyname_r(), gtalk_alloc(), gtalk_answer(), gtalk_digit(), gtalk_fixup(), gtalk_get_rtp_peer(), gtalk_hangup(), gtalk_newcall(), gtalk_read(), gtalk_set_rtp_peer(), gtalk_show_channels(), gtalk_write(), h323_reload(), handle_capabilities_res_message(), handle_deferred_full_frames(), handle_invite_replaces(), handle_line_state_req_message(), handle_mfcr2_call_files(), handle_mfcr2_set_blocked(), handle_mfcr2_set_debug(), handle_mfcr2_set_idle(), handle_mfcr2_show_channels(), handle_modlist(), handle_parkedcalls(), handle_pri_set_debug_file(), handle_pri_show_debug(), handle_pri_show_span(), handle_request(), handle_request_invite(), handle_response_invite(), handle_save_dialplan(), handle_show_globals(), iax2_bridge(), iax2_call(), iax2_canmatch(), iax2_do_register(), iax2_exec(), iax2_exists(), iax2_fixup(), iax2_hangup(), iax2_indicate(), iax2_matchmore(), iax2_poke_peer(), iax2_process_thread(), iax2_sched_add(), iax2_setoption(), iax2_show_cache(), iax2_show_channels(), iax2_show_firmware(), iax2_write(), iax_check_version(), iax_firmware_append(), iax_process_template(), iax_prov_complete_template(), iax_provision_build(), iax_provision_reload(), iax_provision_version(), iax_show_provisioning(), iax_template_parse(), increase_call_count(), load_config(), load_module(), load_rpt_vars(), lock_both(), lock_msg_q(), make_trunk(), manager_event(), manager_parking_status(), mfcr2_monitor(), mgcp_answer(), mgcp_audit_endpoint(), mgcp_call(), mgcp_devicestate(), mgcp_fixup(), mgcp_hangup(), mgcp_indicate(), mgcp_postrequest(), mgcp_read(), mgcp_reload(), mgcp_senddigit_begin(), mgcp_senddigit_end(), mgcp_show_endpoints(), mgcp_write(), mgcpsock_read(), misdn_cfg_lock(), misdn_jb_empty(), misdn_jb_fill(), misdn_overlap_dial_task(), mixmonitor_ds_chan_fixup(), mixmonitor_ds_destroy(), mixmonitor_thread(), mwi_monitor_handler(), node_lookup(), notify_extenstate_update(), odbc_load_module(), odbc_log(), odbc_obj_connect(), odbc_obj_disconnect(), odbc_unload_module(), oh323_alloc(), oh323_answer(), oh323_call(), oh323_destroy(), oh323_digit_begin(), oh323_digit_end(), oh323_fixup(), oh323_get_rtp_peer(), oh323_hangup(), oh323_indicate(), oh323_read(), oh323_request(), oh323_simulate_dtmf_end(), oh323_update_info(), oh323_write(), osp_create_provider(), osp_create_transaction(), osp_get_policy(), osp_show(), osp_unload(), p2p_set_bridge(), park_exec(), park_space_reserve(), pbx_builtin_clear_globals(), pbx_builtin_getvar_helper(), pbx_builtin_pushvar_helper(), pbx_builtin_setvar_helper(), pbx_retrieve_variable(), peer_destructor(), pgsql_log(), phone_request(), pri_dchannel(), pri_fixup_principle(), pri_hangup_all(), process_events(), prune_gateways(), queue_ringing_trunk(), realtime_multi_pgsql(), realtime_pgsql(), recordthread(), register_verify(), registry_authrequest(), release_chan(), release_chan_early(), reload(), reload_agents(), reload_config(), reload_firmware(), reload_followme(), restart_monitor(), retrans_pkt(), rpt_master(), rpt_tele_thread(), run_station(), save_to_folder(), sched_context_destroy(), sched_thread(), scheduled_destroy(), scheduler_process_request_queue(), send_command_locked(), send_keypad_facility_exec(), send_provisional_keepalive_full(), send_request(), set_eventmask(), setup_chanspy_ds(), setup_dahdi(), show_keys(), sig_pri_available(), sig_pri_kill_call(), sig_pri_lock_owner(), signal_condition(), sip_alloc(), sip_answer(), sip_destroy(), sip_dtmfmode(), sip_fixup(), sip_get_rtp_peer(), sip_get_udptl_peer(), sip_get_vrtp_peer(), sip_handle_t38_reinvite(), sip_hangup(), sip_indicate(), sip_new(), sip_read(), sip_reg_timeout(), sip_reinvite_retry(), sip_reload(), sip_request_call(), sip_senddigit_begin(), sip_senddigit_end(), sip_set_rtp_peer(), sip_set_udptl_peer(), sip_show_channel(), sip_show_history(), sip_transfer(), sip_write(), sipsock_read(), skinny_hangup(), skinny_read(), skinny_register(), skinny_req_parse(), skinny_reset_device(), skinny_show_devices(), skinny_show_lines(), skinny_write(), sla_destroy(), sla_handle_dial_state_event(), sla_handle_ringing_trunk_event(), sla_hangup_stations(), sla_queue_event_full(), sla_station_exec(), sla_thread(), sla_trunk_exec(), socket_process(), speech_background(), sqlite_log(), ss_thread(), ssl_lock(), start_rtp(), statechange_queue(), stop_mixmonitor_exec(), submit_unscheduled_batch(), tds_log(), timing_read(), transmit_response(), try_load_key(), unload_module(), update_pgsql(), update_registry(), verboser(), vm_execmain(), wakeup_sub(), and writefile().

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

Definition at line 714 of file lock.h.

Referenced by __action_showchannels(), __ao2_unlock(), __ast_context_destroy(), __ast_key_get(), __attempt_transmit(), __auth_reject(), __auto_congest(), __auto_hangup(), __find_callno(), __get_from_jb(), __iax2_poke_noanswer(), __login_exec(), __oh323_destroy(), __oh323_new(), __oh323_rtp_create(), __send_lagrq(), __send_ping(), __sip_autodestruct(), __sip_destroy(), __sip_show_channels(), __unload_module(), accept_thread(), action_agent_callback_login(), action_agents(), action_setcdruserfield(), action_waitevent(), agent_ack_sleep(), agent_call(), agent_cleanup(), agent_cont_sleep(), agent_devicestate(), agent_devicestate_cb(), agent_digit_begin(), agent_digit_end(), agent_fixup(), agent_hangup(), agent_indicate(), agent_logoff(), agent_read(), agent_request(), agent_sendhtml(), agent_sendtext(), agent_write(), agents_show(), agents_show_online(), alsa_answer(), alsa_call(), alsa_digit(), alsa_fixup(), alsa_hangup(), alsa_indicate(), alsa_read(), alsa_request(), alsa_text(), alsa_write(), announce_thread(), answer_call(), answer_exec_run(), ao2_unlock(), app_exec(), append_mailbox_mapping(), ast_add_extension2(), ast_atomic_fetchadd_int_slow(), ast_cdr_detach(), ast_cdr_engine_init(), ast_cdr_submit_batch(), ast_cli_netstats(), ast_config_engine_deregister(), ast_config_engine_register(), ast_context_add_ignorepat2(), ast_context_add_include2(), ast_context_add_switch2(), ast_context_remove_extension_callerid2(), ast_context_remove_ignorepat2(), ast_context_remove_include2(), ast_context_remove_switch2(), 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_enum_init(), ast_get_enum(), ast_get_indication_tone(), ast_get_indication_zone(), ast_get_txt(), ast_iax2_new(), ast_module_reload(), ast_monitor_start(), ast_odbc_smart_execute(), ast_random(), ast_register_indication(), ast_register_indication_country(), ast_replace_sigchld(), ast_rtp_get_bridged(), ast_rtp_get_current_formats(), ast_rtp_lookup_code(), ast_rtp_lookup_pt(), ast_rtp_pt_clear(), ast_rtp_pt_copy(), ast_rtp_pt_default(), ast_rtp_set_m_type(), ast_rtp_set_rtpmap_type(), ast_rtp_unset_m_type(), ast_sched_add_variable(), ast_sched_del(), ast_sched_runq(), 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_unlock_context(), ast_unlock_contexts(), ast_unregister_indication(), ast_unregister_indication_country(), ast_unreplace_sigchld(), ast_walk_indications(), astman_append(), astman_verify_session_readpermissions(), astman_verify_session_writepermissions(), asyncgoto_exec(), attempt_transfer(), auth_reject(), authenticate_reply(), auto_congest(), auto_hangup(), cache_get_callno_locked(), cb_events(), chan_ringing(), channel_spy(), chanspy_ds_chan_fixup(), chanspy_ds_destroy(), chanspy_ds_free(), check_availability(), check_beep(), check_bridge(), cl_dequeue_chan(), cl_queue_chan(), cleanup_connection(), clear_config_maps(), common_exec(), complete_ch_helper(), complete_dpreply(), complete_sipch(), conf_exec(), conf_free(), conf_run(), config_command(), config_pgsql(), connection_made(), console_answer(), console_answer_deprecated(), console_autoanswer(), console_autoanswer_deprecated(), console_dial(), console_dial_deprecated(), console_hangup(), console_hangup_deprecated(), console_sendtext(), console_sendtext_deprecated(), crypto_load(), csv_log(), custom_log(), dahdi_accept_r2_call_exec(), dahdi_answer(), dahdi_bridge(), dahdi_call(), dahdi_destroy_channel_bynum(), dahdi_digit_begin(), dahdi_digit_end(), dahdi_exception(), dahdi_fixup(), dahdi_func_read(), dahdi_handle_dtmf(), dahdi_handle_event(), dahdi_hangup(), dahdi_indicate(), dahdi_pri_error(), dahdi_pri_message(), dahdi_queue_frame(), 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_restart(), dahdi_show_channel(), dahdi_show_channels(), dahdi_softhangup_all(), dahdi_unlink(), database_show(), database_showkey(), decrease_call_count(), defer_full_frame(), delete_devices(), delete_users(), destroy_all_channels(), destroy_all_mailbox_mappings(), destroy_endpoint(), destroy_monitor_audiohook(), destroy_session(), device_state_thread(), dial_trunk(), dnsmgr_refresh(), do_cdr(), do_monitor(), do_parking_thread(), do_reload(), donodelog(), dp_lookup(), dump_cmd_queues(), dump_queue(), external_rtp_create(), features_answer(), features_call(), features_digit_begin(), features_digit_end(), features_fixup(), features_hangup(), features_indicate(), features_read(), features_show(), features_write(), find_cache(), find_call(), find_call_locked(), find_command(), find_engine(), find_line_by_name(), find_session(), find_subchannel_and_lock(), find_tpeer(), function_remote(), generic_http_callback(), get_input(), get_sip_pvt_byid_locked(), gethostbyname_r(), gtalk_alloc(), gtalk_answer(), gtalk_digit(), gtalk_fixup(), gtalk_get_rtp_peer(), gtalk_hangup(), gtalk_newcall(), gtalk_read(), gtalk_set_rtp_peer(), gtalk_show_channels(), gtalk_write(), h323_reload(), handle_capabilities_res_message(), handle_deferred_full_frames(), handle_invite_replaces(), handle_line_state_req_message(), handle_mfcr2_call_files(), handle_mfcr2_set_blocked(), handle_mfcr2_set_debug(), handle_mfcr2_set_idle(), handle_mfcr2_show_channels(), handle_modlist(), handle_parkedcalls(), handle_pri_set_debug_file(), handle_pri_show_debug(), handle_pri_show_span(), handle_request(), handle_request_invite(), handle_response_invite(), handle_save_dialplan(), handle_show_globals(), hangup_connection(), iax2_bridge(), iax2_call(), iax2_canmatch(), iax2_destroy(), iax2_do_register(), iax2_exec(), iax2_exists(), iax2_fixup(), iax2_hangup(), iax2_indicate(), iax2_matchmore(), iax2_poke_peer(), iax2_process_thread(), iax2_provision(), iax2_queue_control_data(), iax2_queue_frame(), iax2_queue_hangup(), iax2_request(), iax2_sched_add(), iax2_setoption(), iax2_show_cache(), iax2_show_channels(), iax2_show_firmware(), iax2_trunk_queue(), iax2_write(), iax_check_version(), iax_firmware_append(), iax_process_template(), iax_prov_complete_template(), iax_provision_build(), iax_provision_reload(), iax_provision_version(), iax_show_provisioning(), iax_template_parse(), increase_call_count(), load_config(), load_module(), load_rpt_vars(), local_attended_transfer(), make_trunk(), manager_event(), manager_parking_status(), manager_play_dtmf(), mfcr2_monitor(), mgcp_answer(), mgcp_audit_endpoint(), mgcp_call(), mgcp_devicestate(), mgcp_fixup(), mgcp_hangup(), mgcp_indicate(), mgcp_postrequest(), mgcp_queue_frame(), mgcp_queue_hangup(), mgcp_read(), mgcp_reload(), mgcp_request(), mgcp_senddigit_begin(), mgcp_senddigit_end(), mgcp_show_endpoints(), mgcp_write(), mgcpsock_read(), misdn_cfg_unlock(), misdn_jb_empty(), misdn_jb_fill(), misdn_overlap_dial_task(), mixmonitor_ds_chan_fixup(), mixmonitor_ds_destroy(), mixmonitor_thread(), mwi_monitor_handler(), network_thread(), node_lookup(), notify_extenstate_update(), odbc_load_module(), odbc_log(), odbc_obj_connect(), odbc_obj_disconnect(), odbc_unload_module(), oh323_alloc(), oh323_answer(), oh323_call(), oh323_destroy(), oh323_digit_begin(), oh323_digit_end(), oh323_fixup(), oh323_get_rtp_peer(), oh323_hangup(), oh323_indicate(), oh323_read(), oh323_request(), oh323_simulate_dtmf_end(), oh323_update_info(), oh323_write(), osp_create_provider(), osp_create_transaction(), osp_get_policy(), osp_show(), osp_unload(), p2p_set_bridge(), park_exec(), park_space_reserve(), pbx_builtin_clear_globals(), pbx_builtin_getvar_helper(), pbx_builtin_pushvar_helper(), pbx_builtin_setvar_helper(), pbx_retrieve_variable(), peer_destructor(), pgsql_log(), phone_request(), pri_dchannel(), pri_fixup_principle(), pri_hangup_all(), pri_rel(), process_events(), progress(), prune_gateways(), queue_ringing_trunk(), realtime_multi_pgsql(), realtime_pgsql(), receive_digit(), recordthread(), refresh_list(), register_verify(), registry_authrequest(), release_chan(), release_chan_early(), reload(), reload_agents(), reload_config(), reload_firmware(), reload_followme(), restart_monitor(), retrans_pkt(), rpt_master(), rpt_tele_thread(), run_station(), save_to_folder(), sched_context_destroy(), sched_thread(), schedule_delivery(), scheduled_destroy(), scheduler_process_request_queue(), send_command_locked(), send_keypad_facility_exec(), send_provisional_keepalive_full(), send_request(), set_dtmf_payload(), set_eventmask(), set_local_capabilities(), set_peer_capabilities(), setup_chanspy_ds(), setup_dahdi(), setup_rtp_connection(), show_keys(), sig_pri_available(), sig_pri_kill_call(), sig_pri_lock_owner(), signal_condition(), sip_alloc(), sip_answer(), sip_destroy(), sip_dtmfmode(), sip_fixup(), sip_get_rtp_peer(), sip_get_udptl_peer(), sip_get_vrtp_peer(), sip_handle_t38_reinvite(), sip_hangup(), sip_indicate(), sip_new(), sip_read(), sip_reg_timeout(), sip_reinvite_retry(), sip_reload(), sip_request_call(), sip_senddigit_begin(), sip_senddigit_end(), sip_set_rtp_peer(), sip_set_udptl_peer(), sip_show_channel(), sip_show_history(), sip_transfer(), sip_write(), sipsock_read(), skinny_hangup(), skinny_read(), skinny_register(), skinny_req_parse(), skinny_reset_device(), skinny_show_devices(), skinny_show_lines(), skinny_write(), sla_destroy(), sla_handle_dial_state_event(), sla_handle_ringing_trunk_event(), sla_hangup_stations(), sla_queue_event_full(), sla_station_exec(), sla_thread(), sla_trunk_exec(), socket_process(), softhangup_exec(), speech_background(), sqlite_log(), ss_thread(), ssl_lock(), start_rtp(), statechange_queue(), stop_mixmonitor_exec(), submit_unscheduled_batch(), tds_log(), timing_read(), transmit_response(), try_load_key(), unload_module(), unlock_both(), unlock_msg_q(), update_pgsql(), update_registry(), verboser(), vm_execmain(), wakeup_sub(), and writefile().

#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)

Definition at line 1288 of file lock.h.

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

Definition at line 898 of file lock.h.

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

Definition at line 871 of file lock.h.

#define AST_RWLOCK_INIT_VALUE   PTHREAD_RWLOCK_INITIALIZER
#define ast_rwlock_rdlock (  )     _ast_rwlock_rdlock(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ast_rwlock_timedrdlock ( a,
 )     _ast_rwlock_timedrdlock(a, # a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Definition at line 1013 of file lock.h.

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

Definition at line 1062 of file lock.h.

Referenced by ast_manager_register_struct(), and ast_manager_unregister().

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

Definition at line 1111 of file lock.h.

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

Definition at line 1144 of file lock.h.

#define ast_rwlock_unlock (  )     _ast_rwlock_unlock(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ast_rwlock_wrlock (  )     _ast_rwlock_wrlock(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Definition at line 980 of file lock.h.

Referenced by ast_http_uri_link(), ast_http_uri_unlink(), remap_feature(), and unmap_features().

#define DEADLOCK_AVOIDANCE ( lock   ) 
#define DO_THREAD_CRASH   do { } while (0)
#define gethostbyname   __gethostbyname__is__not__reentrant__use__ast_gethostbyname__instead__

Definition at line 855 of file lock.h.

Referenced by connect_sphinx(), and gethostbyname_r().

#define pthread_cond_broadcast   use_ast_cond_broadcast_instead_of_pthread_cond_broadcast

Definition at line 846 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 844 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 843 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 845 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 842 of file lock.h.

#define pthread_cond_timedwait   use_ast_cond_timedwait_instead_of_pthread_cond_timedwait

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

Referenced by __ast_cond_wait().

#define pthread_create   __use_ast_pthread_create_instead__

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

Referenced by __ast_pthread_mutex_destroy(), delete_reentrancy_cs(), and stack_destroy().

#define pthread_mutex_init   use_ast_mutex_init_instead_of_pthread_mutex_init
#define PTHREAD_MUTEX_INIT_VALUE   PTHREAD_MUTEX_INITIALIZER

Definition at line 92 of file lock.h.

#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   ((t->reentrancy > 0) ? (t->reentrancy-1) : 0)

Typedef Documentation

typedef pthread_cond_t ast_cond_t

Definition at line 130 of file lock.h.

typedef struct ast_mutex_info ast_mutex_t

Definition at line 128 of file lock.h.

typedef pthread_rwlock_t ast_rwlock_t

Definition at line 861 of file lock.h.


Enumeration Type Documentation

Enumerator:
AST_MUTEX 
AST_RDLOCK 
AST_WRLOCK 

Definition at line 134 of file lock.h.

00134                    {
00135    AST_MUTEX,
00136    AST_RDLOCK,
00137    AST_WRLOCK,
00138 };


Function Documentation

static int __ast_cond_broadcast ( const char *  filename,
int  lineno,
const char *  func,
const char *  cond_name,
ast_cond_t cond 
) [inline, static]

Definition at line 558 of file lock.h.

References pthread_cond_broadcast.

00560 {
00561    return pthread_cond_broadcast(cond);
00562 }

static int __ast_cond_destroy ( const char *  filename,
int  lineno,
const char *  func,
const char *  cond_name,
ast_cond_t cond 
) [inline, static]

Definition at line 564 of file lock.h.

References pthread_cond_destroy.

00566 {
00567    return pthread_cond_destroy(cond);
00568 }

static 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 
) [inline, static]

Definition at line 546 of file lock.h.

References pthread_cond_init.

00548 {
00549    return pthread_cond_init(cond, cond_attr);
00550 }

static int __ast_cond_signal ( const char *  filename,
int  lineno,
const char *  func,
const char *  cond_name,
ast_cond_t cond 
) [inline, static]

Definition at line 552 of file lock.h.

References pthread_cond_signal.

00554 {
00555    return pthread_cond_signal(cond);
00556 }

static 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 
) [inline, static]

Definition at line 641 of file lock.h.

References __ast_mutex_logger, __ast_pthread_mutex_init(), AST_MAX_REENTRANCY, AST_MUTEX, ast_reentrancy_lock(), ast_reentrancy_unlock(), ast_remove_lock_info(), ast_store_lock_info(), DO_THREAD_CRASH, ast_mutex_info::file, ast_mutex_info::func, ast_mutex_info::lineno, ast_mutex_info::mutex, pthread_cond_timedwait, pthread_mutex_t, ast_mutex_info::reentrancy, ROFFSET, ast_mutex_info::thread, and ast_mutex_info::track.

00644 {
00645    int res;
00646    int canlog = strcmp(filename, "logger.c") & t->track;
00647 
00648 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00649    if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00650       __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
00651                filename, lineno, func, mutex_name);
00652       res = __ast_pthread_mutex_init(t->track, filename, lineno, func, mutex_name, t);
00653       if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00654          __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n",
00655                 filename, lineno, func, mutex_name);
00656       }
00657       return res;
00658    }
00659 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00660 
00661    ast_reentrancy_lock(t);
00662    if (t->reentrancy && (t->thread[ROFFSET] != pthread_self())) {
00663       __ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n",
00664                filename, lineno, func, mutex_name);
00665       __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n",
00666                t->file[ROFFSET], t->lineno[ROFFSET], t->func[ROFFSET], mutex_name);
00667       DO_THREAD_CRASH;
00668    }
00669 
00670    if (--t->reentrancy < 0) {
00671       __ast_mutex_logger("%s line %d (%s): mutex '%s' freed more times than we've locked!\n",
00672                filename, lineno, func, mutex_name);
00673       t->reentrancy = 0;
00674    }
00675 
00676    if (t->reentrancy < AST_MAX_REENTRANCY) {
00677       t->file[t->reentrancy] = NULL;
00678       t->lineno[t->reentrancy] = 0;
00679       t->func[t->reentrancy] = NULL;
00680       t->thread[t->reentrancy] = 0;
00681    }
00682    ast_reentrancy_unlock(t);
00683 
00684    if (t->track)
00685       ast_remove_lock_info(&t->mutex);
00686 
00687    if ((res = pthread_cond_timedwait(cond, &t->mutex, abstime)) && (res != ETIMEDOUT)) {
00688       __ast_mutex_logger("%s line %d (%s): Error waiting on condition mutex '%s'\n", 
00689                filename, lineno, func, strerror(res));
00690       DO_THREAD_CRASH;
00691    } else {
00692       ast_reentrancy_lock(t);
00693       if (t->reentrancy < AST_MAX_REENTRANCY) {
00694          t->file[t->reentrancy] = filename;
00695          t->lineno[t->reentrancy] = lineno;
00696          t->func[t->reentrancy] = func;
00697          t->thread[t->reentrancy] = pthread_self();
00698          t->reentrancy++;
00699       } else {
00700          __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n",
00701                         filename, lineno, func, mutex_name);
00702       }
00703       ast_reentrancy_unlock(t);
00704 
00705       if (t->track)
00706          ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex);
00707    }
00708 
00709    return res;
00710 }

static 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 
) [inline, static]

Definition at line 570 of file lock.h.

References __ast_mutex_logger, __ast_pthread_mutex_init(), AST_MAX_REENTRANCY, AST_MUTEX, ast_reentrancy_lock(), ast_reentrancy_unlock(), ast_remove_lock_info(), ast_store_lock_info(), DO_THREAD_CRASH, ast_mutex_info::file, ast_mutex_info::func, ast_mutex_info::lineno, ast_mutex_info::mutex, pthread_cond_wait, pthread_mutex_t, ast_mutex_info::reentrancy, ROFFSET, ast_mutex_info::thread, and ast_mutex_info::track.

00573 {
00574    int res;
00575    int canlog = strcmp(filename, "logger.c") & t->track;
00576 
00577 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00578    if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00579       __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
00580                filename, lineno, func, mutex_name);
00581       res = __ast_pthread_mutex_init(t->track, filename, lineno, func, mutex_name, t);
00582       if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00583          __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n",
00584                 filename, lineno, func, mutex_name);
00585       }
00586       return res;
00587    }
00588 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00589 
00590    ast_reentrancy_lock(t);
00591    if (t->reentrancy && (t->thread[ROFFSET] != pthread_self())) {
00592       __ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n",
00593                filename, lineno, func, mutex_name);
00594       __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n",
00595                t->file[ROFFSET], t->lineno[ROFFSET], t->func[ROFFSET], mutex_name);
00596       DO_THREAD_CRASH;
00597    }
00598 
00599    if (--t->reentrancy < 0) {
00600       __ast_mutex_logger("%s line %d (%s): mutex '%s' freed more times than we've locked!\n",
00601                filename, lineno, func, mutex_name);
00602       t->reentrancy = 0;
00603    }
00604 
00605    if (t->reentrancy < AST_MAX_REENTRANCY) {
00606       t->file[t->reentrancy] = NULL;
00607       t->lineno[t->reentrancy] = 0;
00608       t->func[t->reentrancy] = NULL;
00609       t->thread[t->reentrancy] = 0;
00610    }
00611    ast_reentrancy_unlock(t);
00612 
00613    if (t->track)
00614       ast_remove_lock_info(&t->mutex);
00615 
00616    if ((res = pthread_cond_wait(cond, &t->mutex))) {
00617       __ast_mutex_logger("%s line %d (%s): Error waiting on condition mutex '%s'\n", 
00618                filename, lineno, func, strerror(res));
00619       DO_THREAD_CRASH;
00620    } else {
00621       ast_reentrancy_lock(t);
00622       if (t->reentrancy < AST_MAX_REENTRANCY) {
00623          t->file[t->reentrancy] = filename;
00624          t->lineno[t->reentrancy] = lineno;
00625          t->func[t->reentrancy] = func;
00626          t->thread[t->reentrancy] = pthread_self();
00627          t->reentrancy++;
00628       } else {
00629          __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n",
00630                         filename, lineno, func, mutex_name);
00631       }
00632       ast_reentrancy_unlock(t);
00633 
00634       if (t->track)
00635          ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex);
00636    }
00637 
00638    return res;
00639 }

static int __ast_pthread_mutex_destroy ( const char *  filename,
int  lineno,
const char *  func,
const char *  mutex_name,
ast_mutex_t t 
) [inline, static]

Definition at line 302 of file lock.h.

References __ast_mutex_logger, ast_reentrancy_lock(), ast_reentrancy_unlock(), delete_reentrancy_cs(), ast_mutex_info::file, ast_mutex_info::func, ast_mutex_info::lineno, ast_mutex_info::mutex, pthread_mutex_destroy, pthread_mutex_t, pthread_mutex_trylock, pthread_mutex_unlock, ast_mutex_info::reentrancy, ROFFSET, ast_mutex_info::thread, and ast_mutex_info::track.

00304 {
00305    int res;
00306    int canlog = strcmp(filename, "logger.c") & t->track;
00307 
00308 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00309    if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00310       /* Don't try to uninitialize non initialized mutex
00311        * This may no effect on linux
00312        * And always ganerate core on *BSD with 
00313        * linked libpthread
00314        * This not error condition if the mutex created on the fly.
00315        */
00316       __ast_mutex_logger("%s line %d (%s): NOTICE: mutex '%s' is uninitialized.\n",
00317                filename, lineno, func, mutex_name);
00318       return 0;
00319    }
00320 #endif
00321 
00322    res = pthread_mutex_trylock(&t->mutex);
00323    switch (res) {
00324    case 0:
00325       pthread_mutex_unlock(&t->mutex);
00326       break;
00327    case EINVAL:
00328       __ast_mutex_logger("%s line %d (%s): Error: attempt to destroy invalid mutex '%s'.\n",
00329               filename, lineno, func, mutex_name);
00330       break;
00331    case EBUSY:
00332       __ast_mutex_logger("%s line %d (%s): Error: attempt to destroy locked mutex '%s'.\n",
00333                filename, lineno, func, mutex_name);
00334       ast_reentrancy_lock(t);
00335       __ast_mutex_logger("%s line %d (%s): Error: '%s' was locked here.\n",
00336              t->file[ROFFSET], t->lineno[ROFFSET], t->func[ROFFSET], mutex_name);
00337       ast_reentrancy_unlock(t);
00338       break;
00339    }
00340 
00341    if ((res = pthread_mutex_destroy(&t->mutex)))
00342       __ast_mutex_logger("%s line %d (%s): Error destroying mutex %s: %s\n",
00343                filename, lineno, func, mutex_name, strerror(res));
00344    ast_reentrancy_lock(t);
00345    t->file[0] = filename;
00346    t->lineno[0] = lineno;
00347    t->func[0] = func;
00348    t->reentrancy = 0;
00349    t->thread[0] = 0;
00350    ast_reentrancy_unlock(t);
00351    delete_reentrancy_cs(t);
00352 
00353    return res;
00354 }

static int __ast_pthread_mutex_init ( int  track,
const char *  filename,
int  lineno,
const char *  func,
const char *  mutex_name,
ast_mutex_t t 
) [inline, static]

Definition at line 266 of file lock.h.

References AST_MUTEX_KIND, ast_reentrancy_init(), ast_mutex_info::mutex, pthread_mutex_init, pthread_mutex_t, and ast_mutex_info::track.

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

00268 {
00269    int res;
00270    pthread_mutexattr_t  attr;
00271 
00272 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00273 
00274    if ((t->mutex) != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00275 /*
00276       int canlog = strcmp(filename, "logger.c") & track;
00277       __ast_mutex_logger("%s line %d (%s): NOTICE: mutex '%s' is already initialized.\n",
00278                filename, lineno, func, mutex_name);
00279       DO_THREAD_CRASH;
00280 */
00281       return 0;
00282    }
00283 
00284 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00285 
00286    ast_reentrancy_init(t);
00287    t->track = track;
00288 
00289    pthread_mutexattr_init(&attr);
00290    pthread_mutexattr_settype(&attr, AST_MUTEX_KIND);
00291 
00292    res = pthread_mutex_init(&t->mutex, &attr);
00293    pthread_mutexattr_destroy(&attr);
00294    return res;
00295 }

static int __ast_pthread_mutex_lock ( const char *  filename,
int  lineno,
const char *  func,
const char *  mutex_name,
ast_mutex_t t 
) [inline, static]

Definition at line 356 of file lock.h.

References __ast_mutex_logger, __ast_pthread_mutex_init(), ast_mark(), ast_mark_lock_acquired(), AST_MAX_REENTRANCY, AST_MUTEX, ast_reentrancy_lock(), ast_reentrancy_unlock(), ast_remove_lock_info(), ast_store_lock_info(), DO_THREAD_CRASH, ast_mutex_info::file, ast_mutex_info::func, ast_mutex_info::lineno, ast_mutex_info::mutex, pthread_mutex_lock, pthread_mutex_t, pthread_mutex_trylock, ast_mutex_info::reentrancy, ROFFSET, ast_mutex_info::thread, and ast_mutex_info::track.

Referenced by __ao2_lock().

00358 {
00359    int res;
00360    int canlog = strcmp(filename, "logger.c") & t->track;
00361 
00362 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00363    if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00364       /* Don't warn abount uninitialized mutex.
00365        * Simple try to initialize it.
00366        * May be not needed in linux system.
00367        */
00368       res = __ast_pthread_mutex_init(t->track, filename, lineno, func, mutex_name, t);
00369       if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00370          __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n",
00371                 filename, lineno, func, mutex_name);
00372          return res;
00373       }     
00374    }
00375 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00376 
00377    if (t->track)
00378       ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex);
00379 
00380 #ifdef DETECT_DEADLOCKS
00381    {
00382       time_t seconds = time(NULL);
00383       time_t wait_time, reported_wait = 0;
00384       do {
00385 #ifdef   HAVE_MTX_PROFILE
00386          ast_mark(mtx_prof, 1);
00387 #endif
00388          res = pthread_mutex_trylock(&t->mutex);
00389 #ifdef   HAVE_MTX_PROFILE
00390          ast_mark(mtx_prof, 0);
00391 #endif
00392          if (res == EBUSY) {
00393             wait_time = time(NULL) - seconds;
00394             if (wait_time > reported_wait && (wait_time % 5) == 0) {
00395                __ast_mutex_logger("%s line %d (%s): Deadlock? waited %d sec for mutex '%s'?\n",
00396                         filename, lineno, func, (int) wait_time, mutex_name);
00397                ast_reentrancy_lock(t);
00398                __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n",
00399                         t->file[ROFFSET], t->lineno[ROFFSET],
00400                         t->func[ROFFSET], mutex_name);
00401                ast_reentrancy_unlock(t);
00402                reported_wait = wait_time;
00403             }
00404             usleep(200);
00405          }
00406       } while (res == EBUSY);
00407    }
00408 #else
00409 #ifdef   HAVE_MTX_PROFILE
00410    ast_mark(mtx_prof, 1);
00411    res = pthread_mutex_trylock(&t->mutex);
00412    ast_mark(mtx_prof, 0);
00413    if (res)
00414 #endif
00415    res = pthread_mutex_lock(&t->mutex);
00416 #endif /* DETECT_DEADLOCKS */
00417 
00418    if (!res) {
00419       ast_reentrancy_lock(t);
00420       if (t->reentrancy < AST_MAX_REENTRANCY) {
00421          t->file[t->reentrancy] = filename;
00422          t->lineno[t->reentrancy] = lineno;
00423          t->func[t->reentrancy] = func;
00424          t->thread[t->reentrancy] = pthread_self();
00425          t->reentrancy++;
00426       } else {
00427          __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n",
00428                         filename, lineno, func, mutex_name);
00429       }
00430       ast_reentrancy_unlock(t);
00431       if (t->track)
00432          ast_mark_lock_acquired(&t->mutex);
00433    } else {
00434       if (t->track)
00435          ast_remove_lock_info(&t->mutex);
00436       __ast_mutex_logger("%s line %d (%s): Error obtaining mutex: %s\n",
00437                filename, lineno, func, strerror(res));
00438       DO_THREAD_CRASH;
00439    }
00440 
00441    return res;
00442 }

static int __ast_pthread_mutex_trylock ( const char *  filename,
int  lineno,
const char *  func,
const char *  mutex_name,
ast_mutex_t t 
) [inline, static]

Definition at line 446 of file lock.h.

References __ast_mutex_logger, __ast_pthread_mutex_init(), ast_mark_lock_acquired(), ast_mark_lock_failed(), AST_MAX_REENTRANCY, AST_MUTEX, ast_reentrancy_lock(), ast_reentrancy_unlock(), ast_store_lock_info(), ast_mutex_info::file, ast_mutex_info::func, ast_mutex_info::lineno, ast_mutex_info::mutex, pthread_mutex_t, pthread_mutex_trylock, ast_mutex_info::reentrancy, ast_mutex_info::thread, and ast_mutex_info::track.

Referenced by __ao2_trylock().

00448 {
00449    int res;
00450    int canlog = strcmp(filename, "logger.c") & t->track;
00451 
00452 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00453    if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00454       /* Don't warn abount uninitialized mutex.
00455        * Simple try to initialize it.
00456        * May be not needed in linux system.
00457        */
00458       res = __ast_pthread_mutex_init(t->track, filename, lineno, func, mutex_name, t);
00459       if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00460          __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n",
00461                 filename, lineno, func, mutex_name);
00462          return res;
00463       }     
00464    }
00465 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00466 
00467    if (t->track)
00468       ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex);
00469 
00470    if (!(res = pthread_mutex_trylock(&t->mutex))) {
00471       ast_reentrancy_lock(t);
00472       if (t->reentrancy < AST_MAX_REENTRANCY) {
00473          t->file[t->reentrancy] = filename;
00474          t->lineno[t->reentrancy] = lineno;
00475          t->func[t->reentrancy] = func;
00476          t->thread[t->reentrancy] = pthread_self();
00477          t->reentrancy++;
00478       } else {
00479          __ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n",
00480                   filename, lineno, func, mutex_name);
00481       }
00482       ast_reentrancy_unlock(t);
00483       if (t->track)
00484          ast_mark_lock_acquired(&t->mutex);
00485    } else if (t->track) {
00486       ast_mark_lock_failed(&t->mutex);
00487    }
00488 
00489    return res;
00490 }

static int __ast_pthread_mutex_unlock ( const char *  filename,
int  lineno,
const char *  func,
const char *  mutex_name,
ast_mutex_t t 
) [inline, static]

Definition at line 492 of file lock.h.

References __ast_mutex_logger, __ast_pthread_mutex_init(), AST_MAX_REENTRANCY, ast_reentrancy_lock(), ast_reentrancy_unlock(), ast_remove_lock_info(), DO_THREAD_CRASH, ast_mutex_info::file, ast_mutex_info::func, ast_mutex_info::lineno, ast_mutex_info::mutex, pthread_mutex_t, pthread_mutex_unlock, ast_mutex_info::reentrancy, ROFFSET, ast_mutex_info::thread, and ast_mutex_info::track.

Referenced by __ao2_unlock().

00494 {
00495    int res;
00496    int canlog = strcmp(filename, "logger.c") & t->track;
00497 
00498 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00499    if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00500       __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
00501                filename, lineno, func, mutex_name);
00502       res = __ast_pthread_mutex_init(t->track, filename, lineno, func, mutex_name, t);
00503       if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00504          __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n",
00505                 filename, lineno, func, mutex_name);
00506       }
00507       return res;
00508    }
00509 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00510 
00511    ast_reentrancy_lock(t);
00512    if (t->reentrancy && (t->thread[ROFFSET] != pthread_self())) {
00513       __ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n",
00514                filename, lineno, func, mutex_name);
00515       __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n",
00516                t->file[ROFFSET], t->lineno[ROFFSET], t->func[ROFFSET], mutex_name);
00517       DO_THREAD_CRASH;
00518    }
00519 
00520    if (--t->reentrancy < 0) {
00521       __ast_mutex_logger("%s line %d (%s): mutex '%s' freed more times than we've locked!\n",
00522                filename, lineno, func, mutex_name);
00523       t->reentrancy = 0;
00524    }
00525 
00526    if (t->reentrancy < AST_MAX_REENTRANCY) {
00527       t->file[t->reentrancy] = NULL;
00528       t->lineno[t->reentrancy] = 0;
00529       t->func[t->reentrancy] = NULL;
00530       t->thread[t->reentrancy] = 0;
00531    }
00532    ast_reentrancy_unlock(t);
00533 
00534    if (t->track)
00535       ast_remove_lock_info(&t->mutex);
00536 
00537    if ((res = pthread_mutex_unlock(&t->mutex))) {
00538       __ast_mutex_logger("%s line %d (%s): Error releasing mutex: %s\n", 
00539                filename, lineno, func, strerror(res));
00540       DO_THREAD_CRASH;
00541    }
00542 
00543    return res;
00544 }

static int __ast_rwlock_destroy ( const char *  filename,
int  lineno,
const char *  func,
const char *  rwlock_name,
ast_rwlock_t prwlock 
) [inline, static]

Definition at line 900 of file lock.h.

References __ast_mutex_logger, and AST_RWLOCK_INIT_VALUE.

00901 {
00902    int res;
00903    int canlog = strcmp(filename, "logger.c");
00904 
00905 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00906    if (*prwlock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
00907       __ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is uninitialized.\n",
00908                filename, lineno, func, rwlock_name);
00909       return 0;
00910    }
00911 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00912    
00913    if ((res = pthread_rwlock_destroy(prwlock)))
00914       __ast_mutex_logger("%s line %d (%s): Error destroying rwlock %s: %s\n",
00915             filename, lineno, func, rwlock_name, strerror(res));
00916 
00917    return res;
00918 }

static int __ast_rwlock_init ( const char *  filename,
int  lineno,
const char *  func,
const char *  rwlock_name,
ast_rwlock_t prwlock 
) [inline, static]

Definition at line 874 of file lock.h.

References __ast_mutex_logger, and AST_RWLOCK_INIT_VALUE.

Referenced by _ast_rwlock_rdlock(), _ast_rwlock_timedrdlock(), _ast_rwlock_timedwrlock(), _ast_rwlock_tryrdlock(), _ast_rwlock_trywrlock(), _ast_rwlock_unlock(), and _ast_rwlock_wrlock().

00875 {
00876    int res;
00877    pthread_rwlockattr_t attr;
00878 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00879         int canlog = strcmp(filename, "logger.c");
00880 
00881         if (*prwlock != ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
00882       __ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is already initialized.\n",
00883             filename, lineno, func, rwlock_name);
00884       return 0;
00885    }
00886 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00887    pthread_rwlockattr_init(&attr);
00888 
00889 #ifdef HAVE_PTHREAD_RWLOCK_PREFER_WRITER_NP
00890    pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NP);
00891 #endif
00892 
00893    res = pthread_rwlock_init(prwlock, &attr);
00894    pthread_rwlockattr_destroy(&attr);
00895    return res;
00896 }

static int _ast_rwlock_rdlock ( ast_rwlock_t lock,
const char *  name,
const char *  file,
int  line,
const char *  func 
) [inline, static]

Definition at line 950 of file lock.h.

References __ast_mutex_logger, __ast_rwlock_init(), ast_mark_lock_acquired(), AST_RDLOCK, ast_remove_lock_info(), AST_RWLOCK_INIT_VALUE, and ast_store_lock_info().

00952 {
00953    int res;
00954 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00955    int canlog = strcmp(file, "logger.c");
00956    
00957    if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
00958        /* Don't warn abount uninitialized lock.
00959         * Simple try to initialize it.
00960         * May be not needed in linux system.
00961         */
00962       res = __ast_rwlock_init(file, line, func, name, lock);
00963       if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
00964          __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n",
00965                file, line, func, name);
00966          return res;
00967       }
00968    }
00969 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00970    
00971    ast_store_lock_info(AST_RDLOCK, file, line, func, name, lock);
00972    res = pthread_rwlock_rdlock(lock);
00973    if (!res)
00974       ast_mark_lock_acquired(lock);
00975    else
00976       ast_remove_lock_info(lock);
00977    return res;
00978 }

static int _ast_rwlock_timedrdlock ( ast_rwlock_t lock,
const char *  name,
const struct timespec *  abs_timeout,
const char *  file,
int  line,
const char *  func 
) [inline, static]

Definition at line 1016 of file lock.h.

References __ast_mutex_logger, __ast_rwlock_init(), ast_mark_lock_acquired(), AST_RDLOCK, ast_remove_lock_info(), AST_RWLOCK_INIT_VALUE, ast_store_lock_info(), ast_tvnow(), and ast_tvsub().

01018 {
01019    int res;
01020 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
01021    int canlog = strcmp(file, "logger.c");
01022    
01023    if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
01024        /* Don't warn abount uninitialized lock.
01025         * Simple try to initialize it.
01026         * May be not needed in linux system.
01027         */
01028       res = __ast_rwlock_init(file, line, func, name, lock);
01029       if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
01030          __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n",
01031                file, line, func, name);
01032          return res;
01033       }
01034    }
01035 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
01036    
01037    ast_store_lock_info(AST_RDLOCK, file, line, func, name, lock);
01038 #ifdef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK
01039    res = pthread_rwlock_timedrdlock(lock, abs_timeout);
01040 #else
01041    do {
01042       struct timeval _start = ast_tvnow(), _diff;
01043       for (;;) {
01044          if (!(res = pthread_rwlock_tryrdlock(lock))) {
01045             break;
01046          }
01047          _diff = ast_tvsub(ast_tvnow(), _start);
01048          if (_diff.tv_sec > abs_timeout->tv_sec || (_diff.tv_sec == abs_timeout->tv_sec && _diff.tv_usec * 1000 > abs_timeout->tv_nsec)) {
01049             break;
01050          }
01051          usleep(1);
01052       }
01053    } while (0);
01054 #endif
01055    if (!res)
01056       ast_mark_lock_acquired(lock);
01057    else
01058       ast_remove_lock_info(lock);
01059    return res;
01060 }

static int _ast_rwlock_timedwrlock ( ast_rwlock_t lock,
const char *  name,
const struct timespec *  abs_timeout,
const char *  file,
int  line,
const char *  func 
) [inline, static]

Definition at line 1065 of file lock.h.

References __ast_mutex_logger, __ast_rwlock_init(), ast_mark_lock_acquired(), ast_remove_lock_info(), AST_RWLOCK_INIT_VALUE, ast_store_lock_info(), ast_tvnow(), ast_tvsub(), and AST_WRLOCK.

01067 {
01068    int res;
01069 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
01070    int canlog = strcmp(file, "logger.c");
01071    
01072    if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
01073        /* Don't warn abount uninitialized lock.
01074         * Simple try to initialize it.
01075         * May be not needed in linux system.
01076         */
01077       res = __ast_rwlock_init(file, line, func, name, lock);
01078       if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
01079          __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n",
01080                file, line, func, name);
01081          return res;
01082       }
01083    }
01084 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
01085 
01086    ast_store_lock_info(AST_WRLOCK, file, line, func, name, lock);
01087 #ifdef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK
01088    res = pthread_rwlock_timedwrlock(lock, abs_timeout);
01089 #else
01090    do {
01091       struct timeval _start = ast_tvnow(), _diff;
01092       for (;;) {
01093          if (!(res = pthread_rwlock_trywrlock(lock))) {
01094             break;
01095          }
01096          _diff = ast_tvsub(ast_tvnow(), _start);
01097          if (_diff.tv_sec > abs_timeout->tv_sec || (_diff.tv_sec == abs_timeout->tv_sec && _diff.tv_usec * 1000 > abs_timeout->tv_nsec)) {
01098             break;
01099          }
01100          usleep(1);
01101       }
01102    } while (0);
01103 #endif
01104    if (!res)
01105       ast_mark_lock_acquired(lock);
01106    else
01107       ast_remove_lock_info(lock);
01108    return res;
01109 }

static int _ast_rwlock_tryrdlock ( ast_rwlock_t lock,
const char *  name,
const char *  file,
int  line,
const char *  func 
) [inline, static]

Definition at line 1114 of file lock.h.

References __ast_mutex_logger, __ast_rwlock_init(), ast_mark_lock_acquired(), AST_RDLOCK, ast_remove_lock_info(), AST_RWLOCK_INIT_VALUE, and ast_store_lock_info().

01116 {
01117    int res;
01118 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
01119    int canlog = strcmp(file, "logger.c");
01120    
01121    if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
01122        /* Don't warn abount uninitialized lock.
01123         * Simple try to initialize it.
01124         * May be not needed in linux system.
01125         */
01126       res = __ast_rwlock_init(file, line, func, name, lock);
01127       if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
01128          __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n",
01129                file, line, func, name);
01130          return res;
01131       }
01132    }
01133 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
01134 
01135    ast_store_lock_info(AST_RDLOCK, file, line, func, name, lock);
01136    res = pthread_rwlock_tryrdlock(lock);
01137    if (!res)
01138       ast_mark_lock_acquired(lock);
01139    else
01140       ast_remove_lock_info(lock);
01141    return res;
01142 }

static int _ast_rwlock_trywrlock ( ast_rwlock_t lock,
const char *  name,
const char *  file,
int  line,
const char *  func 
) [inline, static]

Definition at line 1147 of file lock.h.

References __ast_mutex_logger, __ast_rwlock_init(), ast_mark_lock_acquired(), ast_remove_lock_info(), AST_RWLOCK_INIT_VALUE, ast_store_lock_info(), and AST_WRLOCK.

01149 {
01150    int res;
01151 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
01152    int canlog = strcmp(file, "logger.c");
01153    
01154    if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
01155        /* Don't warn abount uninitialized lock.
01156         * Simple try to initialize it.
01157         * May be not needed in linux system.
01158         */
01159       res = __ast_rwlock_init(file, line, func, name, lock);
01160       if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
01161          __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n",
01162                file, line, func, name);
01163          return res;
01164       }
01165    }
01166 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
01167 
01168    ast_store_lock_info(AST_WRLOCK, file, line, func, name, lock);
01169    res = pthread_rwlock_trywrlock(lock);
01170    if (!res)
01171       ast_mark_lock_acquired(lock);
01172    else
01173       ast_remove_lock_info(lock);
01174    return res;
01175 }

static int _ast_rwlock_unlock ( ast_rwlock_t lock,
const char *  name,
const char *  file,
int  line,
const char *  func 
) [inline, static]

Definition at line 923 of file lock.h.

References __ast_mutex_logger, __ast_rwlock_init(), ast_remove_lock_info(), and AST_RWLOCK_INIT_VALUE.

00925 {
00926    int res;
00927 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00928    int canlog = strcmp(file, "logger.c");
00929 
00930    if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
00931       __ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is uninitialized.\n",
00932                file, line, func, name);
00933       res = __ast_rwlock_init(file, line, func, name, lock);
00934       if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
00935          __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n",
00936                file, line, func, name);
00937       }
00938       return res;
00939    }
00940 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00941    
00942    res = pthread_rwlock_unlock(lock);
00943    ast_remove_lock_info(lock);
00944    return res;
00945 }

static int _ast_rwlock_wrlock ( ast_rwlock_t lock,
const char *  name,
const char *  file,
int  line,
const char *  func 
) [inline, static]

Definition at line 983 of file lock.h.

References __ast_mutex_logger, __ast_rwlock_init(), ast_mark_lock_acquired(), ast_remove_lock_info(), AST_RWLOCK_INIT_VALUE, ast_store_lock_info(), and AST_WRLOCK.

00985 {
00986    int res;
00987 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
00988    int canlog = strcmp(file, "logger.c");
00989    
00990    if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
00991        /* Don't warn abount uninitialized lock.
00992         * Simple try to initialize it.
00993         * May be not needed in linux system.
00994         */
00995       res = __ast_rwlock_init(file, line, func, name, lock);
00996       if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
00997          __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n",
00998                file, line, func, name);
00999          return res;
01000       }
01001    }
01002 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
01003 
01004    ast_store_lock_info(AST_WRLOCK, file, line, func, name, lock);
01005    res = pthread_rwlock_wrlock(lock);
01006    if (!res)
01007       ast_mark_lock_acquired(lock);
01008    else
01009       ast_remove_lock_info(lock);
01010    return res;
01011 }

int ast_atomic_dec_and_test ( volatile int *  p  ) 

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

Definition at line 1363 of file lock.h.

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

01366 {

int ast_atomic_fetchadd_int ( volatile int *  p,
int  v 
)
int ast_atomic_fetchadd_int_slow ( volatile int *  p,
int  v 
)

Definition at line 1327 of file utils.c.

References ast_mutex_lock, and ast_mutex_unlock.

01328 {
01329         int ret;
01330         ast_mutex_lock(&fetchadd_m);
01331         ret = *p;
01332         *p += v;
01333         ast_mutex_unlock(&fetchadd_m);
01334         return ret;
01335 }

int ast_find_lock_info ( void *  lock_addr,
char *  filename,
size_t  filename_size,
int *  lineno,
char *  func,
size_t  func_size,
char *  mutex_name,
size_t  mutex_name_size 
)

retrieve lock info for the specified mutex

this gets called during deadlock avoidance, so that the information may be preserved as to what location originally acquired the lock.

void ast_mark_lock_acquired ( void *  lock_addr  ) 
void ast_mark_lock_failed ( void *  lock_addr  ) 

Mark the last lock as failed (trylock).

Referenced by __ast_pthread_mutex_trylock().

static void ast_reentrancy_init ( ast_mutex_t p_ast_mutex  )  [inline, static]

Definition at line 241 of file lock.h.

References AST_MAX_REENTRANCY, AST_MUTEX_KIND, ast_mutex_info::file, ast_mutex_info::func, ast_mutex_info::lineno, pthread_mutex_init, ast_mutex_info::reentr_mutex, ast_mutex_info::reentrancy, and ast_mutex_info::thread.

Referenced by __ast_pthread_mutex_init().

00242 {
00243    int i;
00244    pthread_mutexattr_t reentr_attr;
00245 
00246    for (i = 0; i < AST_MAX_REENTRANCY; i++) {
00247       p_ast_mutex->file[i] = NULL;
00248       p_ast_mutex->lineno[i] = 0;
00249       p_ast_mutex->func[i] = NULL;
00250       p_ast_mutex->thread[i] = 0;
00251    }
00252 
00253    p_ast_mutex->reentrancy = 0;
00254 
00255    pthread_mutexattr_init(&reentr_attr);
00256    pthread_mutexattr_settype(&reentr_attr, AST_MUTEX_KIND);
00257    pthread_mutex_init(&p_ast_mutex->reentr_mutex, &reentr_attr);
00258    pthread_mutexattr_destroy(&reentr_attr);
00259 }

static void ast_reentrancy_lock ( ast_mutex_t p_ast_mutex  )  [inline, static]
static void ast_reentrancy_unlock ( ast_mutex_t p_ast_mutex  )  [inline, static]
void ast_remove_lock_info ( void *  lock_addr  ) 

remove lock info for the current thread

this gets called by ast_mutex_unlock so that information on the lock can be removed from the current thread's lock info struct.

Referenced by __ast_cond_timedwait(), __ast_cond_wait(), __ast_pthread_mutex_lock(), __ast_pthread_mutex_unlock(), _ast_rwlock_rdlock(), _ast_rwlock_timedrdlock(), _ast_rwlock_timedwrlock(), _ast_rwlock_tryrdlock(), _ast_rwlock_trywrlock(), _ast_rwlock_unlock(), and _ast_rwlock_wrlock().

void ast_store_lock_info ( enum ast_lock_type  type,
const char *  filename,
int  line_num,
const char *  func,
const char *  lock_name,
void *  lock_addr 
)

Store lock info for the current thread.

This function gets called in ast_mutex_lock() and ast_mutex_trylock() so that information about this lock can be stored in this thread's lock info struct. The lock is marked as pending as the thread is waiting on the lock. ast_mark_lock_acquired() will mark it as held by this thread.

Referenced by __ast_cond_timedwait(), __ast_cond_wait(), __ast_pthread_mutex_lock(), __ast_pthread_mutex_trylock(), _ast_rwlock_rdlock(), _ast_rwlock_timedrdlock(), _ast_rwlock_timedwrlock(), _ast_rwlock_tryrdlock(), _ast_rwlock_trywrlock(), and _ast_rwlock_wrlock().

static void delete_reentrancy_cs ( ast_mutex_t p_ast_mutex  )  [inline, static]

Definition at line 261 of file lock.h.

References pthread_mutex_destroy, and ast_mutex_info::reentr_mutex.

Referenced by __ast_pthread_mutex_destroy().

00262 {
00263    pthread_mutex_destroy(&p_ast_mutex->reentr_mutex);
00264 }

static void init_empty_mutex ( void   )  [static]

Definition at line 226 of file lock.h.

References empty_mutex.

00227 {
00228    memset(&empty_mutex, 0, sizeof(empty_mutex));
00229 }


Variable Documentation

pthread_mutex_t empty_mutex [static]

Definition at line 132 of file lock.h.

Referenced by init_empty_mutex().


Generated on 7 Jun 2012 for Asterisk - the Open Source PBX by  doxygen 1.6.1