Thu Dec 17 15:36:06 2009

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 <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 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)
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 819 of file lock.h.

 
#define __ast_mutex_logger (  )     do { if (canlog) ast_log(LOG_ERROR, __VA_ARGS__); else fprintf(stderr, __VA_ARGS__); } while (0)

Definition at line 97 of file lock.h.

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

#define __AST_RWLOCK_DEFINE ( scope,
rwlock   )     scope ast_rwlock_t rwlock = AST_RWLOCK_INIT_VALUE

Definition at line 1271 of file lock.h.

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

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

Referenced by __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_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_set_callerid(), ast_settimeout(), ast_softhangup(), ast_stopstream(), ast_transfer(), ast_udptl_bridge(), ast_waitfor_nandfds(), ast_write(), asyncgoto_exec(), callerid_read(), callerid_write(), channel_spy(), common_exec(), dahdi_handle_dtmfup(), do_atxfer(), do_parking_thread(), end_bridge_callback(), feature_interpret(), func_header_read(), func_inheritance_write(), function_sipchaninfo_read(), generator_force(), handle_request_invite(), local_hangup(), local_queue_frame(), p2p_callback_disable(), park_exec(), 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(), transmit_invite(), try_calling(), and update_bridgepeer().

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

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

Definition at line 1377 of file lock.h.

Referenced by __ast_read(), __oh323_rtp_create(), agent_indicate(), agent_logoff(), ast_channel_masquerade(), ast_queue_hangup(), ast_rtp_bridge(), ast_rtp_early_bridge(), ast_rtp_make_compatible(), ast_udptl_bridge(), ast_write(), auto_congest(), channel_find_locked(), channel_spy(), chanspy_ds_free(), cleanup_connection(), dahdi_softhangup_all(), do_monitor(), get_sip_pvt_byid_locked(), hangup_connection(), local_hangup(), local_queue_frame(), oh323_rtp_read(), oh323_simulate_dtmf_end(), receive_digit(), retrans_pkt(), scheduler_process_request_queue(), setup_rtp_connection(), sip_park(), sipsock_read(), and update_state().

#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 1374 of file lock.h.

Referenced by __ast_queue_frame(), __ast_read(), __login_exec(), __oh323_destroy(), __oh323_rtp_create(), __sip_destroy(), _macro_exec(), action_atxfer(), action_getvar(), action_hangup(), action_redirect(), action_setvar(), action_status(), action_timeout(), add_features_datastores(), agent_hangup(), agent_indicate(), agent_logoff(), 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_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_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(), callerid_read(), callerid_write(), change_monitor_action(), channel_spy(), chanspy_ds_free(), cleanup_connection(), common_exec(), dahdi_handle_dtmfup(), dahdi_softhangup_all(), do_atxfer(), do_monitor(), do_parking_thread(), do_pause_or_unpause(), end_bridge_callback(), fast_originate(), feature_interpret(), func_header_read(), func_inheritance_write(), 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_attended_transfer(), local_hangup(), local_queue_frame(), manager_park(), mixmonitor_cli(), next_channel(), oh323_rtp_read(), oh323_simulate_dtmf_end(), p2p_callback_disable(), park_call_full(), park_exec(), 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(), receive_digit(), retrans_pkt(), ring_entry(), 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(), sipsock_read(), smdi_msg_read(), smdi_msg_retrieve_read(), start_monitor_action(), 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)

Definition at line 712 of file lock.h.

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

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

Definition at line 710 of file lock.h.

Referenced by __login_exec(), __unload_module(), agent_cleanup(), agent_hangup(), ast_audiohook_destroy(), ast_smdi_interface_destroy(), do_reload(), iax2_process_thread_cleanup(), mixmonitor_free(), read_agent_config(), setup_mixmonitor_ds(), sla_destroy(), sla_handle_dial_state_event(), and sla_station_exec().

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

Definition at line 709 of file lock.h.

Referenced by add_agent(), alloc_smdi_interface(), ast_audiohook_init(), ast_autoservice_init(), ast_device_state_engine_init(), do_reload(), find_idle_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 711 of file lock.h.

Referenced by __unload_module(), agent_cleanup(), agent_hangup(), agent_new(), ast_audiohook_detach_list(), ast_audiohook_remove(), ast_audiohook_write_frame(), ast_autoservice_start(), ast_device_state_changed_literal(), audio_audiohook_write_list(), conf_free(), conf_run(), dial_trunk(), iax2_sched_add(), mixmonitor_ds_destroy(), run_station(), signal_condition(), sla_destroy(), sla_queue_event_full(), statechange_queue(), submit_unscheduled_batch(), 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 714 of file lock.h.

Referenced by ast_audiohook_trigger_wait(), do_cdr(), iax2_process_thread(), mwi_monitor_handler(), sched_thread(), 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 713 of file lock.h.

