RTS API Documentation  1.10.11
Data Structures | Macros | Typedefs | Functions | Variables
switch_event.c File Reference
#include <switch.h>
#include "private/switch_core_pvt.h"
#include <switch_event.h>
+ Include dependency graph for switch_event.c:

Go to the source code of this file.

Data Structures

struct  switch_event_node
 A node to store binded events. More...
 
struct  switch_event_subclass
 A registered custom event subclass. More...
 
struct  switch_event_channel_sub_node_s
 
struct  switch_event_channel_sub_node_head_s
 
struct  event_channel_data_t
 
struct  alias_node_s
 
struct  la_node_s
 
struct  switch_live_array_s
 

Macros

#define DISPATCH_QUEUE_LEN   10000
 
#define MAX_DISPATCH_VAL   64
 
#define ALLOC(size)   malloc(size)
 
#define DUP(str)   my_dup(str)
 
#define FREE(ptr)   switch_safe_free(ptr)
 
#define SWITCH_SERIALIZED_EVENT_MAP   "S(iiisss)A(S(ss))"
 
#define resize(l)
 
#define SWITCH_CHANNEL_DISPATCH_MAX_KEY_PARTS   10
 

Typedefs

typedef struct switch_event_channel_sub_node_s switch_event_channel_sub_node_t
 
typedef struct switch_event_channel_sub_node_head_s switch_event_channel_sub_node_head_t
 
typedef struct alias_node_s alias_node_t
 
typedef struct la_node_s la_node_t
 

Functions

static void unsub_all_switch_event_channel (void)
 
static char * my_dup (const char *s)
 
static void free_header (switch_event_header_t **header)
 
static int switch_events_match (switch_event_t *event, switch_event_node_t *node)
 
static void *SWITCH_THREAD_FUNC switch_event_deliver_thread (switch_thread_t *thread, void *obj)
 
static void switch_event_deliver_thread_pool (switch_event_t **event)
 
static void *SWITCH_THREAD_FUNC switch_event_dispatch_thread (switch_thread_t *thread, void *obj)
 
static switch_status_t switch_event_queue_dispatch_event (switch_event_t **eventp)
 
void switch_event_deliver (switch_event_t **event)
 Deliver an event to all of the registered event listeners. More...
 
switch_status_t switch_event_running (void)
 Determine if the event system has been initialized. More...
 
const char * switch_event_name (switch_event_types_t event)
 Render the name of an event id enumeration. More...
 
switch_status_t switch_name_event (const char *name, switch_event_types_t *type)
 return the event id that matches a given event name More...
 
switch_status_t switch_event_free_subclass_detailed (const char *owner, const char *subclass_name)
 
switch_status_t switch_event_reserve_subclass_detailed (const char *owner, const char *subclass_name)
 Reserve a subclass name for private use with a custom event. More...
 
void switch_core_memory_reclaim_events (void)
 
switch_status_t switch_event_shutdown (void)
 Stop the eventing system. More...
 
static void check_dispatch (void)
 
void switch_event_launch_dispatch_threads (uint32_t max)
 
switch_status_t switch_event_init (switch_memory_pool_t *pool)
 Start the eventing system. More...
 
switch_status_t switch_event_create_subclass_detailed (const char *file, const char *func, int line, switch_event_t **event, switch_event_types_t event_id, const char *subclass_name)
 Create an event. More...
 
switch_status_t switch_event_set_priority (switch_event_t *event, switch_priority_t priority)
 Set the priority of an event. More...
 
switch_status_t switch_event_rename_header (switch_event_t *event, const char *header_name, const char *new_header_name)
 
switch_event_header_tswitch_event_get_header_ptr (switch_event_t *event, const char *header_name)
 Retrieve a header value from an event. More...
 
char * switch_event_get_header_idx (switch_event_t *event, const char *header_name, int idx)
 
char * switch_event_get_body (switch_event_t *event)
 Retrieve the body value from an event. More...
 
switch_status_t switch_event_del_header_val (switch_event_t *event, const char *header_name, const char *val)
 
static switch_event_header_tnew_header (const char *header_name)
 
int switch_event_add_array (switch_event_t *event, const char *var, const char *val)
 
static switch_status_t switch_event_base_add_header (switch_event_t *event, switch_stack_t stack, const char *header_name, char *data)
 
switch_status_t switch_event_add_header (switch_event_t *event, switch_stack_t stack, const char *header_name, const char *fmt,...)
 
switch_status_t switch_event_set_subclass_name (switch_event_t *event, const char *subclass_name)
 
switch_status_t switch_event_add_header_string_nodup (switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
 
switch_status_t switch_event_add_header_string (switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
 Add a string header to an event. More...
 
switch_status_t switch_event_set_body (switch_event_t *event, const char *body)
 
switch_status_t switch_event_add_body (switch_event_t *event, const char *fmt,...)
 
void switch_event_destroy (switch_event_t **event)
 Destroy an event. More...
 
void switch_event_merge (switch_event_t *event, switch_event_t *tomerge)
 
switch_status_t switch_event_dup (switch_event_t **event, switch_event_t *todup)
 Duplicate an event. More...
 
switch_status_t switch_event_dup_reply (switch_event_t **event, switch_event_t *todup)
 
switch_status_t switch_event_binary_deserialize (switch_event_t **eventp, void **data, switch_size_t len, switch_bool_t destroy)
 Render a string representation of an event suitable for printing or network transport. More...
 
switch_status_t switch_event_binary_serialize (switch_event_t *event, void **data, switch_size_t *len)
 
switch_status_t switch_event_serialize (switch_event_t *event, char **str, switch_bool_t encode)
 
switch_status_t switch_event_create_array_pair (switch_event_t **event, char **names, char **vals, int len)
 
switch_status_t switch_event_create_brackets (char *data, char a, char b, char c, switch_event_t **event, char **new_data, switch_bool_t dup)
 
switch_status_t switch_event_create_json (switch_event_t **event, const char *json)
 
switch_status_t switch_event_serialize_json_obj (switch_event_t *event, cJSON **json)
 
switch_status_t switch_event_serialize_json (switch_event_t *event, char **str)
 
static switch_xml_t add_xml_header (switch_xml_t xml, char *name, char *value, int offset)
 
switch_xml_t switch_event_xmlize (switch_event_t *event, const char *fmt,...)
 
void switch_event_prep_for_delivery_detailed (const char *file, const char *func, int line, switch_event_t *event)
 
switch_status_t switch_event_fire_detailed (const char *file, const char *func, int line, switch_event_t **event, void *user_data)
 Fire an event with full arguement list. More...
 
switch_status_t switch_event_get_custom_events (switch_console_callback_match_t **matches)
 
switch_status_t switch_event_bind_removable (const char *id, switch_event_types_t event, const char *subclass_name, switch_event_callback_t callback, void *user_data, switch_event_node_t **node)
 Bind an event callback to a specific event. More...
 
switch_status_t switch_event_bind (const char *id, switch_event_types_t event, const char *subclass_name, switch_event_callback_t callback, void *user_data)
 Bind an event callback to a specific event. More...
 
switch_status_t switch_event_unbind_callback (switch_event_callback_t callback)
 
switch_status_t switch_event_unbind (switch_event_node_t **node)
 Unbind a bound event consumer. More...
 
switch_status_t switch_event_create_pres_in_detailed (char *file, char *func, int line, const char *proto, const char *login, const char *from, const char *from_domain, const char *status, const char *event_type, const char *alt_event_type, int event_count, const char *unique_id, const char *channel_state, const char *answer_state, const char *call_direction)
 
char * switch_event_expand_headers_check (switch_event_t *event, const char *in, switch_event_t *var_list, switch_event_t *api_list, uint32_t recur)
 
char * switch_event_build_param_string (switch_event_t *event, const char *prefix, switch_hash_t *vars_map)
 
int switch_event_check_permission_list (switch_event_t *list, const char *name)
 
void switch_json_add_presence_data_cols (switch_event_t *event, cJSON *json, const char *prefix)
 
void switch_event_add_presence_data_cols (switch_channel_t *channel, switch_event_t *event, const char *prefix)
 
static uint32_t switch_event_channel_unsub_head (switch_event_channel_func_t func, switch_event_channel_sub_node_head_t *head, void *user_data)
 
static uint32_t switch_event_channel_unsub_channel (switch_event_channel_func_t func, const char *event_channel, void *user_data)
 
static switch_status_t switch_event_channel_sub_channel (const char *event_channel, switch_event_channel_func_t func, switch_event_channel_id_t id, void *user_data)
 
static uint32_t _switch_event_channel_broadcast (const char *event_channel, const char *broadcast_channel, cJSON *json, const char *key, switch_event_channel_id_t id)
 
static void destroy_ecd (event_channel_data_t **ecdP)
 
static void ecd_deliver (event_channel_data_t **ecdP)
 
static void *SWITCH_THREAD_FUNC switch_event_channel_deliver_thread (switch_thread_t *thread, void *obj)
 
switch_status_t switch_event_channel_broadcast (const char *event_channel, cJSON **json, const char *key, switch_event_channel_id_t id)
 
switch_status_t switch_event_channel_deliver (const char *event_channel, cJSON **json, const char *key, switch_event_channel_id_t id)
 
uint32_t switch_event_channel_unbind (const char *event_channel, switch_event_channel_func_t func, void *user_data)
 
switch_status_t switch_event_channel_bind (const char *event_channel, switch_event_channel_func_t func, switch_event_channel_id_t *id, void *user_data)
 
switch_bool_t switch_event_channel_permission_verify (const char *cookie, const char *event_channel)
 
void switch_event_channel_permission_modify (const char *cookie, const char *event_channel, switch_bool_t set)
 
void switch_event_channel_permission_clear (const char *cookie)
 
static switch_status_t la_broadcast (switch_live_array_t *la, cJSON **json)
 
switch_status_t switch_live_array_visible (switch_live_array_t *la, switch_bool_t visible, switch_bool_t force)
 
switch_status_t switch_live_array_clear (switch_live_array_t *la)
 
switch_status_t switch_live_array_bootstrap (switch_live_array_t *la, const char *sessid, switch_event_channel_id_t channel_id)
 
switch_status_t switch_live_array_destroy (switch_live_array_t **live_arrayP)
 
switch_bool_t switch_live_array_isnew (switch_live_array_t *la)
 
switch_bool_t switch_live_array_clear_alias (switch_live_array_t *la, const char *event_channel, const char *name)
 
switch_bool_t switch_live_array_add_alias (switch_live_array_t *la, const char *event_channel, const char *name)
 
switch_status_t switch_live_array_create (const char *event_channel, const char *name, switch_event_channel_id_t channel_id, switch_live_array_t **live_arrayP)
 
cJSONswitch_live_array_get (switch_live_array_t *la, const char *name)
 
cJSONswitch_live_array_get_idx (switch_live_array_t *la, int idx)
 
void switch_live_array_lock (switch_live_array_t *la)
 
void switch_live_array_unlock (switch_live_array_t *la)
 
switch_status_t switch_live_array_del (switch_live_array_t *la, const char *name)
 
switch_status_t switch_live_array_add (switch_live_array_t *la, const char *name, int index, cJSON **obj, switch_bool_t duplicate)
 
void switch_live_array_set_user_data (switch_live_array_t *la, void *user_data)
 
void switch_live_array_set_command_handler (switch_live_array_t *la, switch_live_array_command_handler_t command_handler)
 
void switch_live_array_parse_json (cJSON *json, switch_event_channel_id_t channel_id)
 

Variables

struct {
   switch_event_channel_id_t   ID
 
   switch_thread_rwlock_t *   rwlock
 
   switch_hash_t *   hash
 
   switch_hash_t *   perm_hash
 
   switch_hash_t *   lahash
 
   switch_mutex_t *   lamutex
 
event_channel_manager
 
static unsigned int MAX_DISPATCH = MAX_DISPATCH_VAL
 
static unsigned int SOFT_MAX_DISPATCH = 0
 
static char guess_ip_v4 [80] = ""
 
static char guess_ip_v6 [80] = ""
 
static switch_event_node_tEVENT_NODES [SWITCH_EVENT_ALL+1] = { NULL }
 
static switch_thread_rwlock_tRWLOCK = NULL
 
static switch_mutex_tBLOCK = NULL
 
static switch_mutex_tPOOL_LOCK = NULL
 
static switch_memory_pool_tRUNTIME_POOL = NULL
 
static switch_memory_pool_tTHRUNTIME_POOL = NULL
 
static switch_thread_tEVENT_DISPATCH_QUEUE_THREADS [MAX_DISPATCH_VAL] = { 0 }
 
static uint8_t EVENT_DISPATCH_QUEUE_RUNNING [MAX_DISPATCH_VAL] = { 0 }
 
static switch_queue_tEVENT_DISPATCH_QUEUE = NULL
 
static switch_queue_tEVENT_CHANNEL_DISPATCH_QUEUE = NULL
 
static switch_mutex_tEVENT_QUEUE_MUTEX = NULL
 
static switch_mutex_tCUSTOM_HASH_MUTEX = NULL
 
static switch_hash_tCUSTOM_HASH = NULL
 
static int THREAD_COUNT = 0
 
static int DISPATCH_THREAD_COUNT = 0
 
static int EVENT_CHANNEL_DISPATCH_THREAD_COUNT = 0
 
static int EVENT_CHANNEL_DISPATCH_THREAD_STARTING = 0
 
static int SYSTEM_RUNNING = 0
 
static uint64_t EVENT_SEQUENCE_NR = 0
 
static char * EVENT_NAMES []
 
static int PENDING = 0
 

Macro Definition Documentation

◆ ALLOC

#define ALLOC (   size)    malloc(size)

Definition at line 123 of file switch_event.c.

Referenced by new_header(), and switch_event_create_subclass_detailed().

◆ DISPATCH_QUEUE_LEN

#define DISPATCH_QUEUE_LEN   10000

◆ DUP

#define DUP (   str)    my_dup(str)

◆ FREE

#define FREE (   ptr)    switch_safe_free(ptr)

◆ MAX_DISPATCH_VAL

#define MAX_DISPATCH_VAL   64

Definition at line 82 of file switch_event.c.

Referenced by switch_event_dispatch_thread().

◆ resize

#define resize (   l)
Value:
{\
char *dp;\
olen += (len + l + block);\
cpos = c - data;\
if ((dp = realloc(data, olen))) {\
data = dp;\
c = data + cpos;\
memset(c, 0, olen - cpos);\
}} \

Definition at line 2241 of file switch_event.c.

Referenced by switch_event_expand_headers_check().

◆ SWITCH_CHANNEL_DISPATCH_MAX_KEY_PARTS

#define SWITCH_CHANNEL_DISPATCH_MAX_KEY_PARTS   10

Definition at line 2942 of file switch_event.c.

Referenced by ecd_deliver().

◆ SWITCH_SERIALIZED_EVENT_MAP

#define SWITCH_SERIALIZED_EVENT_MAP   "S(iiisss)A(S(ss))"

Typedef Documentation

◆ alias_node_t

typedef struct alias_node_s alias_node_t

◆ la_node_t

typedef struct la_node_s la_node_t

◆ switch_event_channel_sub_node_head_t

◆ switch_event_channel_sub_node_t

Function Documentation

◆ _switch_event_channel_broadcast()

static uint32_t _switch_event_channel_broadcast ( const char *  event_channel,
const char *  broadcast_channel,
cJSON json,
const char *  key,
switch_event_channel_id_t  id 
)
static

Definition at line 2903 of file switch_event.c.

References event_channel_manager, switch_event_channel_sub_node_s::func, switch_event_channel_sub_node_s::id, switch_event_channel_sub_node_s::next, switch_event_channel_sub_node_head_s::node, switch_core_hash_find(), switch_thread_rwlock_rdlock(), switch_thread_rwlock_unlock(), and switch_event_channel_sub_node_s::user_data.

Referenced by ecd_deliver().

2905 {
2908  uint32_t x = 0;
2909 
2911  if ((head = switch_core_hash_find(event_channel_manager.hash, event_channel))) {
2912  for (np = head->node; np; np = np->next) {
2913  if (np->id == id) {
2914  continue;
2915  }
2916 
2917  np->func(broadcast_channel, json, key, id, np->user_data);
2918  x++;
2919  }
2920  }
2922 
2923  return x;
2924 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:286
void * switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key)
Retrieve data from a given hash.
static struct @5 event_channel_manager
switch_event_channel_id_t id
switch_status_t switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:250
switch_event_channel_sub_node_t * node
switch_event_channel_func_t func
char * key
Definition: switch_msrp.c:64
struct switch_event_channel_sub_node_s * next

◆ add_xml_header()

static switch_xml_t add_xml_header ( switch_xml_t  xml,
char *  name,
char *  value,
int  offset 
)
static

Definition at line 1872 of file switch_event.c.

References memset(), switch_assert, switch_url_encode(), switch_xml_add_child_d(), and switch_xml_set_txt_d().

Referenced by switch_event_xmlize().

1873 {
1874  switch_xml_t header = switch_xml_add_child_d(xml, name, offset);
1875 
1876  if (header) {
1877  switch_size_t encode_len = (strlen(value) * 3) + 1;
1878  char *encode_buf = malloc(encode_len);
1879 
1880  switch_assert(encode_buf);
1881 
1882  memset(encode_buf, 0, encode_len);
1883  switch_url_encode((char *) value, encode_buf, encode_len);
1884  switch_xml_set_txt_d(header, encode_buf);
1885  free(encode_buf);
1886  }
1887 
1888  return header;
1889 }
switch_xml_t switch_xml_add_child_d(_In_ switch_xml_t xml, _In_z_ const char *name, _In_ switch_size_t off)
wrapper for switch_xml_add_child() that strdup()s name
const char *const const char *const const cJSON *const value
A representation of an XML tree.
Definition: switch_xml.h:79
char * switch_url_encode(const char *url, char *buf, size_t len)
switch_xml_t switch_xml_set_txt_d(switch_xml_t xml, const char *txt)
wrapper for switch_xml_set_txt() that strdup()s txt \ sets the character content for the given tag an...
Definition: switch_xml.c:3005
uintptr_t switch_size_t
const char *const name
Definition: switch_cJSON.h:250
#define switch_assert(expr)
memset(buf, 0, buflen)

◆ check_dispatch()

static void check_dispatch ( void  )
static

Definition at line 634 of file switch_event.c.

References BLOCK, DISPATCH_QUEUE_LEN, MAX_DISPATCH, switch_cond_next(), switch_event_launch_dispatch_threads(), switch_mutex_lock(), switch_mutex_unlock(), switch_queue_create(), THREAD_COUNT, and THRUNTIME_POOL.

Referenced by switch_event_fire_detailed(), switch_event_init(), and switch_event_launch_dispatch_threads().

635 {
636  if (!EVENT_DISPATCH_QUEUE) {
638 
639  if (!EVENT_DISPATCH_QUEUE) {
642 
643  while (!THREAD_COUNT) {
645  }
646  }
648  }
649 }
static unsigned int MAX_DISPATCH
Definition: switch_event.c:83
#define DISPATCH_QUEUE_LEN
Definition: switch_event.c:44
void switch_event_launch_dispatch_threads(uint32_t max)
Definition: switch_event.c:653
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
static switch_queue_t * EVENT_DISPATCH_QUEUE
Definition: switch_event.c:95
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
static int THREAD_COUNT
Definition: switch_event.c:100
static switch_mutex_t * BLOCK
Definition: switch_event.c:89
void switch_cond_next(void)
Definition: switch_time.c:658
static switch_memory_pool_t * THRUNTIME_POOL
Definition: switch_event.c:92
switch_status_t switch_queue_create(switch_queue_t **queue, unsigned int queue_capacity, switch_memory_pool_t *pool)
Definition: switch_apr.c:1233

◆ destroy_ecd()

static void destroy_ecd ( event_channel_data_t **  ecdP)
static

Definition at line 2926 of file switch_event.c.

References event_channel_data_t::event_channel, event_channel_data_t::json, event_channel_data_t::key, and switch_safe_free.

Referenced by ecd_deliver(), switch_event_channel_broadcast(), and switch_event_channel_deliver_thread().

2927 {
2928  event_channel_data_t *ecd = *ecdP;
2929  *ecdP = NULL;
2930 
2932  switch_safe_free(ecd->key);
2933  if (ecd->json) {
2934  cJSON_Delete(ecd->json);
2935  ecd->json = NULL;
2936  }
2937 
2938  free(ecd);
2939 }
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885

◆ ecd_deliver()

static void ecd_deliver ( event_channel_data_t **  ecdP)
static

Definition at line 2945 of file switch_event.c.

References _switch_event_channel_broadcast(), buf, destroy_ecd(), event_channel_data_t::event_channel, event_channel_data_t::id, event_channel_data_t::json, key, event_channel_data_t::key, memset(), SCF_EVENT_CHANNEL_ENABLE_HIERARCHY_DELIVERY, SCF_EVENT_CHANNEL_HIERARCHY_DELIVERY_ONCE, SCF_EVENT_CHANNEL_LOG_UNDELIVERABLE_JSON, SWITCH_CHANNEL_DISPATCH_MAX_KEY_PARTS, SWITCH_CHANNEL_LOG, switch_core_get_event_channel_key_separator(), switch_core_test_flag(), SWITCH_EVENT_CHANNEL_GLOBAL, SWITCH_LOG_DEBUG1, switch_log_printf(), SWITCH_LOG_WARNING, switch_safe_free, switch_separate_string_string(), and switch_snprintf().

Referenced by switch_event_channel_deliver(), and switch_event_channel_deliver_thread().

2946 {
2947  event_channel_data_t *ecd = *ecdP;
2948  char *key;
2949  uint32_t t = 0;
2950 
2951  *ecdP = NULL;
2952 
2953  t = _switch_event_channel_broadcast(ecd->event_channel, ecd->event_channel, ecd->json, ecd->key, ecd->id);
2954 
2955  key = strdup(ecd->event_channel);
2957  const char *sep = switch_core_get_event_channel_key_separator();
2958  char *x_argv[SWITCH_CHANNEL_DISPATCH_MAX_KEY_PARTS] = { 0 };
2959  int x_argc = switch_separate_string_string(key, (char*) sep, x_argv, SWITCH_CHANNEL_DISPATCH_MAX_KEY_PARTS);
2960  char buf[1024];
2961  int i, r;
2962 
2963  for(i=x_argc - 1; i > 0; i--) {
2964  int z;
2965 
2966  memset(buf, 0, 1024);
2967  switch_snprintf(buf, sizeof(buf), "%s", x_argv[0]);
2968  for(z=1; z < i; z++) {
2969  strcat(buf, sep);
2970  strncat(buf, x_argv[z], sizeof(buf) - strlen(buf) - 1);
2971  }
2972 
2973  r = _switch_event_channel_broadcast(buf, ecd->event_channel, ecd->json, ecd->key, ecd->id);
2974  t += r;
2976  break;
2977  }
2978  }
2979  } else {
2980  char *p = NULL;
2981 
2982  if ((p = strchr(key, '.'))) {
2983  *p = '\0';
2984  t += _switch_event_channel_broadcast(key, ecd->event_channel, ecd->json, ecd->key, ecd->id);
2985  }
2986  }
2987 
2988  switch_safe_free(key);
2989 
2991 
2992  if(t == 0) {
2994  char *json = cJSON_Print(ecd->json);
2995 
2996  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no subscribers for %s , %s => %s\n", ecd->event_channel, ecd->key, json);
2997  switch_safe_free(json);
2998  } else {
2999  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no subscribers for %s , %s\n", ecd->event_channel, ecd->key);
3000  }
3001  } else {
3002  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "delivered to %u subscribers for %s\n", t, ecd->event_channel);
3003  }
3004 
3005  destroy_ecd(&ecd);
3006 }
#define SWITCH_CHANNEL_LOG
int switch_core_test_flag(int flag)
Definition: switch_core.c:1792
unsigned int switch_separate_string_string(char *buf, char *delim, _Post_count_(return) char **array, unsigned int arraylen)
static uint32_t _switch_event_channel_broadcast(const char *event_channel, const char *broadcast_channel, cJSON *json, const char *key, switch_event_channel_id_t id)
switch_event_channel_id_t id
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
#define SWITCH_CHANNEL_DISPATCH_MAX_KEY_PARTS
static void destroy_ecd(event_channel_data_t **ecdP)
switch_byte_t switch_byte_t * buf
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
const char * switch_core_get_event_channel_key_separator(void)
Definition: switch_core.c:3592
#define SWITCH_EVENT_CHANNEL_GLOBAL
Definition: switch_event.h:440
char * key
Definition: switch_msrp.c:64
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
memset(buf, 0, buflen)