Referenced by __login_exec(), announce_thread(), autoservice_run(), dahdi_restart(), device_state_thread(), do_devstate_changes(), mixmonitor_thread(), sched_thread(), sla_handle_dial_state_event(), sla_station_exec(), and sla_thread().

#define AST_MAX_REENTRANCY   10

Definition at line 113 of file lock.h.

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

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

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

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

Definition at line 705 of file lock.h.

Referenced by __ast_context_destroy(), __login_exec(), __oh323_destroy(), __unload_module(), agent_cleanup(), agent_hangup(), ao2_ref(), ast_audiohook_destroy(), ast_channel_free(), ast_dnsmgr_release(), ast_odbc_request_obj(), ast_rtp_destroy(), ast_smdi_interface_destroy(), ast_speech_destroy(), ast_speech_new(), build_gateway(), common_exec(), delete_devices(), destroy_dahdi_pvt(), destroy_queue(), destroy_session(), features_hangup(), free_session(), iax2_process_thread_cleanup(), local_pvt_destroy(), misdn_cfg_destroy(), misdn_jb_destroy(), mixmonitor_free(), read_agent_config(), release_chan(), release_chan_early(), sched_context_destroy(), setup_mixmonitor_ds(), sip_alloc(), sla_destroy(), sla_handle_dial_state_event(), sla_station_exec(), timing_read(), and unload_module().

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

Definition at line 288 of file lock.h.

Referenced by accept_thread(), add_agent(), alloc_profile(), alloc_queue(), alloc_smdi_interface(), ao2_alloc(), ast_audiohook_init(), ast_dial_create(), ast_dnsmgr_get(), ast_odbc_request_obj(), ast_rtp_new_init(), ast_speech_new(), build_conf(), build_device(), build_gateway(), chandup(), common_exec(), conf_run(), crypto_init(), dahdi_restart(), features_alloc(), find_idle_thread(), gtalk_alloc(), load_module(), local_alloc(), misdn_cfg_init(), misdn_jb_init(), mkintf(), oh323_alloc(), read_config(), rpt_master(), sched_context_create(), setup_mixmonitor_ds(), sip_alloc(), skinny_new(), sla_handle_dial_state_event(), sla_load_config(), sla_station_exec(), and start_network_thread().

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

Definition at line 289 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 109 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 110 of file lock.h.

#define AST_MUTEX_INITIALIZER   __use_AST_MUTEX_DEFINE_STATIC_rather_than_AST_MUTEX_INITIALIZER__

Definition at line 840 of file lock.h.

#define AST_MUTEX_KIND   PTHREAD_MUTEX_RECURSIVE

Definition at line 92 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 706 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(), __queues_show(), __send_lagrq(), __send_ping(), __sip_show_channels(), __unload_module(), accept_thread(), action_agent_callback_login(), action_agents(), action_waitevent(), add_to_queue(), agent_ack_sleep(), agent_call(), agent_cont_sleep(), agent_devicestate(), agent_devicestate_cb(), 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_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(), 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_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_unregister_indication(), ast_unregister_indication_country(), ast_unreplace_sigchld(), ast_walk_indications(), astman_append(), astman_verify_session_readpermissions(), astman_verify_session_writepermissions(), auth_reject(), authenticate_reply(), auto_congest(), auto_hangup(), cb_events(), cb_extensionstate(), 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(), compare_weight(), complete_dpreply(), complete_queue_remove_member(), 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_answer(), dahdi_bridge(), dahdi_call(), dahdi_destroy_channel_bynum(), dahdi_digit_begin(), dahdi_digit_end(), dahdi_exception(), dahdi_fixup(), dahdi_func_read(), dahdi_handle_dtmfup(), dahdi_handle_event(), 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_show_channel(), dahdi_show_channels(), dahdi_softhangup_all(), dahdi_unlink(), dahdi_write(), database_show(), database_showkey(), decrease_call_count(), defer_full_frame(), delete_devices(), delete_users(), destroy_all_channels(), destroy_all_mailbox_mappings(), destroy_endpoint(), 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_queue_by_name_rt(), find_session(), find_subchannel_and_lock(), find_tpeer(), function_remote(), get_input(), get_member_status(), get_sip_pvt_byid_locked(), 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_request(), handle_request_invite(), handle_request_subscribe(), 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(), interface_exists_global(), is_our_turn(), join_queue(), leave_queue(), load_config(), load_module(), load_rpt_vars(), local_answer(), local_call(), local_digit_begin(), local_digit_end(), local_fixup(), local_hangup(), local_indicate(), local_queue_frame(), local_sendhtml(), local_sendtext(), local_write(), locals_show(), lock_both(), lock_msg_q(), make_trunk(), manager_event(), manager_parking_status(), manager_queues_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_close_fs(), mixmonitor_ds_destroy(), mixmonitor_thread(), mwi_monitor_handler(), node_lookup(), 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_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_hangup_all(), process_events(), prune_gateways(), queue_function_queuemembercount(), queue_function_queuememberlist(), queue_function_queuewaitingcount(), queue_member_count(), queue_ringing_trunk(), realtime_multi_pgsql(), realtime_pgsql(), recalc_holdtime(), record_abandoned(), recordthread(), register_verify(), registry_authrequest(), release_chan(), release_chan_early(), reload(), reload_agents(), reload_config(), reload_firmware(), reload_followme(), reload_queue_members(), reload_queues(), remove_from_queue(), restart_monitor(), retrans_pkt(), ring_entry(), 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_request(), set_eventmask(), set_member_paused(), setup_chanspy_ds(), setup_dahdi(), show_keys(), 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(), submit_unscheduled_batch(), tds_log(), timing_read(), transmit_response(), try_calling(), try_load_key(), unload_module(), update_pgsql(), update_queue(), update_realtime_members(), update_registry(), update_status(), verboser(), vm_execmain(), and writefile().

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

Definition at line 708 of file lock.h.

Referenced by __ao2_trylock(), ast_module_reload(), cache_get_callno_locked(), check_bridge(), dahdi_bridge(), dahdi_handle_event(), dahdi_queue_frame(), dahdi_read(), dahdi_unlink(), do_monitor(), grab_owner(), iax2_destroy(), iax2_queue_control_data(), iax2_queue_frame(), iax2_queue_hangup(), local_hangup(), local_queue_frame(), lock_both(), mgcp_queue_frame(), mgcp_queue_hangup(), network_thread(), pri_grab(), pri_hangup_all(), refresh_list(), socket_process(), unload_module(), and wakeup_sub().

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

Definition at line 707 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(), __queues_show(), __send_lagrq(), __send_ping(), __unload_module(), accept_thread(), action_agent_callback_login(), action_agents(), action_setcdruserfield(), action_waitevent(), add_to_queue(), agent_ack_sleep(), agent_call(), agent_cont_sleep(), agent_devicestate(), agent_devicestate_cb(), 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_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(), 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_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_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(), cb_extensionstate(), 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(), compare_weight(), complete_ch_helper(), complete_dpreply(), complete_queue_remove_member(), conf_exec(), conf_free(), conf_run(), 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_answer(), dahdi_bridge(), dahdi_call(), dahdi_destroy_channel_bynum(), dahdi_digit_begin(), dahdi_digit_end(), dahdi_exception(), dahdi_func_read(), dahdi_handle_dtmfup(), 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_write(), database_show(), database_showkey(), decrease_call_count(), defer_full_frame(), delete_users(), destroy_all_channels(), destroy_all_mailbox_mappings(), 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_locked(), find_line_by_name(), find_queue_by_name_rt(), find_session(), find_subchannel_and_lock(), function_remote(), get_input(), get_member_status(), get_sip_pvt_byid_locked(), 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_request(), handle_request_invite(), handle_request_subscribe(), 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_provision_build(), iax_provision_reload(), iax_provision_version(), iax_template_parse(), increase_call_count(), interface_exists_global(), is_our_turn(), join_queue(), leave_queue(), load_config(), load_module(), load_rpt_vars(), local_answer(), local_attended_transfer(), local_call(), local_digit_begin(), local_digit_end(), local_fixup(), local_hangup(), local_indicate(), local_queue_frame(), local_sendhtml(), local_sendtext(), local_write(), locals_show(), make_trunk(), manager_event(), manager_parking_status(), manager_play_dtmf(), manager_queues_status(), 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_close_fs(), mixmonitor_ds_destroy(), mixmonitor_thread(), mwi_monitor_handler(), network_thread(), node_lookup(), 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_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_hangup_all(), pri_rel(), process_events(), progress(), queue_function_queuemembercount(), queue_function_queuememberlist(), queue_function_queuewaitingcount(), queue_member_count(), queue_ringing_trunk(), realtime_multi_pgsql(), realtime_pgsql(), recalc_holdtime(), receive_digit(), record_abandoned(), recordthread(), refresh_list(), register_verify(), registry_authrequest(), release_chan(), release_chan_early(), reload(), reload_agents(), reload_config(), reload_firmware(), reload_followme(), reload_queue_members(), reload_queues(), remove_from_queue(), restart_monitor(), retrans_pkt(), ring_entry(), 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_request(), set_dtmf_payload(), set_eventmask(), set_local_capabilities(), set_member_paused(), setup_chanspy_ds(), setup_dahdi(), setup_rtp_connection(), show_keys(), 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_transfer(), sip_write(), sipsock_read(), skinny_hangup(), skinny_read(), skinny_req_parse(), skinny_reset_device(), 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(), submit_unscheduled_batch(), tds_log(), timing_read(), transmit_response(), try_calling(), try_load_key(), unload_module(), unlock_both(), unlock_msg_q(), update_pgsql(), update_queue(), update_realtime_members(), update_registry(), update_status(), verboser(), vm_execmain(), wakeup_sub(), and writefile().