◆ free_header()

static void free_header ( switch_event_header_t **  header)
static

Definition at line 931 of file switch_event.c.

References FREE, SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, switch_log_printf(), switch_queue_trypush(), and SWITCH_STATUS_SUCCESS.

Referenced by switch_event_base_add_header(), switch_event_del_header_val(), and switch_event_destroy().

932 {
933  assert(header);
934 
935  if (*header) {
936  if ((*header)->idx) {
937  if (!(*header)->array) {
938  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "INDEX WITH NO ARRAY ?? [%s][%s]\n", (*header)->name, (*header)->value);
939  } else {
940  int i = 0;
941 
942  for (i = 0; i < (*header)->idx; i++) {
943  FREE((*header)->array[i]);
944  }
945  FREE((*header)->array);
946  }
947  }
948 
949  FREE((*header)->name);
950  FREE((*header)->value);
951 
952 #ifdef SWITCH_EVENT_RECYCLE
953  if (switch_queue_trypush(EVENT_HEADER_RECYCLE_QUEUE, *header) != SWITCH_STATUS_SUCCESS) {
954  FREE(*header);
955  }
956 #else
957  FREE(*header);
958 #endif
959  }
960 }
#define SWITCH_CHANNEL_LOG
#define FREE(ptr)
Definition: switch_event.c:129
switch_status_t switch_queue_trypush(switch_queue_t *queue, void *data)
Definition: switch_apr.c:1279
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.

◆ la_broadcast()

static switch_status_t la_broadcast ( switch_live_array_t la,
cJSON **  json 
)
static

Definition at line 3231 of file switch_event.c.

References switch_live_array_s::aliases, switch_live_array_s::channel_id, alias_node_s::event_channel, switch_live_array_s::event_channel, switch_live_array_s::mutex, alias_node_s::name, alias_node_s::next, switch_event_channel_broadcast(), switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_live_array_add(), switch_live_array_clear(), switch_live_array_del(), and switch_live_array_visible().