#define AST_PTHREADT_NULL   (pthread_t) -1

Definition at line 78 of file lock.h.

Referenced by __unload_module(), accept_thread(), action_waitevent(), ast_autoservice_start(), ast_autoservice_stop(), ast_cdr_submit_batch(), ast_device_state_changed_literal(), ast_dial_create(), ast_dial_join(), ast_smdi_interface_destroy(), build_conf(), conf_free(), conf_run(), console_verboser(), dahdi_restart(), do_reload(), http_server_start(), iax2_transmit(), init_mfcr2_globals(), load_module(), load_rpt_vars(), manager_event(), moh_class_destructor(), network_thread(), pri_grab(), process_precache(), quit_handler(), restart_monitor(), rpt_master(), sla_destroy(), sla_queue_event_full(), and unload_module().

#define AST_PTHREADT_STOP   (pthread_t) -2

Definition at line 79 of file lock.h.

Referenced by __unload_module(), answer_exec_run(), ast_dial_join(), ast_smdi_interface_destroy(), dahdi_restart(), monitor_dial(), restart_monitor(), rpt(), rpt_master(), and unload_module().

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

Definition at line 1275 of file lock.h.

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

Definition at line 885 of file lock.h.

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

Definition at line 858 of file lock.h.

#define AST_RWLOCK_INIT_VALUE   PTHREAD_RWLOCK_INITIALIZER

Definition at line 851 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_rwlock_rdlock (  )     _ast_rwlock_rdlock(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Definition at line 934 of file lock.h.

Referenced by ast_feature_request_and_dial(), ast_rdlock_contexts(), complete_show_mancmd(), feature_interpret_helper(), handle_show_http(), handle_showfeatures(), handle_showmancmd(), handle_showmancmds(), handle_uri(), process_message(), and set_config_flags().

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

Definition at line 1000 of file lock.h.

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

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

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

Definition at line 1131 of file lock.h.

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

Definition at line 907 of file lock.h.

Referenced by ast_feature_request_and_dial(), ast_http_uri_link(), ast_http_uri_unlink(), ast_manager_register_struct(), ast_manager_unregister(), ast_unlock_contexts(), complete_show_mancmd(), feature_interpret_helper(), handle_show_http(), handle_showfeatures(), handle_showmancmds(), handle_uri(), process_message(), remap_feature(), set_config_flags(), and unmap_features().

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

Definition at line 967 of file lock.h.

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

#define DEADLOCK_AVOIDANCE ( lock   ) 

Unlock a lock briefly.

used during deadlock avoidance, to preserve the original location where a lock was originally acquired.

Definition at line 203 of file lock.h.

Referenced by agent_logoff(), channel_spy(), chanspy_ds_free(), dahdi_bridge(), dahdi_handle_event(), dahdi_queue_frame(), dahdi_read(), dahdi_unlink(), do_monitor(), get_sip_pvt_byid_locked(), grab_owner(), iax2_destroy(), iax2_queue_control_data(), iax2_queue_frame(), iax2_queue_hangup(), local_hangup(), lock_both(), mgcp_queue_frame(), mgcp_queue_hangup(), pri_grab(), pri_hangup_all(), retrans_pkt(), sip_park(), socket_process(), wait_for_peercallno(), and wakeup_sub().

#define DO_THREAD_CRASH   do { } while (0)

Definition at line 102 of file lock.h.

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

#define gethostbyname   __gethostbyname__is__not__reentrant__use__ast_gethostbyname__instead__

Definition at line 842 of file lock.h.

Referenced by connect_sphinx().

#define pthread_cond_broadcast   use_ast_cond_broadcast_instead_of_pthread_cond_broadcast

Definition at line 833 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 831 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 830 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 832 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 829 of file lock.h.

#define pthread_cond_timedwait   use_ast_cond_timedwait_instead_of_pthread_cond_timedwait

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

Referenced by __ast_cond_wait().

#define pthread_create   __use_ast_pthread_create_instead__

Definition at line 845 of file lock.h.

Referenced by ast_pthread_create_stack(), and misdn_tasks_init().

#define pthread_mutex_destroy   use_ast_mutex_destroy_instead_of_pthread_mutex_destroy

Definition at line 828 of file lock.h.

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

#define pthread_mutex_init   use_ast_mutex_init_instead_of_pthread_mutex_init

Definition at line 827 of file lock.h.

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

#define PTHREAD_MUTEX_INIT_VALUE   PTHREAD_MUTEX_INITIALIZER

Definition at line 91 of file lock.h.

Referenced by __ast_pthread_mutex_destroy().

#define pthread_mutex_lock   use_ast_mutex_lock_instead_of_pthread_mutex_lock

Definition at line 824 of file lock.h.

Referenced by __ast_pthread_mutex_lock(), ast_find_lock_info(), ast_mark_lock_acquired(), ast_mark_lock_failed(), ast_reentrancy_lock(), ast_remove_lock_info(), ast_store_lock_info(), dummy_start(), find_free_chan_in_stack(), handle_event_nt(), handle_frm_nt(), handle_l1(), handle_show_locks(), handle_timers(), lock_info_destroy(), 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 823 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 826 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 825 of file lock.h.

Referenced by __ast_pthread_mutex_destroy(), __ast_pthread_mutex_unlock(), ast_find_lock_info(), ast_mark_lock_acquired(), ast_mark_lock_failed(), ast_reentrancy_unlock(), ast_remove_lock_info(), ast_store_lock_info(), dummy_start(), handle_event_nt(), handle_frm_nt(), handle_l1(), handle_show_locks(), handle_timers(), lock_info_destroy(), manager_event_handler(), misdn_lib_get_free_bc(), misdn_lib_get_l2_down(), misdn_lib_get_l2_up(), and misdn_send_unlock().

#define ROFFSET   ((t->reentrancy > 0) ? (t->reentrancy-1) : 0)

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

typedef struct ast_mutex_info ast_mutex_t

Definition at line 127 of file lock.h.

typedef pthread_rwlock_t ast_rwlock_t

Definition at line 848 of file lock.h.


Enumeration Type Documentation

enum ast_lock_type

Enumerator:
AST_MUTEX 
AST_RDLOCK 
AST_WRLOCK 

Definition at line 133 of file lock.h.

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


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 551 of file lock.h.

References pthread_cond_broadcast.

00553 {
00554    return pthread_cond_broadcast(cond);
00555 }

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 557 of file lock.h.

References pthread_cond_destroy.

00559 {
00560    return pthread_cond_destroy(cond);
00561 }

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 539 of file lock.h.

References pthread_cond_init.

00541 {
00542    return pthread_cond_init(cond, cond_attr);
00543 }

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 545 of file lock.h.

References pthread_cond_signal.

00547 {
00548    return pthread_cond_signal(cond);
00549 }

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 634 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, pthread_cond_timedwait, pthread_mutex_t, ROFFSET, and t.

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

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 563 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, pthread_cond_wait, pthread_mutex_t, ROFFSET, and t.

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

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 293 of file lock.h.

References __ast_mutex_logger, ast_reentrancy_lock(), ast_reentrancy_unlock(), delete_reentrancy_cs(), pthread_mutex_destroy, PTHREAD_MUTEX_INIT_VALUE, pthread_mutex_t, pthread_mutex_trylock, pthread_mutex_unlock, ROFFSET, and t.

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

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 257 of file lock.h.

References AST_MUTEX_KIND, ast_reentrancy_init(), pthread_mutex_init, pthread_mutex_t, and t.

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

00259 {
00260    int res;
00261    pthread_mutexattr_t  attr;
00262 
00263 #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
00264 
00265    if ((t->mutex) != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
00266 /*
00267       int canlog = strcmp(filename, "logger.c") & track;
00268       __ast_mutex_logger("%s line %d (%s): NOTICE: mutex '%s' is already initialized.\n",
00269                filename, lineno, func, mutex_name);
00270       DO_THREAD_CRASH;
00271 */
00272       return 0;
00273    }
00274 
00275 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00276 
00277    ast_reentrancy_init(t);
00278    t->track = track;
00279 
00280    pthread_mutexattr_init(&attr);
00281    pthread_mutexattr_settype(&attr, AST_MUTEX_KIND);
00282 
00283    res = pthread_mutex_init(&t->mutex, &attr);
00284    pthread_mutexattr_destroy(&attr);
00285    return res;
00286 }

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 351 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, pthread_mutex_lock, pthread_mutex_t, pthread_mutex_trylock, ROFFSET, and t.

Referenced by __ao2_lock().

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

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 439 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(), pthread_mutex_t, pthread_mutex_trylock, and t.

Referenced by __ao2_trylock().

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

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 485 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, pthread_mutex_t, pthread_mutex_unlock, ROFFSET, and t.

Referenced by __ao2_unlock().

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

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 887 of file lock.h.

References __ast_mutex_logger, and AST_RWLOCK_INIT_VALUE.

00888 {
00889    int res;
00890    int canlog = strcmp(filename, "logger.c");
00891 
00892 #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
00893    if (*prwlock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
00894       __ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is uninitialized.\n",
00895                filename, lineno, func, rwlock_name);
00896       return 0;
00897    }
00898 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00899    
00900    if ((res = pthread_rwlock_destroy(prwlock)))
00901       __ast_mutex_logger("%s line %d (%s): Error destroying rwlock %s: %s\n",
00902             filename, lineno, func, rwlock_name, strerror(res));
00903 
00904    return res;
00905 }

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