3232 {
3233  alias_node_t *np;
3234 
3235  if (la->aliases) {
3236  switch_mutex_lock(la->mutex);
3237  for (np = la->aliases; np; np = np->next) {
3238  cJSON *dup = cJSON_Duplicate(*json, 1);
3239  cJSON *data = cJSON_GetObjectItem(dup, "data");
3240 
3241  cJSON_ReplaceItemInObject(dup, "eventChannel", cJSON_CreateString(np->event_channel));
3242  cJSON_ReplaceItemInObject(data, "name", cJSON_CreateString(np->name));
3243 
3244  switch_event_channel_broadcast(np->event_channel, &dup, __FILE__, la->channel_id);
3245  }
3247  }
3248 
3249  return switch_event_channel_broadcast(la->event_channel, json, __FILE__, la->channel_id);
3250 
3251 }
struct alias_node_s * next
char * event_channel
switch_status_t switch_event_channel_broadcast(const char *event_channel, cJSON **json, const char *key, switch_event_channel_id_t id)
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
alias_node_t * aliases
switch_event_channel_id_t channel_id
switch_mutex_t * mutex

◆ my_dup()

static char* my_dup ( const char *  s)
static

Definition at line 113 of file switch_event.c.

References switch_assert.

114 {
115  size_t len = strlen(s) + 1;
116  void *new = malloc(len);
117  switch_assert(new);
118 
119  return (char *) memcpy(new, s, len);
120 }
#define switch_assert(expr)

◆ new_header()

static switch_event_header_t* new_header ( const char *  header_name)
static

Definition at line 908 of file switch_event.c.

References ALLOC, DUP, memset(), switch_event_header::name, switch_assert, switch_queue_trypop(), and SWITCH_STATUS_SUCCESS.

Referenced by switch_event_base_add_header().

909 {
910  switch_event_header_t *header;
911 
912 #ifdef SWITCH_EVENT_RECYCLE
913  void *pop;
914  if (EVENT_HEADER_RECYCLE_QUEUE && switch_queue_trypop(EVENT_HEADER_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS) {
915  header = (switch_event_header_t *) pop;
916  } else {
917 #endif
918  header = ALLOC(sizeof(*header));
919  switch_assert(header);
920 #ifdef SWITCH_EVENT_RECYCLE
921  }
922 #endif
923 
924  memset(header, 0, sizeof(*header));
925  header->name = DUP(header_name);
926 
927  return header;
928 
929 }
An event Header.
Definition: switch_event.h:65
switch_status_t switch_queue_trypop(switch_queue_t *queue, void **data)
Definition: switch_apr.c:1264
#define ALLOC(size)
Definition: switch_event.c:123
#define DUP(str)
Definition: switch_event.c:126
#define switch_assert(expr)
memset(buf, 0, buflen)

◆ switch_event_add_body()

switch_status_t switch_event_add_body ( switch_event_t event,
const char *  fmt,
  ... 
)

Definition at line 1266 of file switch_event.c.

References switch_event::body, switch_safe_free, SWITCH_STATUS_GENERR, SWITCH_STATUS_SUCCESS, and switch_vasprintf().

Referenced by switch_event_create_json().

1267 {
1268  int ret = 0;
1269  char *data;
1270 
1271  va_list ap;
1272  if (fmt) {
1273  va_start(ap, fmt);
1274  ret = switch_vasprintf(&data, fmt, ap);
1275  va_end(ap);
1276 
1277  if (ret == -1) {
1278  return SWITCH_STATUS_GENERR;
1279  } else {
1280  switch_safe_free(event->body);
1281  event->body = data;
1282  return SWITCH_STATUS_SUCCESS;
1283  }
1284  } else {
1285  return SWITCH_STATUS_GENERR;
1286  }
1287 }
int cJSON_bool fmt
Definition: switch_cJSON.h:150
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
int switch_vasprintf(_Out_opt_ char **buf, _In_z_ _Printf_format_string_ const char *format, _In_ va_list ap)

◆ switch_event_add_header()

switch_status_t switch_event_add_header ( switch_event_t event,
switch_stack_t  stack,
const char *  header_name,
const char *  fmt,
  ... 
)

Definition at line 1210 of file switch_event.c.

References switch_event_base_add_header(), SWITCH_STATUS_MEMERR, and switch_vasprintf().

Referenced by switch_event_create_pres_in_detailed(), and switch_event_prep_for_delivery_detailed().

1211 {
1212  int ret = 0;
1213  char *data;
1214  va_list ap;
1215 
1216  va_start(ap, fmt);
1217  ret = switch_vasprintf(&data, fmt, ap);
1218  va_end(ap);
1219 
1220  if (ret == -1) {
1221  return SWITCH_STATUS_MEMERR;
1222  }
1223 
1224  return switch_event_base_add_header(event, stack, header_name, data);
1225 }
int cJSON_bool fmt
Definition: switch_cJSON.h:150
int switch_vasprintf(_Out_opt_ char **buf, _In_z_ _Printf_format_string_ const char *format, _In_ va_list ap)
static switch_status_t switch_event_base_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, char *data)

◆ switch_event_base_add_header()

static switch_status_t switch_event_base_add_header ( switch_event_t event,
switch_stack_t  stack,
const char *  header_name,
char *  data 
)
static

Definition at line 1005 of file switch_event.c.

References switch_event_header::array, DUP, EF_UNIQ_HEADERS, FREE, free_header(), switch_event_header::hash, switch_event_header::idx, index, switch_event::last_header, switch_event_header::name, new_header(), switch_event_header::next, switch_assert, switch_ci_hashfunc_default(), switch_event_add_array(), switch_event_del_header, switch_event_get_header_ptr(), switch_event_set_body(), switch_safe_free, switch_snprintf(), SWITCH_STACK_BOTTOM, SWITCH_STACK_PUSH, SWITCH_STACK_TOP, SWITCH_STACK_UNSHIFT, SWITCH_STATUS_SUCCESS, switch_test_flag, switch_event_header::value, and zstr.

Referenced by switch_event_add_header(), switch_event_add_header_string(), and switch_event_add_header_string_nodup().