00862 {
00863    int res;
00864    pthread_rwlockattr_t attr;
00865 #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
00866         int canlog = strcmp(filename, "logger.c");
00867 
00868         if (*prwlock != ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
00869       __ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is already initialized.\n",
00870             filename, lineno, func, rwlock_name);
00871       return 0;
00872    }
00873 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00874    pthread_rwlockattr_init(&attr);
00875 
00876 #ifdef HAVE_PTHREAD_RWLOCK_PREFER_WRITER_NP
00877    pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NP);
00878 #endif
00879 
00880    res = pthread_rwlock_init(prwlock, &attr);
00881    pthread_rwlockattr_destroy(&attr);
00882    return res;
00883 }

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

00939 {
00940    int res;
00941 #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
00942    int canlog = strcmp(file, "logger.c");
00943    
00944    if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
00945        /* Don't warn abount uninitialized lock.
00946         * Simple try to initialize it.
00947         * May be not needed in linux system.
00948         */
00949       res = __ast_rwlock_init(file, line, func, name, lock);
00950       if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
00951          __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n",
00952                file, line, func, name);
00953          return res;
00954       }
00955    }
00956 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00957    
00958    ast_store_lock_info(AST_RDLOCK, file, line, func, name, lock);
00959    res = pthread_rwlock_rdlock(lock);
00960    if (!res)
00961       ast_mark_lock_acquired(lock);
00962    else
00963       ast_remove_lock_info(lock);
00964    return res;
00965 }

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

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

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 1052 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.

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

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

01103 {
01104    int res;
01105 #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
01106    int canlog = strcmp(file, "logger.c");
01107    
01108    if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
01109        /* Don't warn abount uninitialized lock.
01110         * Simple try to initialize it.
01111         * May be not needed in linux system.
01112         */
01113       res = __ast_rwlock_init(file, line, func, name, lock);
01114       if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
01115          __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n",
01116                file, line, func, name);
01117          return res;
01118       }
01119    }
01120 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
01121 
01122    ast_store_lock_info(AST_RDLOCK, file, line, func, name, lock);
01123    res = pthread_rwlock_tryrdlock(lock);
01124    if (!res)
01125       ast_mark_lock_acquired(lock);
01126    else
01127       ast_remove_lock_info(lock);
01128    return res;
01129 }

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 1134 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.

01136 {
01137    int res;
01138 #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
01139    int canlog = strcmp(file, "logger.c");
01140    
01141    if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
01142        /* Don't warn abount uninitialized lock.
01143         * Simple try to initialize it.
01144         * May be not needed in linux system.
01145         */
01146       res = __ast_rwlock_init(file, line, func, name, lock);
01147       if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
01148          __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n",
01149                file, line, func, name);
01150          return res;
01151       }
01152    }
01153 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
01154 
01155    ast_store_lock_info(AST_WRLOCK, file, line, func, name, lock);
01156    res = pthread_rwlock_trywrlock(lock);
01157    if (!res)
01158       ast_mark_lock_acquired(lock);
01159    else
01160       ast_remove_lock_info(lock);
01161    return res;
01162 }

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 910 of file lock.h.

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

00912 {
00913    int res;
00914 #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
00915    int canlog = strcmp(file, "logger.c");
00916 
00917    if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
00918       __ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is uninitialized.\n",
00919                file, line, func, name);
00920       res = __ast_rwlock_init(file, line, func, name, lock);
00921       if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
00922          __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n",
00923                file, line, func, name);
00924       }
00925       return res;
00926    }
00927 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00928    
00929    res = pthread_rwlock_unlock(lock);
00930    ast_remove_lock_info(lock);
00931    return res;
00932 }

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 970 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.

00972 {
00973    int res;
00974 #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
00975    int canlog = strcmp(file, "logger.c");
00976    
00977    if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
00978        /* Don't warn abount uninitialized lock.
00979         * Simple try to initialize it.
00980         * May be not needed in linux system.
00981         */
00982       res = __ast_rwlock_init(file, line, func, name, lock);
00983       if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
00984          __ast_mutex_logger("%s line %d (%s): Error: rwlock '%s' is uninitialized and unable to initialize.\n",
00985                file, line, func, name);
00986          return res;
00987       }
00988    }
00989 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
00990 
00991    ast_store_lock_info(AST_WRLOCK, file, line, func, name, lock);
00992    res = pthread_rwlock_wrlock(lock);
00993    if (!res)
00994       ast_mark_lock_acquired(lock);
00995    else
00996       ast_remove_lock_info(lock);
00997    return res;
00998 }

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 1350 of file lock.h.

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

01353 {

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 1304 of file lock.h.

Referenced by __ao2_link(), __ao2_lock(), __ao2_trylock(), __ao2_unlock(), __ast_module_user_add(), __ast_module_user_hangup_all(), __ast_module_user_remove(), accept_thread(), admin_exec(), agent_new(), ao2_alloc(), ao2_callback(), ao2_container_alloc(), ao2_ref(), ast_cli_command(), ast_dial_append(), ast_module_ref(), ast_module_unref(), authenticate_verify(), build_conf(), common_exec(), dahdi_destroy(), dahdi_translate(), iax2_destroy_helper(), iax2_process_thread(), iax_frame_free(), iax_frame_new(), run_station(), sip_new(), sla_add_trunk_to_station(), sla_handle_hold_event(), sla_station_exec(), and smdi_msg_retrieve_read().

01307 {

int ast_atomic_fetchadd_int_slow ( volatile int *  p,
int  v 
)

Definition at line 1325 of file utils.c.

References ast_mutex_lock, ast_mutex_unlock, and fetchadd_m.

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

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

retrieve lock info for the specified mutex

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

Definition at line 623 of file utils.c.

References ast_copy_string(), ast_threadstorage_get(), pthread_mutex_lock, pthread_mutex_unlock, and thread_lock_info.

00624 {
00625    struct thr_lock_info *lock_info;
00626    int i = 0;
00627 
00628    if (!(lock_info = ast_threadstorage_get(&thread_lock_info, sizeof(*lock_info))))
00629       return -1;
00630 
00631    pthread_mutex_lock(&lock_info->lock);
00632 
00633    for (i = lock_info->num_locks - 1; i >= 0; i--) {
00634       if (lock_info->locks[i].lock_addr == lock_addr)
00635          break;
00636    }
00637 
00638    if (i == -1) {
00639       /* Lock not found :( */
00640       pthread_mutex_unlock(&lock_info->lock);
00641       return -1;
00642    }
00643 
00644    ast_copy_string(filename, lock_info->locks[i].file, filename_size);
00645    *lineno = lock_info->locks[i].line_num;
00646    ast_copy_string(func, lock_info->locks[i].func, func_size);
00647    ast_copy_string(mutex_name, lock_info->locks[i].lock_name, mutex_name_size);
00648 
00649    pthread_mutex_unlock(&lock_info->lock);
00650 
00651    return 0;
00652 }

void ast_mark_lock_acquired ( void *  lock_addr  ) 

Mark the last lock as acquired.

Definition at line 594 of file utils.c.

References ast_threadstorage_get(), pthread_mutex_lock, pthread_mutex_unlock, and thread_lock_info.

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

00595 {
00596    struct thr_lock_info *lock_info;
00597 
00598    if (!(lock_info = ast_threadstorage_get(&thread_lock_info, sizeof(*lock_info))))
00599       return;
00600 
00601    pthread_mutex_lock(&lock_info->lock);
00602    if (lock_info->locks[lock_info->num_locks - 1].lock_addr == lock_addr) {
00603       lock_info->locks[lock_info->num_locks - 1].pending = 0;
00604    }
00605    pthread_mutex_unlock(&lock_info->lock);
00606 }

void ast_mark_lock_failed ( void *  lock_addr  ) 

Mark the last lock as failed (trylock).

Definition at line 608 of file utils.c.

References ast_threadstorage_get(), pthread_mutex_lock, pthread_mutex_unlock, and thread_lock_info.

Referenced by __ast_pthread_mutex_trylock().

00609 {
00610    struct thr_lock_info *lock_info;
00611 
00612    if (!(lock_info = ast_threadstorage_get(&thread_lock_info, sizeof(*lock_info))))
00613       return;
00614 
00615    pthread_mutex_lock(&lock_info->lock);
00616    if (lock_info->locks[lock_info->num_locks - 1].lock_addr == lock_addr) {
00617       lock_info->locks[lock_info->num_locks - 1].pending = -1;
00618       lock_info->locks[lock_info->num_locks - 1].times_locked--;
00619    }
00620    pthread_mutex_unlock(&lock_info->lock);
00621 }

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

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

00233 {
00234    int i;
00235    pthread_mutexattr_t reentr_attr;
00236 
00237    for (i = 0; i < AST_MAX_REENTRANCY; i++) {
00238       p_ast_mutex->file[i] = NULL;
00239       p_ast_mutex->lineno[i] = 0;
00240       p_ast_mutex->func[i] = NULL;
00241       p_ast_mutex->thread[i] = 0;
00242    }
00243 
00244    p_ast_mutex->reentrancy = 0;
00245 
00246    pthread_mutexattr_init(&reentr_attr);
00247    pthread_mutexattr_settype(&reentr_attr, AST_MUTEX_KIND);
00248    pthread_mutex_init(&p_ast_mutex->reentr_mutex, &reentr_attr);
00249    pthread_mutexattr_destroy(&reentr_attr);
00250 }

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

Definition at line 222 of file lock.h.

References pthread_mutex_lock, and ast_mutex_info::reentr_mutex.

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

00223 {
00224    pthread_mutex_lock(&p_ast_mutex->reentr_mutex);
00225 }

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

Definition at line 227 of file lock.h.

References pthread_mutex_unlock, and ast_mutex_info::reentr_mutex.

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

00228 {
00229    pthread_mutex_unlock(&p_ast_mutex->reentr_mutex);
00230 }

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.

Definition at line 654 of file utils.c.

References ast_threadstorage_get(), thr_lock_info::num_locks, pthread_mutex_lock, pthread_mutex_unlock, and thread_lock_info.

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

00655 {
00656    struct thr_lock_info *lock_info;
00657    int i = 0;
00658 
00659    if (!(lock_info = ast_threadstorage_get(&thread_lock_info, sizeof(*lock_info))))
00660       return;
00661 
00662    pthread_mutex_lock(&lock_info->lock);
00663 
00664    for (i = lock_info->num_locks - 1; i >= 0; i--) {
00665       if (lock_info->locks[i].lock_addr == lock_addr)
00666          break;
00667    }
00668 
00669    if (i == -1) {
00670       /* Lock not found :( */
00671       pthread_mutex_unlock(&lock_info->lock);
00672       return;
00673    }
00674 
00675    if (lock_info->locks[i].times_locked > 1) {
00676       lock_info->locks[i].times_locked--;
00677       pthread_mutex_unlock(&lock_info->lock);
00678       return;
00679    }
00680 
00681    if (i < lock_info->num_locks - 1) {
00682       /* Not the last one ... *should* be rare! */
00683       memmove(&lock_info->locks[i], &lock_info->locks[i + 1], 
00684          (lock_info->num_locks - (i + 1)) * sizeof(lock_info->locks[0]));
00685    }
00686 
00687    lock_info->num_locks--;
00688 
00689    pthread_mutex_unlock(&lock_info->lock);
00690 }

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.

Definition at line 545 of file utils.c.

References ast_threadstorage_get(), pthread_mutex_lock, pthread_mutex_unlock, and thread_lock_info.

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

00547 {
00548    struct thr_lock_info *lock_info;
00549    int i;
00550 
00551    if (!(lock_info = ast_threadstorage_get(&thread_lock_info, sizeof(*lock_info))))
00552       return;
00553 
00554    pthread_mutex_lock(&lock_info->lock);
00555 
00556    for (i = 0; i < lock_info->num_locks; i++) {
00557       if (lock_info->locks[i].lock_addr == lock_addr) {
00558          lock_info->locks[i].times_locked++;
00559          pthread_mutex_unlock(&lock_info->lock);
00560          return;
00561       }
00562    }
00563 
00564    if (lock_info->num_locks == AST_MAX_LOCKS) {
00565       /* Can't use ast_log here, because it will cause infinite recursion */
00566       fprintf(stderr, "XXX ERROR XXX A thread holds more locks than '%d'."
00567          "  Increase AST_MAX_LOCKS!\n", AST_MAX_LOCKS);
00568       pthread_mutex_unlock(&lock_info->lock);
00569       return;
00570    }
00571 
00572    if (i && lock_info->locks[i - 1].pending == -1) {
00573       /* The last lock on the list was one that this thread tried to lock but
00574        * failed at doing so.  It has now moved on to something else, so remove
00575        * the old lock from the list. */
00576       i--;
00577       lock_info->num_locks--;
00578       memset(&lock_info->locks[i], 0, sizeof(lock_info->locks[0]));
00579    }
00580 
00581    lock_info->locks[i].file = filename;
00582    lock_info->locks[i].line_num = line_num;
00583    lock_info->locks[i].func = func;
00584    lock_info->locks[i].lock_name = lock_name;
00585    lock_info->locks[i].lock_addr = lock_addr;
00586    lock_info->locks[i].times_locked = 1;
00587    lock_info->locks[i].type = type;
00588    lock_info->locks[i].pending = 1;
00589    lock_info->num_locks++;
00590 
00591    pthread_mutex_unlock(&lock_info->lock);
00592 }

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

Definition at line 252 of file lock.h.

References pthread_mutex_destroy, and ast_mutex_info::reentr_mutex.

Referenced by __ast_pthread_mutex_destroy().

00253 {
00254    pthread_mutex_destroy(&p_ast_mutex->reentr_mutex);
00255 }

static void init_empty_mutex ( void   )  [static]

Definition at line 217 of file lock.h.

References empty_mutex.

00218 {
00219    memset(&empty_mutex, 0, sizeof(empty_mutex));
00220 }


Variable Documentation

pthread_mutex_t empty_mutex [static]

Definition at line 131 of file lock.h.

Referenced by init_empty_mutex().


Generated on Thu Dec 17 15:36:06 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7