1006 {
1007  switch_event_header_t *header = NULL;
1008  switch_ssize_t hlen = -1;
1009  int exists = 0, fly = 0;
1010  char *index_ptr;
1011  int index = 0;
1012  char *real_header_name = NULL;
1013 
1014 
1015  if (!strcmp(header_name, "_body")) {
1016  switch_event_set_body(event, data);
1017  }
1018 
1019  if ((index_ptr = strchr(header_name, '['))) {
1020  index_ptr++;
1021  index = atoi(index_ptr);
1022  real_header_name = DUP(header_name);
1023  if ((index_ptr = strchr(real_header_name, '['))) {
1024  *index_ptr++ = '\0';
1025  }
1026  header_name = real_header_name;
1027  }
1028 
1029  if (index_ptr || (stack & SWITCH_STACK_PUSH) || (stack & SWITCH_STACK_UNSHIFT)) {
1030  switch_event_header_t *tmp_header = NULL;
1031 
1032  if (!(header = switch_event_get_header_ptr(event, header_name)) && index_ptr) {
1033 
1034  tmp_header = header = new_header(header_name);
1035 
1036  if (switch_test_flag(event, EF_UNIQ_HEADERS)) {
1037  switch_event_del_header(event, header_name);
1038  }
1039 
1040  fly++;
1041  }
1042 
1043  if (header || (header = switch_event_get_header_ptr(event, header_name))) {
1044 
1045  if (index_ptr) {
1046  if (index > -1 && index <= 4000) {
1047  if (index < header->idx) {
1048  FREE(header->array[index]);
1049  header->array[index] = DUP(data);
1050  } else {
1051  int i;
1052  char **m;
1053 
1054  m = realloc(header->array, sizeof(char *) * (index + 1));
1055  switch_assert(m);
1056  header->array = m;
1057  for (i = header->idx; i < index; i++) {
1058  m[i] = DUP("");
1059  }
1060  m[index] = DUP(data);
1061  header->idx = index + 1;
1062  if (!fly) {
1063  exists = 1;
1064  }
1065 
1066  FREE(data);
1067  goto redraw;
1068  }
1069  } else if (tmp_header) {
1070  free_header(&tmp_header);
1071  }
1072 
1073  FREE(data);
1074  goto end;
1075  } else {
1076  if ((stack & SWITCH_STACK_PUSH) || (stack & SWITCH_STACK_UNSHIFT)) {
1077  exists++;
1078  stack &= ~(SWITCH_STACK_TOP | SWITCH_STACK_BOTTOM);
1079  } else {
1080  header = NULL;
1081  }
1082  }
1083  }
1084  }
1085 
1086 
1087  if (!header) {
1088 
1089  if (zstr(data)) {
1090  switch_event_del_header(event, header_name);
1091  FREE(data);
1092  goto end;
1093  }
1094 
1095  if (switch_test_flag(event, EF_UNIQ_HEADERS)) {
1096  switch_event_del_header(event, header_name);
1097  }
1098 
1099  if (!strncmp(data, "ARRAY::", 7)) {
1100  switch_event_add_array(event, header_name, data);
1101  FREE(data);
1102  goto end;
1103  }
1104 
1105 
1106  header = new_header(header_name);
1107  }
1108 
1109  if ((stack & SWITCH_STACK_PUSH) || (stack & SWITCH_STACK_UNSHIFT)) {
1110  char **m = NULL;
1111  switch_size_t len = 0;
1112  char *hv;
1113  int i = 0, j = 0;
1114 
1115  if (header->value && !header->idx) {
1116  m = malloc(sizeof(char *));
1117  switch_assert(m);
1118  m[0] = header->value;
1119  header->value = NULL;
1120  header->array = m;
1121  header->idx++;
1122  m = NULL;
1123  }
1124 
1125  i = header->idx + 1;
1126  m = realloc(header->array, sizeof(char *) * i);
1127  switch_assert(m);
1128 
1129  if ((stack & SWITCH_STACK_PUSH)) {
1130  m[header->idx] = data;
1131  } else if ((stack & SWITCH_STACK_UNSHIFT)) {
1132  for (j = header->idx; j > 0; j--) {
1133  m[j] = m[j-1];
1134  }
1135  m[0] = data;
1136  }
1137 
1138  header->idx++;
1139  header->array = m;
1140 
1141  redraw:
1142  len = 0;
1143  for(j = 0; j < header->idx; j++) {
1144  len += 2;
1145  if (!header->array[j]) {
1146  continue;
1147  }
1148  len += strlen(header->array[j]);
1149  }
1150 
1151  if (len) {
1152  len += 8;
1153  hv = realloc(header->value, len);
1154  switch_assert(hv);
1155  header->value = hv;
1156 
1157  if (header->idx > 1) {
1158  switch_snprintf(header->value, len, "ARRAY::");
1159  } else {
1160  *header->value = '\0';
1161  }
1162 
1163  hv += strlen(header->value);
1164  for(j = 0; j < header->idx; j++) {
1165  if (j > 0) {
1166  memcpy(hv, "|:", 2);
1167  hv += 2;
1168  }
1169  if (!header->array[j]) {
1170  continue;
1171  }
1172  memcpy(hv, header->array[j], strlen(header->array[j]));
1173  hv += strlen(header->array[j]);
1174  }
1175  *hv = '\0';
1176  }
1177 
1178  } else {
1179  switch_safe_free(header->value);
1180  header->value = data;
1181  }
1182 
1183  if (!exists) {
1184  header->hash = switch_ci_hashfunc_default(header->name, &hlen);
1185 
1186  if ((stack & SWITCH_STACK_TOP)) {
1187  header->next = event->headers;
1188  event->headers = header;
1189  if (!event->last_header) {
1190  event->last_header = header;
1191  }
1192  } else {
1193  if (event->last_header) {
1194  event->last_header->next = header;
1195  } else {
1196  event->headers = header;
1197  header->next = NULL;
1198  }
1199  event->last_header = header;
1200  }
1201  }
1202 
1203  end:
1204 
1205  switch_safe_free(real_header_name);
1206 
1207  return SWITCH_STATUS_SUCCESS;
1208 }
#define switch_event_del_header(_e, _h)
Definition: switch_event.h:212
int switch_event_add_array(switch_event_t *event, const char *var, const char *val)
Definition: switch_event.c:962
An event Header.
Definition: switch_event.h:65
unsigned int switch_ci_hashfunc_default(const char *char_key, switch_ssize_t *klen)
Definition: switch_apr.c:121
switch_event_header_t * last_header
Definition: switch_event.h:92
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
#define zstr(x)
Definition: switch_utils.h:314
#define FREE(ptr)
Definition: switch_event.c:129
intptr_t switch_ssize_t
int index
Definition: switch_cJSON.h:160
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
static switch_event_header_t * new_header(const char *header_name)
Definition: switch_event.c:908
uintptr_t switch_size_t
static void free_header(switch_event_header_t **header)
Definition: switch_event.c:931
struct switch_event_header * next
Definition: switch_event.h:76
#define DUP(str)
Definition: switch_event.c:126
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:693
switch_status_t switch_event_set_body(switch_event_t *event, const char *body)
#define switch_assert(expr)
switch_event_header_t * switch_event_get_header_ptr(switch_event_t *event, const char *header_name)
Retrieve a header value from an event.
Definition: switch_event.c:825
unsigned long hash
Definition: switch_event.h:75

◆ switch_event_channel_deliver_thread()

static void* SWITCH_THREAD_FUNC switch_event_channel_deliver_thread ( switch_thread_t thread,
void *  obj 
)
static

Definition at line 3008 of file switch_event.c.

References destroy_ecd(), ecd_deliver(), EVENT_CHANNEL_DISPATCH_THREAD_COUNT, EVENT_CHANNEL_DISPATCH_THREAD_STARTING, EVENT_QUEUE_MUTEX, SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_os_yield(), switch_queue_pop(), switch_queue_trypop(), SWITCH_STATUS_SUCCESS, SYSTEM_RUNNING, and THREAD_COUNT.

Referenced by switch_event_channel_broadcast().

3009 {
3010  switch_queue_t *queue = (switch_queue_t *) obj;
3011  void *pop = NULL;
3012  event_channel_data_t *ecd = NULL;
3013 
3015  THREAD_COUNT++;
3019 
3020  while(SYSTEM_RUNNING) {
3021 
3022  if (switch_queue_pop(queue, &pop) != SWITCH_STATUS_SUCCESS) {
3023  continue;
3024  }
3025 
3026  if (!pop) {
3027  break;
3028  }
3029 
3030  ecd = (event_channel_data_t *) pop;
3031  ecd_deliver(&ecd);
3032  switch_os_yield();
3033  }
3034 
3035  while (switch_queue_trypop(queue, &pop) == SWITCH_STATUS_SUCCESS) {
3036  ecd = (event_channel_data_t *) pop;
3037  destroy_ecd(&ecd);
3038  }
3039 
3041  THREAD_COUNT--;
3044 
3045  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Event Channel Dispatch Thread Ended.\n");
3046  return NULL;
3047 }
#define SWITCH_CHANNEL_LOG
static int SYSTEM_RUNNING
Definition: switch_event.c:104
switch_status_t switch_queue_trypop(switch_queue_t *queue, void **data)
Definition: switch_apr.c:1264
switch_status_t switch_queue_pop(switch_queue_t *queue, void **data)
Definition: switch_apr.c:1243
static int EVENT_CHANNEL_DISPATCH_THREAD_STARTING
Definition: switch_event.c:103
static void destroy_ecd(event_channel_data_t **ecdP)
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
void switch_os_yield(void)
Definition: switch_time.c:142
static void ecd_deliver(event_channel_data_t **ecdP)
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
static int THREAD_COUNT
Definition: switch_event.c:100
static switch_mutex_t * EVENT_QUEUE_MUTEX
Definition: switch_event.c:97
static int EVENT_CHANNEL_DISPATCH_THREAD_COUNT
Definition: switch_event.c:102
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.

◆ switch_event_channel_sub_channel()

static switch_status_t switch_event_channel_sub_channel ( const char *  event_channel,
switch_event_channel_func_t  func,
switch_event_channel_id_t  id,
void *  user_data 
)
static

Definition at line 2836 of file switch_event.c.

References switch_event_channel_sub_node_head_s::event_channel, event_channel_manager, switch_event_channel_sub_node_s::func, switch_event_channel_sub_node_s::head, switch_event_node::id, switch_event_channel_sub_node_s::id, switch_event_channel_sub_node_s::next, switch_event_channel_sub_node_head_s::node, switch_core_hash_find(), switch_core_hash_insert, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_thread_rwlock_unlock(), switch_thread_rwlock_wrlock(), switch_zmalloc, switch_event_channel_sub_node_head_s::tail, switch_event_node::user_data, and switch_event_channel_sub_node_s::user_data.

Referenced by switch_event_channel_bind().

2838 {
2842 
2844 
2845  if (!(head = switch_core_hash_find(event_channel_manager.hash, event_channel))) {
2846  switch_zmalloc(head, sizeof(*head));
2847  head->event_channel = strdup(event_channel);
2848  switch_core_hash_insert(event_channel_manager.hash, event_channel, head);
2849 
2850  switch_zmalloc(node, sizeof(*node));
2851  node->func = func;
2852  node->user_data = user_data;
2853  node->id = id;
2854 
2855  node->head = head;
2856  head->node = node;
2857  head->tail = node;
2858  status = SWITCH_STATUS_SUCCESS;
2859  } else {
2860  int exist = 0;
2861 
2862  for (np = head->node; np; np = np->next) {
2863  if (np->func == func && np->user_data == user_data) {
2864  exist = 1;
2865  break;
2866  }
2867  }
2868 
2869  if (!exist) {
2870  switch_zmalloc(node, sizeof(*node));
2871 
2872  node->func = func;
2873  node->user_data = user_data;
2874  node->id = id;
2875  node->head = head;
2876 
2877 
2878  if (!head->node) {
2879  head->node = node;
2880  head->tail = node;
2881  } else {
2882  head->tail->next = node;
2883  head->tail = head->tail->next;
2884  }
2885  status = SWITCH_STATUS_SUCCESS;
2886  }
2887  }
2888 
2890 
2891  return status;
2892 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:286
void * switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key)
Retrieve data from a given hash.
static struct @5 event_channel_manager
switch_event_channel_id_t id
struct switch_event_channel_sub_node_head_s * head
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:260
switch_event_channel_sub_node_t * node
switch_event_channel_func_t func
#define switch_zmalloc(ptr, len)
switch_status_t
Common return values.
switch_event_channel_sub_node_t * tail
#define switch_core_hash_insert(_h, _k, _d)
Definition: switch_core.h:1479
struct switch_event_channel_sub_node_s * next

◆ switch_event_channel_unsub_channel()

static uint32_t switch_event_channel_unsub_channel ( switch_event_channel_func_t  func,
const char *  event_channel,
void *  user_data 
)
static

Definition at line 2805 of file switch_event.c.

References event_channel_manager, switch_core_hash_find(), switch_core_hash_first, switch_core_hash_next(), switch_core_hash_this(), switch_event_channel_unsub_head(), switch_thread_rwlock_unlock(), and switch_thread_rwlock_wrlock().

Referenced by switch_event_channel_unbind().

2806 {
2808  uint32_t x = 0;
2809 
2811 
2812  if (!event_channel) {
2813  switch_hash_index_t *hi;
2814  void *val;
2815 
2816  for (hi = switch_core_hash_first(event_channel_manager.hash); hi; hi = switch_core_hash_next(&hi)) {
2817  switch_core_hash_this(hi, NULL, NULL, &val);
2818 
2819  if (val) {
2820  head = (switch_event_channel_sub_node_head_t *) val;
2821  x += switch_event_channel_unsub_head(func, head, user_data);
2822  }
2823  }
2824 
2825  } else {
2826  if ((head = switch_core_hash_find(event_channel_manager.hash, event_channel))) {
2827  x += switch_event_channel_unsub_head(func, head, user_data);
2828  }
2829  }
2830 
2832 
2833  return x;
2834 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:286
void * switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key)
Retrieve data from a given hash.
static struct @5 event_channel_manager
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:260
static uint32_t switch_event_channel_unsub_head(switch_event_channel_func_t func, switch_event_channel_sub_node_head_t *head, void *user_data)
void switch_core_hash_this(_In_ switch_hash_index_t *hi, _Out_opt_ptrdiff_cap_(klen) const void **key, _Out_opt_ switch_ssize_t *klen, _Out_ void **val)
Gets the key and value of the current hash element.
switch_hash_index_t * switch_core_hash_next(_In_ switch_hash_index_t **hi)
Gets the next element of a hashtable.
#define switch_core_hash_first(_h)
Definition: switch_core.h:1592

◆ switch_event_channel_unsub_head()

static uint32_t switch_event_channel_unsub_head ( switch_event_channel_func_t  func,
switch_event_channel_sub_node_head_t head,
void *  user_data 
)
static

Definition at line 2738 of file switch_event.c.

References switch_event_channel_sub_node_head_s::event_channel, switch_event_channel_sub_node_s::func, switch_event_channel_sub_node_s::head, switch_event_channel_sub_node_s::next, switch_event_channel_sub_node_head_s::node, SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, switch_log_printf(), switch_event_channel_sub_node_head_s::tail, and switch_event_channel_sub_node_s::user_data.

Referenced by switch_event_channel_unsub_channel(), and unsub_all_switch_event_channel().

2739 {
2740  uint32_t x = 0;
2741 
2742  switch_event_channel_sub_node_t *thisnp = NULL, *np, *last = NULL;
2743 
2744  np = head->tail = head->node;
2745 
2746  while (np) {
2747 
2748  thisnp = np;
2749  np = np->next;
2750 
2751  if (!(func) || (thisnp->func == func && (thisnp->user_data == user_data || user_data == NULL))) {
2752  x++;
2753 
2754  if (last) {
2755  last->next = np;
2756  } else {
2757  head->node = np;
2758  }
2759 
2760 
2761  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "UNSUBBING %p [%s]\n", (void *)(intptr_t)thisnp->func, thisnp->head->event_channel);
2762 
2763 
2764  thisnp->func = NULL;
2765  free(thisnp);
2766  } else {
2767  last = thisnp;
2768  head->tail = last;
2769  }
2770  }
2771 
2772  return x;
2773 }
#define SWITCH_CHANNEL_LOG
struct switch_event_channel_sub_node_head_s * head
switch_event_channel_sub_node_t * node
switch_event_channel_func_t func
switch_event_channel_sub_node_t * tail
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
struct switch_event_channel_sub_node_s * next

◆ switch_event_create_pres_in_detailed()

switch_status_t switch_event_create_pres_in_detailed ( char *  file,
char *  func,
int  line,
const char *  proto,
const char *  login,
const char *  from,
const char *  from_domain,
const char *  status,
const char *  event_type,
const char *  alt_event_type,
int  event_count,
const char *  unique_id,
const char *  channel_state,
const char *  answer_state,
const char *  call_direction 
)

Definition at line 2213 of file switch_event.c.

References switch_event_add_header(), switch_event_add_header_string(), switch_event_create_subclass, switch_event_fire_detailed(), SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, SWITCH_STACK_TOP, SWITCH_STATUS_MEMERR, and SWITCH_STATUS_SUCCESS.

2220 {
2221  switch_event_t *pres_event;
2222 
2224  switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "proto", proto);
2225  switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "login", login);
2226  switch_event_add_header(pres_event, SWITCH_STACK_TOP, "from", "%s@%s", from, from_domain);
2227  switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "status", status);
2228  switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "event_type", event_type);
2229  switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "alt_event_type", alt_event_type);
2230  switch_event_add_header(pres_event, SWITCH_STACK_TOP, "event_count", "%d", event_count);
2231  switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "unique-id", alt_event_type);
2232  switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "channel-state", channel_state);
2233  switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "answer-state", answer_state);
2234  switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "presence-call-direction", call_direction);
2235  switch_event_fire_detailed(file, func, line, &pres_event, NULL);
2236  return SWITCH_STATUS_SUCCESS;
2237  }
2238  return SWITCH_STATUS_MEMERR;
2239 }
#define SWITCH_EVENT_SUBCLASS_ANY
Definition: switch_event.h:128
Representation of an event.
Definition: switch_event.h:80
#define switch_event_create_subclass(_e, _eid, _sn)
Definition: switch_event.h:153
switch_status_t switch_event_fire_detailed(const char *file, const char *func, int line, switch_event_t **event, void *user_data)
Fire an event with full arguement list.
switch_status_t switch_event_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *fmt,...)
switch_status_t switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
Add a string header to an event.

◆ switch_event_deliver_thread()

static void* SWITCH_THREAD_FUNC switch_event_deliver_thread ( switch_thread_t thread,
void *  obj 
)
static

Definition at line 272 of file switch_event.c.

References switch_event_deliver().

Referenced by switch_event_deliver_thread_pool().

273 {
274  switch_event_t *event = (switch_event_t *) obj;
275 
276  switch_event_deliver(&event);
277 
278  return NULL;
279 }
Representation of an event.
Definition: switch_event.h:80
void switch_event_deliver(switch_event_t **event)
Deliver an event to all of the registered event listeners.
Definition: switch_event.c:400

◆ switch_event_deliver_thread_pool()

static void switch_event_deliver_thread_pool ( switch_event_t **  event)
static

Definition at line 281 of file switch_event.c.

References switch_thread_data_s::alloc, switch_thread_data_s::func, switch_thread_data_s::obj, switch_thread_data_s::pool, switch_assert, switch_event_deliver_thread(), and switch_thread_pool_launch_thread().

Referenced by switch_event_fire_detailed().

282 {
284 
285  td = malloc(sizeof(*td));
286  switch_assert(td);
287 
288  td->alloc = 1;
290  td->obj = *event;
291  td->pool = NULL;
292 
293  *event = NULL;
294 
296 
297 }
switch_memory_pool_t * pool
Definition: switch_core.h:71
switch_thread_start_t func
Definition: switch_core.h:67
#define switch_assert(expr)
static void *SWITCH_THREAD_FUNC switch_event_deliver_thread(switch_thread_t *thread, void *obj)
Definition: switch_event.c:272
switch_status_t switch_thread_pool_launch_thread(switch_thread_data_t **tdp)

◆ switch_event_dispatch_thread()

static void* SWITCH_THREAD_FUNC switch_event_dispatch_thread ( switch_thread_t thread,
void *  obj 
)
static

Definition at line 299 of file switch_event.c.

References DISPATCH_THREAD_COUNT, EVENT_DISPATCH_QUEUE_RUNNING, EVENT_DISPATCH_QUEUE_THREADS, EVENT_QUEUE_MUTEX, MAX_DISPATCH_VAL, SWITCH_CHANNEL_LOG, switch_event_deliver(), SWITCH_LOG_CONSOLE, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_os_yield(), switch_queue_pop(), SWITCH_STATUS_SUCCESS, SYSTEM_RUNNING, and THREAD_COUNT.

Referenced by switch_event_launch_dispatch_threads().

300 {
301  switch_queue_t *queue = (switch_queue_t *) obj;
302  int my_id = 0;
303 
305  THREAD_COUNT++;
307 
308  for (my_id = 0; my_id < MAX_DISPATCH_VAL; my_id++) {
309  if (EVENT_DISPATCH_QUEUE_THREADS[my_id] == thread) {
310  break;
311  }
312  }
313 
314  if ( my_id >= MAX_DISPATCH_VAL ) {
316  return NULL;
317  }
318 
319  EVENT_DISPATCH_QUEUE_RUNNING[my_id] = 1;
321 
322 
323  for (;;) {
324  void *pop = NULL;
325  switch_event_t *event = NULL;
326 
327  if (!SYSTEM_RUNNING) {
328  break;
329  }
330 
331  if (switch_queue_pop(queue, &pop) != SWITCH_STATUS_SUCCESS) {
332  continue;
333  }
334 
335  if (!pop) {
336  break;
337  }
338 
339  event = (switch_event_t *) pop;
340  switch_event_deliver(&event);
341  switch_os_yield();
342  }
343 
344 
346  EVENT_DISPATCH_QUEUE_RUNNING[my_id] = 0;
347  THREAD_COUNT--;
350 
351  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Dispatch Thread %d Ended.\n", my_id);
352  return NULL;
353 
354 }
#define SWITCH_CHANNEL_LOG
static uint8_t EVENT_DISPATCH_QUEUE_RUNNING[MAX_DISPATCH_VAL]
Definition: switch_event.c:94
static int SYSTEM_RUNNING
Definition: switch_event.c:104
#define MAX_DISPATCH_VAL
Definition: switch_event.c:82
Representation of an event.
Definition: switch_event.h:80
switch_status_t switch_queue_pop(switch_queue_t *queue, void **data)
Definition: switch_apr.c:1243
static switch_thread_t * thread
Definition: switch_log.c:486
static switch_thread_t * EVENT_DISPATCH_QUEUE_THREADS[MAX_DISPATCH_VAL]
Definition: switch_event.c:93
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
void switch_os_yield(void)
Definition: switch_time.c:142
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
static int THREAD_COUNT
Definition: switch_event.c:100
void switch_event_deliver(switch_event_t **event)
Deliver an event to all of the registered event listeners.
Definition: switch_event.c:400
static switch_mutex_t * EVENT_QUEUE_MUTEX
Definition: switch_event.c:97
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
static int DISPATCH_THREAD_COUNT
Definition: switch_event.c:101

◆ switch_event_queue_dispatch_event()

static switch_status_t switch_event_queue_dispatch_event ( switch_event_t **  eventp)
static

Definition at line 358 of file switch_event.c.

References DISPATCH_QUEUE_LEN, DISPATCH_THREAD_COUNT, EVENT_QUEUE_MUTEX, MAX_DISPATCH, PENDING, SOFT_MAX_DISPATCH, switch_event_launch_dispatch_threads(), switch_mutex_lock(), switch_mutex_unlock(), switch_queue_push(), switch_queue_size(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and SYSTEM_RUNNING.

Referenced by switch_event_fire_detailed().

359 {
360 
361  switch_event_t *event = *eventp;
362 
363  if (!SYSTEM_RUNNING) {
364  return SWITCH_STATUS_FALSE;
365  }
366 
367  while (event) {
368  int launch = 0;
369 
371 
373  if (SOFT_MAX_DISPATCH + 1 < MAX_DISPATCH) {
374  launch++;
375  PENDING++;
376  }
377  }
378 
380 
381  if (launch) {
382  if (SOFT_MAX_DISPATCH + 1 < MAX_DISPATCH) {
384  }
385 
387  PENDING--;
389  }
390 
391  *eventp = NULL;
393  event = NULL;
394 
395  }
396 
397  return SWITCH_STATUS_SUCCESS;
398 }
unsigned int switch_queue_size(switch_queue_t *queue)
Definition: switch_apr.c:1238
static unsigned int MAX_DISPATCH
Definition: switch_event.c:83
static int SYSTEM_RUNNING
Definition: switch_event.c:104
#define DISPATCH_QUEUE_LEN
Definition: switch_event.c:44
static unsigned int SOFT_MAX_DISPATCH
Definition: switch_event.c:84
Representation of an event.
Definition: switch_event.h:80
void switch_event_launch_dispatch_threads(uint32_t max)
Definition: switch_event.c:653
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
static switch_queue_t * EVENT_DISPATCH_QUEUE
Definition: switch_event.c:95
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
static int PENDING
Definition: switch_event.c:356
static switch_mutex_t * EVENT_QUEUE_MUTEX
Definition: switch_event.c:97
switch_status_t switch_queue_push(switch_queue_t *queue, void *data)
Definition: switch_apr.c:1253
static int DISPATCH_THREAD_COUNT
Definition: switch_event.c:101

◆ switch_event_xmlize()

switch_xml_t switch_event_xmlize ( switch_event_t event,
const char *  fmt,
  ... 
)

Definition at line 1891 of file switch_event.c.

References add_xml_header(), switch_event_header::array, switch_event::body, switch_event::headers, switch_event_header::idx, switch_event_header::name, switch_event_header::next, switch_snprintf(), switch_xml_add_child_d(), switch_xml_free(), switch_xml_new(), switch_xml_set_txt_d(), switch_event_header::value, and zstr.

1892 {
1894  char *data = NULL, *body = NULL;
1895  int ret = 0;
1896  switch_xml_t xml = NULL;
1897  uint32_t off = 0;
1898  va_list ap;
1899  switch_xml_t xheaders = NULL;
1900 
1901  if (!(xml = switch_xml_new("event"))) {
1902  return xml;
1903  }
1904 
1905  if (!zstr(fmt)) {
1906  va_start(ap, fmt);
1907 #ifdef HAVE_VASPRINTF
1908  ret = vasprintf(&data, fmt, ap);
1909 #else
1910  data = (char *) malloc(2048);
1911  if (!data) {
1912  va_end(ap);
1913  switch_xml_free(xml);
1914 
1915  return NULL;
1916  }
1917  ret = vsnprintf(data, 2048, fmt, ap);
1918 #endif
1919  va_end(ap);
1920  if (ret == -1) {
1921 #ifndef HAVE_VASPRINTF
1922  free(data);
1923 #endif
1924  switch_xml_free(xml);
1925 
1926  return NULL;
1927  }
1928  }
1929 
1930  if ((xheaders = switch_xml_add_child_d(xml, "headers", off++))) {
1931  int hoff = 0;
1932  for (hp = event->headers; hp; hp = hp->next) {
1933 
1934  if (hp->idx) {
1935  int i;
1936  for (i = 0; i < hp->idx; i++) {
1937  add_xml_header(xheaders, hp->name, hp->array[i], hoff++);
1938  }
1939  } else {
1940  add_xml_header(xheaders, hp->name, hp->value, hoff++);
1941  }
1942  }
1943  }
1944 
1945  if (!zstr(data)) {
1946  body = data;
1947  } else if (event->body) {
1948  body = event->body;
1949  }
1950 
1951  if (body) {
1952  int blen = (int) strlen(body);
1953  char blena[25];
1954  switch_snprintf(blena, sizeof(blena), "%d", blen);
1955  if (blen) {
1956  switch_xml_t xbody = NULL;
1957 
1958  add_xml_header(xml, "Content-Length", blena, off++);
1959  if ((xbody = switch_xml_add_child_d(xml, "body", off++))) {
1960  switch_xml_set_txt_d(xbody, body);
1961  }
1962  }
1963  }
1964 
1965  if (data) {
1966  free(data);
1967  }
1968 
1969  return xml;
1970 }
switch_xml_t switch_xml_add_child_d(_In_ switch_xml_t xml, _In_z_ const char *name, _In_ switch_size_t off)
wrapper for switch_xml_add_child() that strdup()s name
void switch_xml_free(_In_opt_ switch_xml_t xml)
frees the memory allocated for an switch_xml structure
static switch_xml_t add_xml_header(switch_xml_t xml, char *name, char *value, int offset)
An event Header.
Definition: switch_event.h:65
A representation of an XML tree.
Definition: switch_xml.h:79
switch_xml_t switch_xml_set_txt_d(switch_xml_t xml, const char *txt)
wrapper for switch_xml_set_txt() that strdup()s txt \ sets the character content for the given tag an...
Definition: switch_xml.c:3005
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
#define zstr(x)
Definition: switch_utils.h:314
int cJSON_bool fmt
Definition: switch_cJSON.h:150
switch_xml_t switch_xml_new(_In_opt_z_ const char *name)
returns a new empty switch_xml structure with the given root tag name
struct switch_event_header * next
Definition: switch_event.h:76
switch_event_header_t * headers
Definition: switch_event.h:90

◆ switch_events_match()

static int switch_events_match ( switch_event_t event,
switch_event_node_t node 
)
static

Definition at line 233 of file switch_event.c.

References switch_event_node::event_id, switch_event::event_id, switch_event_node::subclass_name, switch_event::subclass_name, SWITCH_EVENT_ALL, and switch_event_get_header.

Referenced by switch_event_deliver().

234 {
235  int match = 0;
236 
237  if (node->event_id == SWITCH_EVENT_ALL) {
238  match++;
239 
240  if (!node->subclass_name) {
241  return match;
242  }
243  }
244 
245  if (match || event->event_id == node->event_id) {
246 
247  if (event->subclass_name && node->subclass_name) {
248  if (!strncasecmp(node->subclass_name, "file:", 5)) {
249  char *file_header;
250  if ((file_header = switch_event_get_header(event, "file")) != 0) {
251  match = !strcmp(node->subclass_name + 5, file_header) ? 1 : 0;
252  }
253  } else if (!strncasecmp(node->subclass_name, "func:", 5)) {
254  char *func_header;
255  if ((func_header = switch_event_get_header(event, "function")) != 0) {
256  match = !strcmp(node->subclass_name + 5, func_header) ? 1 : 0;
257  }
258  } else if (event->subclass_name && node->subclass_name) {
259  match = !strcmp(event->subclass_name, node->subclass_name) ? 1 : 0;
260  }
261  } else if ((event->subclass_name && !node->subclass_name) || (!event->subclass_name && !node->subclass_name)) {
262  match = 1;
263  } else {
264  match = 0;
265  }
266  }
267 
268  return match;
269 }
switch_event_types_t event_id
Definition: switch_event.h:82
switch_event_types_t event_id
Definition: switch_event.c:52
#define switch_event_get_header(_e, _h)
Definition: switch_event.h:172
char * subclass_name
Definition: switch_event.h:88

◆ unsub_all_switch_event_channel()

static void unsub_all_switch_event_channel ( void  )
static

Definition at line 2775 of file switch_event.c.

References switch_event_channel_sub_node_head_s::event_channel, event_channel_manager, switch_core_hash_delete(), switch_core_hash_first_iter(), switch_core_hash_this(), switch_event_channel_unsub_head(), switch_event_destroy(), switch_safe_free, switch_thread_rwlock_unlock(), and switch_thread_rwlock_wrlock().

Referenced by switch_event_shutdown().

2776 {
2777  switch_hash_index_t *hi = NULL;
2778  const void *var;
2779  void *val;
2781 
2783 
2784  while ((hi = switch_core_hash_first_iter( event_channel_manager.perm_hash, hi))) {
2785  switch_event_t *vals = NULL;
2786  switch_core_hash_this(hi, &var, NULL, &val);
2787  vals = (switch_event_t *) val;
2789  switch_event_destroy(&vals);
2790  }
2791 
2792  while ((hi = switch_core_hash_first_iter( event_channel_manager.hash, hi))) {
2793  switch_core_hash_this(hi, NULL, NULL, &val);
2794  head = (switch_event_channel_sub_node_head_t *) val;
2795  switch_event_channel_unsub_head(NULL, head, NULL);
2797  free(head->event_channel);
2798  free(head);
2799  }
2800 
2801  switch_safe_free(hi);
2803 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:286
static struct @5 event_channel_manager
Representation of an event.
Definition: switch_event.h:80
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:260
static uint32_t switch_event_channel_unsub_head(switch_event_channel_func_t func, switch_event_channel_sub_node_head_t *head, void *user_data)
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
void switch_core_hash_this(_In_ switch_hash_index_t *hi, _Out_opt_ptrdiff_cap_(klen) const void **key, _Out_opt_ switch_ssize_t *klen, _Out_ void **val)
Gets the key and value of the current hash element.
void * switch_core_hash_delete(_In_ switch_hash_t *hash, _In_z_ const char *key)
Delete data from a hash based on desired key.
void switch_event_destroy(switch_event_t **event)
Destroy an event.
switch_hash_index_t * switch_core_hash_first_iter(_In_ switch_hash_t *hash, switch_hash_index_t *hi)
Gets the first element of a hashtable.

Variable Documentation

◆ BLOCK

switch_mutex_t* BLOCK = NULL
static

◆ CUSTOM_HASH

switch_hash_t* CUSTOM_HASH = NULL
static

Definition at line 99 of file switch_event.c.

◆ CUSTOM_HASH_MUTEX

switch_mutex_t* CUSTOM_HASH_MUTEX = NULL
static

◆ DISPATCH_THREAD_COUNT

int DISPATCH_THREAD_COUNT = 0
static

◆ EVENT_CHANNEL_DISPATCH_QUEUE

switch_queue_t* EVENT_CHANNEL_DISPATCH_QUEUE = NULL
static

Definition at line 96 of file switch_event.c.

Referenced by switch_event_channel_broadcast().

◆ EVENT_CHANNEL_DISPATCH_THREAD_COUNT

int EVENT_CHANNEL_DISPATCH_THREAD_COUNT = 0
static

◆ EVENT_CHANNEL_DISPATCH_THREAD_STARTING

int EVENT_CHANNEL_DISPATCH_THREAD_STARTING = 0
static

◆ event_channel_manager

struct { ... } event_channel_manager

◆ EVENT_DISPATCH_QUEUE

switch_queue_t* EVENT_DISPATCH_QUEUE = NULL
static

Definition at line 95 of file switch_event.c.

◆ EVENT_DISPATCH_QUEUE_RUNNING

uint8_t EVENT_DISPATCH_QUEUE_RUNNING[MAX_DISPATCH_VAL] = { 0 }
static

◆ EVENT_DISPATCH_QUEUE_THREADS

switch_thread_t* EVENT_DISPATCH_QUEUE_THREADS[MAX_DISPATCH_VAL] = { 0 }
static

◆ EVENT_NAMES

char* EVENT_NAMES[]
static

Definition at line 137 of file switch_event.c.

Referenced by switch_event_name(), and switch_name_event().

◆ EVENT_NODES

switch_event_node_t* EVENT_NODES[SWITCH_EVENT_ALL+1] = { NULL }
static

Definition at line 87 of file switch_event.c.

◆ EVENT_QUEUE_MUTEX

switch_mutex_t* EVENT_QUEUE_MUTEX = NULL
static

◆ EVENT_SEQUENCE_NR

uint64_t EVENT_SEQUENCE_NR = 0
static

Definition at line 105 of file switch_event.c.

Referenced by switch_event_prep_for_delivery_detailed().

◆ guess_ip_v4

char guess_ip_v4[80] = ""
static

Definition at line 85 of file switch_event.c.

Referenced by switch_event_init(), and switch_event_prep_for_delivery_detailed().

◆ guess_ip_v6

char guess_ip_v6[80] = ""
static

Definition at line 86 of file switch_event.c.

Referenced by switch_event_init(), and switch_event_prep_for_delivery_detailed().

◆ hash

◆ ID

Definition at line 74 of file switch_event.c.

◆ lahash

switch_hash_t* lahash

Definition at line 78 of file switch_event.c.

◆ lamutex

switch_mutex_t* lamutex

Definition at line 79 of file switch_event.c.

◆ MAX_DISPATCH

unsigned int MAX_DISPATCH = MAX_DISPATCH_VAL
static

◆ PENDING

int PENDING = 0
static

Definition at line 356 of file switch_event.c.

Referenced by switch_event_queue_dispatch_event().

◆ perm_hash

switch_hash_t* perm_hash

Definition at line 77 of file switch_event.c.

◆ POOL_LOCK

switch_mutex_t* POOL_LOCK = NULL
static

Definition at line 90 of file switch_event.c.

Referenced by switch_event_init().

◆ RUNTIME_POOL

switch_memory_pool_t* RUNTIME_POOL = NULL
static

◆ rwlock

Definition at line 75 of file switch_event.c.

◆ RWLOCK

switch_thread_rwlock_t* RWLOCK = NULL
static

◆ SOFT_MAX_DISPATCH

unsigned int SOFT_MAX_DISPATCH = 0
static

◆ SYSTEM_RUNNING

int SYSTEM_RUNNING = 0
static

◆ THREAD_COUNT

int THREAD_COUNT = 0
static

◆ THRUNTIME_POOL

switch_memory_pool_t* THRUNTIME_POOL = NULL
static