diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index 861f84640c..5337a4a890 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Fri Dec 30 15:29:04 CST 2016 +Thu Feb 9 17:36:33 CST 2017 diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c index 2aee664111..6db2523320 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c @@ -25,7 +25,7 @@ #define WS_NOBLOCK 0 #define SHA1_HASH_SIZE 20 -struct ws_globals_s ws_globals; +static struct ws_globals_s ws_globals; #ifndef WSS_STANDALONE diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/ws.h b/libs/sofia-sip/libsofia-sip-ua/tport/ws.h index 83a6890cca..43283c61ac 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/ws.h +++ b/libs/sofia-sip/libsofia-sip-ua/tport/ws.h @@ -61,7 +61,7 @@ struct ws_globals_s { char key[512]; }; -extern struct ws_globals_s ws_globals; +//extern struct ws_globals_s ws_globals; #ifndef WIN32 typedef int ws_socket_t; diff --git a/src/mod/applications/mod_avmd/mod_avmd.c b/src/mod/applications/mod_avmd/mod_avmd.c index 5a5e7ffe2e..63d60e6f27 100644 --- a/src/mod/applications/mod_avmd/mod_avmd.c +++ b/src/mod/applications/mod_avmd/mod_avmd.c @@ -187,7 +187,7 @@ typedef struct { size_t sample_count; } avmd_session_t; -struct avmd_globals +static struct avmd_globals { switch_mutex_t *mutex; struct avmd_settings settings; diff --git a/src/mod/applications/mod_oreka/mod_oreka.c b/src/mod/applications/mod_oreka/mod_oreka.c index a21f227b2a..5cccdeb511 100644 --- a/src/mod/applications/mod_oreka/mod_oreka.c +++ b/src/mod/applications/mod_oreka/mod_oreka.c @@ -60,7 +60,7 @@ typedef struct oreka_session_s { int mux_streams; } oreka_session_t; -struct { +static struct { char local_ipv4_str[256]; char sip_server_addr_str[256]; char sip_server_ipv4_str[256]; diff --git a/src/mod/applications/mod_sms_flowroute/mod_sms_flowroute.c b/src/mod/applications/mod_sms_flowroute/mod_sms_flowroute.c index 3d7d42484b..d432024515 100644 --- a/src/mod/applications/mod_sms_flowroute/mod_sms_flowroute.c +++ b/src/mod/applications/mod_sms_flowroute/mod_sms_flowroute.c @@ -35,7 +35,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sms_flowroute_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sms_flowroute_shutdown); SWITCH_MODULE_DEFINITION(mod_sms_flowroute, mod_sms_flowroute_load, mod_sms_flowroute_shutdown, NULL); -mod_sms_flowroute_globals_t mod_sms_flowroute_globals; +static mod_sms_flowroute_globals_t mod_sms_flowroute_globals; static void on_accept(h2o_socket_t *listener, const char *error) { diff --git a/src/mod/applications/mod_spy/mod_spy.c b/src/mod/applications/mod_spy/mod_spy.c index fd213ffec4..646fc012ea 100644 --- a/src/mod/applications/mod_spy/mod_spy.c +++ b/src/mod/applications/mod_spy/mod_spy.c @@ -38,7 +38,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spy_load); SWITCH_MODULE_DEFINITION(mod_spy, mod_spy_load, mod_spy_shutdown, NULL); -struct mod_spy_globals { +static struct mod_spy_globals { switch_memory_pool_t *pool; switch_event_node_t *node; switch_hash_t *spy_hash; diff --git a/src/mod/endpoints/mod_h323/mod_h323.cpp b/src/mod/endpoints/mod_h323/mod_h323.cpp index 514bff5a6e..4f4c112857 100644 --- a/src/mod/endpoints/mod_h323/mod_h323.cpp +++ b/src/mod/endpoints/mod_h323/mod_h323.cpp @@ -47,7 +47,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_rtp_timer_name, mod_h323_globals.rt #define CF_NEED_FLUSH (1 << 1) -struct mod_h323_globals mod_h323_globals = { 0 }; +static struct mod_h323_globals mod_h323_globals = { 0 }; static switch_call_cause_t create_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event, switch_caller_profile_t *outbound_profile, switch_core_session_t **new_session, diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index 3a39801cc5..9239f9ea19 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -43,7 +43,7 @@ SWITCH_MODULE_DEFINITION(mod_skinny, mod_skinny_load, mod_skinny_shutdown, NULL) switch_endpoint_interface_t *skinny_endpoint_interface; -skinny_globals_t globals; +skinny_globals_t skinny_globals; /*****************************************************************************/ /* SQL TABLES */ @@ -188,9 +188,9 @@ switch_status_t skinny_profile_dump(const skinny_profile_t *profile, switch_stre skinny_profile_t *skinny_find_profile(const char *profile_name) { skinny_profile_t *profile; - switch_mutex_lock(globals.mutex); - profile = (skinny_profile_t *) switch_core_hash_find(globals.profile_hash, profile_name); - switch_mutex_unlock(globals.mutex); + switch_mutex_lock(skinny_globals.mutex); + profile = (skinny_profile_t *) switch_core_hash_find(skinny_globals.profile_hash, profile_name); + switch_mutex_unlock(skinny_globals.mutex); return profile; } @@ -201,8 +201,8 @@ skinny_profile_t *skinny_find_profile_by_domain(const char *domain_name) void *val; skinny_profile_t *profile = NULL, *tmp_profile; - switch_mutex_lock(globals.mutex); - for (hi = switch_core_hash_first(globals.profile_hash); hi; hi = switch_core_hash_next(&hi)) { + switch_mutex_lock(skinny_globals.mutex); + for (hi = switch_core_hash_first(skinny_globals.profile_hash); hi; hi = switch_core_hash_next(&hi)) { switch_core_hash_this(hi, NULL, NULL, &val); tmp_profile = (skinny_profile_t *) val; @@ -216,7 +216,7 @@ skinny_profile_t *skinny_find_profile_by_domain(const char *domain_name) } } switch_safe_free(hi); - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(skinny_globals.mutex); return profile; } @@ -1469,7 +1469,7 @@ switch_io_routines_t skinny_io_routines = { uint8_t listener_is_ready(listener_t *listener) { - return globals.running + return skinny_globals.running && listener && listener->sock && switch_test_flag(listener, LFLAG_RUNNING) @@ -1520,14 +1520,14 @@ static void walk_listeners(skinny_listener_callback_func_t callback, void *pvt) skinny_profile_t *profile; /* walk listeners */ - switch_mutex_lock(globals.mutex); - for (hi = switch_core_hash_first(globals.profile_hash); hi; hi = switch_core_hash_next(&hi)) { + switch_mutex_lock(skinny_globals.mutex); + for (hi = switch_core_hash_first(skinny_globals.profile_hash); hi; hi = switch_core_hash_next(&hi)) { switch_core_hash_this(hi, NULL, NULL, &val); profile = (skinny_profile_t *) val; profile_walk_listeners(profile, callback, pvt); } - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(skinny_globals.mutex); } static int flush_listener_callback(void *pArg, int argc, char **argv, char **columnNames) @@ -2017,7 +2017,7 @@ static void *SWITCH_THREAD_FUNC skinny_profile_run(switch_thread_t *thread, void } new_socket: - while(globals.running && !profile->sock) { + while(skinny_globals.running && !profile->sock) { char *listening_ip = NULL; switch_clear_flag_locked(profile, PFLAG_RESPAWN); rv = switch_sockaddr_info_get(&sa, profile->ip, SWITCH_UNSPEC, profile->port, 0, tmp_pool); @@ -2053,7 +2053,7 @@ sock_fail: switch_set_flag_locked(profile, PFLAG_LISTENER_READY); - while(globals.running) { + while(skinny_globals.running) { if (switch_core_new_memory_pool(&listener_pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "OH OH no pool\n"); @@ -2063,7 +2063,7 @@ sock_fail: assert(profile->sock); if ((rv = switch_socket_accept(&inbound_socket, profile->sock, listener_pool))) { - if (!globals.running) { + if (!skinny_globals.running) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Shutting Down\n"); goto end; } else if (switch_test_flag(profile, PFLAG_RESPAWN)) { @@ -2253,7 +2253,7 @@ static switch_status_t load_skinny_config(void) return SWITCH_STATUS_TERM; } - switch_mutex_lock(globals.mutex); + switch_mutex_lock(skinny_globals.mutex); if ((xprofiles = switch_xml_child(xcfg, "profiles"))) { for (xprofile = switch_xml_child(xprofiles, "profile"); xprofile; xprofile = xprofile->next) { char *profile_name = (char *) switch_xml_attr_soft(xprofile, "name"); @@ -2450,7 +2450,7 @@ static switch_status_t load_skinny_config(void) skinny_profile_respawn(profile, 0); /* Register profile */ - switch_core_hash_insert(globals.profile_hash, profile->name, profile); + switch_core_hash_insert(skinny_globals.profile_hash, profile->name, profile); profile = NULL; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, @@ -2459,7 +2459,7 @@ static switch_status_t load_skinny_config(void) } /* profile */ } switch_xml_free(xml); - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(skinny_globals.mutex); return SWITCH_STATUS_SUCCESS; } @@ -2679,7 +2679,7 @@ static void skinny_trap_event_handler(switch_event_t *event) const char *cond = switch_event_get_header(event, "condition"); - if (cond && !strcmp(cond, "network-address-change") && globals.auto_restart) { + if (cond && !strcmp(cond, "network-address-change") && skinny_globals.auto_restart) { const char *old_ip4 = switch_event_get_header_nil(event, "network-address-previous-v4"); const char *new_ip4 = switch_event_get_header_nil(event, "network-address-change-v4"); const char *old_ip6 = switch_event_get_header_nil(event, "network-address-previous-v6"); @@ -2692,9 +2692,9 @@ static void skinny_trap_event_handler(switch_event_t *event) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "EVENT_TRAP: IP change detected\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "IP change detected [%s]->[%s] [%s]->[%s]\n", old_ip4, new_ip4, old_ip6, new_ip6); - switch_mutex_lock(globals.mutex); - if (globals.profile_hash) { - for (hi = switch_core_hash_first(globals.profile_hash); hi; hi = switch_core_hash_next(&hi)) { + switch_mutex_lock(skinny_globals.mutex); + if (skinny_globals.profile_hash) { + for (hi = switch_core_hash_first(skinny_globals.profile_hash); hi; hi = switch_core_hash_next(&hi)) { switch_core_hash_this(hi, &var, NULL, &val); if ((profile = (skinny_profile_t *) val) && profile->auto_restart) { if (!strcmp(profile->ip, old_ip4)) { @@ -2706,7 +2706,7 @@ static void skinny_trap_event_handler(switch_event_t *event) } } } - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(skinny_globals.mutex); } } @@ -2715,45 +2715,45 @@ static void skinny_trap_event_handler(switch_event_t *event) SWITCH_MODULE_LOAD_FUNCTION(mod_skinny_load) { switch_hash_index_t *hi; - /* globals init */ - memset(&globals, 0, sizeof(globals)); + /* skinny_globals init */ + memset(&skinny_globals, 0, sizeof(skinny_globals)); - if (switch_core_new_memory_pool(&globals.pool) != SWITCH_STATUS_SUCCESS) { + if (switch_core_new_memory_pool(&skinny_globals.pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "OH OH no pool\n"); return SWITCH_STATUS_TERM; } - switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool); + switch_mutex_init(&skinny_globals.mutex, SWITCH_MUTEX_NESTED, skinny_globals.pool); - switch_mutex_lock(globals.mutex); - switch_core_hash_init(&globals.profile_hash); - globals.running = 1; - globals.auto_restart = SWITCH_TRUE; - switch_mutex_unlock(globals.mutex); + switch_mutex_lock(skinny_globals.mutex); + switch_core_hash_init(&skinny_globals.profile_hash); + skinny_globals.running = 1; + skinny_globals.auto_restart = SWITCH_TRUE; + switch_mutex_unlock(skinny_globals.mutex); /* load_skinny_config does it's own locking */ load_skinny_config(); - switch_mutex_lock(globals.mutex); + switch_mutex_lock(skinny_globals.mutex); /* at least one profile */ - if (switch_core_hash_empty( globals.profile_hash)) { + if (switch_core_hash_empty( skinny_globals.profile_hash)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No profile found!\n"); return SWITCH_STATUS_TERM; } /* bind to events */ - if ((switch_event_bind_removable(modname, SWITCH_EVENT_CUSTOM, SKINNY_EVENT_CALL_STATE, skinny_call_state_event_handler, NULL, &globals.call_state_node) != SWITCH_STATUS_SUCCESS)) { + if ((switch_event_bind_removable(modname, SWITCH_EVENT_CUSTOM, SKINNY_EVENT_CALL_STATE, skinny_call_state_event_handler, NULL, &skinny_globals.call_state_node) != SWITCH_STATUS_SUCCESS)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind our call_state handler!\n"); return SWITCH_STATUS_TERM; } - if ((switch_event_bind_removable(modname, SWITCH_EVENT_MESSAGE_WAITING, NULL, skinny_message_waiting_event_handler, NULL, &globals.message_waiting_node) != SWITCH_STATUS_SUCCESS)) { + if ((switch_event_bind_removable(modname, SWITCH_EVENT_MESSAGE_WAITING, NULL, skinny_message_waiting_event_handler, NULL, &skinny_globals.message_waiting_node) != SWITCH_STATUS_SUCCESS)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Couldn't bind our message waiting handler!\n"); /* Not such severe to prevent loading */ } - if ((switch_event_bind_removable(modname, SWITCH_EVENT_TRAP, NULL, skinny_trap_event_handler, NULL, &globals.trap_node) != SWITCH_STATUS_SUCCESS)) { + if ((switch_event_bind_removable(modname, SWITCH_EVENT_TRAP, NULL, skinny_trap_event_handler, NULL, &skinny_globals.trap_node) != SWITCH_STATUS_SUCCESS)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Couldn't bind our trap handler!\n"); /* Not such severe to prevent loading */ } - if ((switch_event_bind_removable(modname, SWITCH_EVENT_CUSTOM, SKINNY_EVENT_USER_TO_DEVICE, skinny_user_to_device_event_handler, NULL, &globals.user_to_device_node) != SWITCH_STATUS_SUCCESS)) { + if ((switch_event_bind_removable(modname, SWITCH_EVENT_CUSTOM, SKINNY_EVENT_USER_TO_DEVICE, skinny_user_to_device_event_handler, NULL, &skinny_globals.user_to_device_node) != SWITCH_STATUS_SUCCESS)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind our user_to_device handler!\n"); /* Not such severe to prevent loading */ } @@ -2789,7 +2789,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skinny_load) } /* connect my internal structure to the blank pointer passed to me */ - *module_interface = switch_loadable_module_create_module_interface(globals.pool, modname); + *module_interface = switch_loadable_module_create_module_interface(skinny_globals.pool, modname); skinny_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE); skinny_endpoint_interface->interface_name = "skinny"; skinny_endpoint_interface->io_routines = &skinny_io_routines; @@ -2798,7 +2798,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skinny_load) skinny_api_register(module_interface); /* launch listeners */ - for (hi = switch_core_hash_first(globals.profile_hash); hi; hi = switch_core_hash_next(&hi)) { + for (hi = switch_core_hash_first(skinny_globals.profile_hash); hi; hi = switch_core_hash_next(&hi)) { void *val; skinny_profile_t *profile; @@ -2807,7 +2807,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skinny_load) launch_skinny_profile_thread(profile); } - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(skinny_globals.mutex); /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; @@ -2817,17 +2817,17 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skinny_shutdown) { switch_hash_index_t *hi; void *val; - switch_memory_pool_t *pool = globals.pool; - switch_mutex_t *mutex = globals.mutex; + switch_memory_pool_t *pool = skinny_globals.pool; + switch_mutex_t *mutex = skinny_globals.mutex; int sanity = 0; skinny_api_unregister(); /* release events */ - switch_event_unbind(&globals.user_to_device_node); - switch_event_unbind(&globals.call_state_node); - switch_event_unbind(&globals.message_waiting_node); - switch_event_unbind(&globals.trap_node); + switch_event_unbind(&skinny_globals.user_to_device_node); + switch_event_unbind(&skinny_globals.call_state_node); + switch_event_unbind(&skinny_globals.message_waiting_node); + switch_event_unbind(&skinny_globals.trap_node); switch_event_free_subclass(SKINNY_EVENT_REGISTER); switch_event_free_subclass(SKINNY_EVENT_UNREGISTER); switch_event_free_subclass(SKINNY_EVENT_EXPIRE); @@ -2838,14 +2838,14 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skinny_shutdown) switch_mutex_lock(mutex); - globals.running = 0; + skinny_globals.running = 0; /* kill listeners */ walk_listeners(kill_listener, NULL); /* close sockets */ - switch_mutex_lock(globals.mutex); - for (hi = switch_core_hash_first(globals.profile_hash); hi; hi = switch_core_hash_next(&hi)) { + switch_mutex_lock(skinny_globals.mutex); + for (hi = switch_core_hash_first(skinny_globals.profile_hash); hi; hi = switch_core_hash_next(&hi)) { skinny_profile_t *profile; switch_core_hash_this(hi, NULL, NULL, &val); profile = (skinny_profile_t *) val; @@ -2861,10 +2861,10 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skinny_shutdown) } switch_core_destroy_memory_pool(&profile->pool); } - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(skinny_globals.mutex); - switch_core_hash_destroy(&globals.profile_hash); - memset(&globals, 0, sizeof(globals)); + switch_core_hash_destroy(&skinny_globals.profile_hash); + memset(&skinny_globals, 0, sizeof(skinny_globals)); switch_mutex_unlock(mutex); switch_core_destroy_memory_pool(&pool); return SWITCH_STATUS_SUCCESS; diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.h b/src/mod/endpoints/mod_skinny/mod_skinny.h index b0f6abf1be..b5aed9e42c 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.h +++ b/src/mod/endpoints/mod_skinny/mod_skinny.h @@ -101,7 +101,7 @@ struct skinny_globals { }; typedef struct skinny_globals skinny_globals_t; -extern skinny_globals_t globals; +extern skinny_globals_t skinny_globals; typedef enum { PFLAG_LISTENER_READY = (1 << 0), diff --git a/src/mod/endpoints/mod_skinny/skinny_api.c b/src/mod/endpoints/mod_skinny/skinny_api.c index f9f734f630..98ee68c8e9 100644 --- a/src/mod/endpoints/mod_skinny/skinny_api.c +++ b/src/mod/endpoints/mod_skinny/skinny_api.c @@ -48,14 +48,14 @@ static switch_status_t skinny_api_list_profiles(const char *line, const char *cu skinny_profile_t *profile; /* walk profiles */ - switch_mutex_lock(globals.mutex); - for (hi = switch_core_hash_first(globals.profile_hash); hi; hi = switch_core_hash_next(&hi)) { + switch_mutex_lock(skinny_globals.mutex); + for (hi = switch_core_hash_first(skinny_globals.profile_hash); hi; hi = switch_core_hash_next(&hi)) { switch_core_hash_this(hi, NULL, NULL, &val); profile = (skinny_profile_t *) val; switch_console_push_match(&my_matches, profile->name); } - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(skinny_globals.mutex); if (my_matches) { *matches = my_matches; diff --git a/src/mod/endpoints/mod_verto/mod_verto.c b/src/mod/endpoints/mod_verto/mod_verto.c index 2d9bd1a6ff..c9bfb88a04 100644 --- a/src/mod/endpoints/mod_verto/mod_verto.c +++ b/src/mod/endpoints/mod_verto/mod_verto.c @@ -61,7 +61,7 @@ SWITCH_MODULE_DEFINITION(mod_verto, mod_verto_load, mod_verto_shutdown, mod_vert #define die(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, __VA_ARGS__); goto error -struct globals_s globals; +static struct globals_s verto_globals; static struct { @@ -290,7 +290,7 @@ static uint32_t jsock_unsub_head(jsock_t *jsock, jsock_sub_node_head_t *head) head->node = np; } - if (thisnp->jsock->profile->debug || globals.debug) { + if (thisnp->jsock->profile->debug || verto_globals.debug) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "UNSUBBING %s [%s]\n", thisnp->jsock->name, thisnp->head->event_channel); } @@ -313,22 +313,22 @@ static void unsub_all_jsock(void) void *val; jsock_sub_node_head_t *head; - switch_thread_rwlock_wrlock(globals.event_channel_rwlock); + switch_thread_rwlock_wrlock(verto_globals.event_channel_rwlock); top: head = NULL; - for (hi = switch_core_hash_first(globals.event_channel_hash); hi;) { + for (hi = switch_core_hash_first(verto_globals.event_channel_hash); hi;) { switch_core_hash_this(hi, NULL, NULL, &val); head = (jsock_sub_node_head_t *) val; jsock_unsub_head(NULL, head); - switch_core_hash_delete(globals.event_channel_hash, head->event_channel); + switch_core_hash_delete(verto_globals.event_channel_hash, head->event_channel); free(head->event_channel); free(head); switch_safe_free(hi); goto top; } - switch_thread_rwlock_unlock(globals.event_channel_rwlock); + switch_thread_rwlock_unlock(verto_globals.event_channel_rwlock); } static uint32_t jsock_unsub_channel(jsock_t *jsock, const char *event_channel) @@ -336,13 +336,13 @@ static uint32_t jsock_unsub_channel(jsock_t *jsock, const char *event_channel) jsock_sub_node_head_t *head; uint32_t x = 0; - switch_thread_rwlock_wrlock(globals.event_channel_rwlock); + switch_thread_rwlock_wrlock(verto_globals.event_channel_rwlock); if (!event_channel) { switch_hash_index_t *hi; void *val; - for (hi = switch_core_hash_first(globals.event_channel_hash); hi; hi = switch_core_hash_next(&hi)) { + for (hi = switch_core_hash_first(verto_globals.event_channel_hash); hi; hi = switch_core_hash_next(&hi)) { switch_core_hash_this(hi, NULL, NULL, &val); if (val) { @@ -352,12 +352,12 @@ static uint32_t jsock_unsub_channel(jsock_t *jsock, const char *event_channel) } } else { - if ((head = switch_core_hash_find(globals.event_channel_hash, event_channel))) { + if ((head = switch_core_hash_find(verto_globals.event_channel_hash, event_channel))) { x += jsock_unsub_head(jsock, head); } } - switch_thread_rwlock_unlock(globals.event_channel_rwlock); + switch_thread_rwlock_unlock(verto_globals.event_channel_rwlock); return x; } @@ -410,12 +410,12 @@ static switch_status_t jsock_sub_channel(jsock_t *jsock, const char *event_chann jsock_sub_node_head_t *head; switch_status_t status = SWITCH_STATUS_FALSE; - switch_thread_rwlock_wrlock(globals.event_channel_rwlock); + switch_thread_rwlock_wrlock(verto_globals.event_channel_rwlock); - if (!(head = switch_core_hash_find(globals.event_channel_hash, event_channel))) { + if (!(head = switch_core_hash_find(verto_globals.event_channel_hash, event_channel))) { switch_zmalloc(head, sizeof(*head)); head->event_channel = strdup(event_channel); - switch_core_hash_insert(globals.event_channel_hash, event_channel, head); + switch_core_hash_insert(verto_globals.event_channel_hash, event_channel, head); switch_zmalloc(node, sizeof(*node)); node->jsock = jsock; @@ -449,7 +449,7 @@ static switch_status_t jsock_sub_channel(jsock_t *jsock, const char *event_chann } } - switch_thread_rwlock_unlock(globals.event_channel_rwlock); + switch_thread_rwlock_unlock(verto_globals.event_channel_rwlock); if (status == SWITCH_STATUS_SUCCESS && !strncasecmp(event_channel, "presence", 8)) { presence_ping(event_channel); @@ -500,9 +500,9 @@ static uint32_t next_id(void) { uint32_t id; - switch_mutex_lock(globals.mutex); + switch_mutex_lock(verto_globals.mutex); id = ID++; - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(verto_globals.mutex); return id; } @@ -599,7 +599,7 @@ static switch_ssize_t ws_write_json(jsock_t *jsock, cJSON **json, switch_bool_t } if ((json_text = cJSON_PrintUnformatted(*json))) { - if (jsock->profile->debug || globals.debug) { + if (jsock->profile->debug || verto_globals.debug) { char *log_text = cJSON_Print(*json); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "WRITE %s [%s]\n", jsock->name, log_text); free(log_text); @@ -665,7 +665,7 @@ static void write_event(const char *event_channel, jsock_t *use_jsock, cJSON *ev { jsock_sub_node_head_t *head; - if ((head = switch_core_hash_find(globals.event_channel_hash, event_channel))) { + if ((head = switch_core_hash_find(verto_globals.event_channel_hash, event_channel))) { jsock_sub_node_t *np; for(np = head->node; np; np = np->next) { @@ -721,7 +721,7 @@ static void jsock_send_event(cJSON *event) } } - switch_thread_rwlock_rdlock(globals.event_channel_rwlock); + switch_thread_rwlock_rdlock(verto_globals.event_channel_rwlock); write_event(event_channel, use_jsock, event); if (strchr(event_channel, '.')) { char *main_channel = strdup(event_channel); @@ -730,7 +730,7 @@ static void jsock_send_event(cJSON *event) write_event(main_channel, use_jsock, event); free(main_channel); } - switch_thread_rwlock_unlock(globals.event_channel_rwlock); + switch_thread_rwlock_unlock(verto_globals.event_channel_rwlock); if (use_jsock) { switch_thread_rwlock_unlock(use_jsock->rwlock); @@ -759,9 +759,9 @@ static jrpc_func_t jrpc_get_func(jsock_t *jsock, const char *method) } } - switch_mutex_lock(globals.method_mutex); - func = (jrpc_func_t) (intptr_t) switch_core_hash_find(globals.method_hash, method); - switch_mutex_unlock(globals.method_mutex); + switch_mutex_lock(verto_globals.method_mutex); + func = (jrpc_func_t) (intptr_t) switch_core_hash_find(verto_globals.method_hash, method); + switch_mutex_unlock(verto_globals.method_mutex); end: @@ -776,9 +776,9 @@ static void jrpc_add_func(const char *method, jrpc_func_t func) switch_assert(method); switch_assert(func); - switch_mutex_lock(globals.method_mutex); - switch_core_hash_insert(globals.method_hash, method, (void *) (intptr_t) func); - switch_mutex_unlock(globals.method_mutex); + switch_mutex_lock(verto_globals.method_mutex); + switch_core_hash_insert(verto_globals.method_hash, method, (void *) (intptr_t) func); + switch_mutex_unlock(verto_globals.method_mutex); } static char *MARKER = "X"; @@ -1082,13 +1082,13 @@ static jsock_t *get_jsock(const char *uuid) { jsock_t *jsock = NULL; - switch_mutex_lock(globals.jsock_mutex); - if ((jsock = switch_core_hash_find(globals.jsock_hash, uuid))) { + switch_mutex_lock(verto_globals.jsock_mutex); + if ((jsock = switch_core_hash_find(verto_globals.jsock_hash, uuid))) { if (switch_thread_rwlock_tryrdlock(jsock->rwlock) != SWITCH_STATUS_SUCCESS) { jsock = NULL; } } - switch_mutex_unlock(globals.jsock_mutex); + switch_mutex_unlock(verto_globals.jsock_mutex); return jsock; } @@ -1098,11 +1098,11 @@ static void attach_jsock(jsock_t *jsock) jsock_t *jp; int proceed = 1; - switch_mutex_lock(globals.jsock_mutex); + switch_mutex_lock(verto_globals.jsock_mutex); switch_assert(jsock); - if ((jp = switch_core_hash_find(globals.jsock_hash, jsock->uuid_str))) { + if ((jp = switch_core_hash_find(verto_globals.jsock_hash, jsock->uuid_str))) { if (jp == jsock) { proceed = 0; } else { @@ -1110,7 +1110,7 @@ static void attach_jsock(jsock_t *jsock) cJSON *msg = NULL; msg = jrpc_new_req("verto.punt", NULL, ¶ms); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "New connection for session %s dropping previous connection.\n", jsock->uuid_str); - switch_core_hash_delete(globals.jsock_hash, jsock->uuid_str); + switch_core_hash_delete(verto_globals.jsock_hash, jsock->uuid_str); ws_write_json(jp, &msg, SWITCH_TRUE); cJSON_Delete(msg); jp->nodelete = 1; @@ -1119,10 +1119,10 @@ static void attach_jsock(jsock_t *jsock) } if (proceed) { - switch_core_hash_insert(globals.jsock_hash, jsock->uuid_str, jsock); + switch_core_hash_insert(verto_globals.jsock_hash, jsock->uuid_str, jsock); } - switch_mutex_unlock(globals.jsock_mutex); + switch_mutex_unlock(verto_globals.jsock_mutex); } static void detach_jsock(jsock_t *jsock) @@ -1131,9 +1131,9 @@ static void detach_jsock(jsock_t *jsock) return; } - switch_mutex_lock(globals.jsock_mutex); - switch_core_hash_delete(globals.jsock_hash, jsock->uuid_str); - switch_mutex_unlock(globals.jsock_mutex); + switch_mutex_lock(verto_globals.jsock_mutex); + switch_core_hash_delete(verto_globals.jsock_hash, jsock->uuid_str); + switch_mutex_unlock(verto_globals.jsock_mutex); } static int attach_wake(void) @@ -1143,15 +1143,15 @@ static int attach_wake(void) top: - status = switch_mutex_trylock(globals.detach_mutex); + status = switch_mutex_trylock(verto_globals.detach_mutex); if (status == SWITCH_STATUS_SUCCESS) { - switch_thread_cond_signal(globals.detach_cond); - switch_mutex_unlock(globals.detach_mutex); + switch_thread_cond_signal(verto_globals.detach_cond); + switch_mutex_unlock(verto_globals.detach_mutex); return 1; } else { - if (switch_mutex_trylock(globals.detach2_mutex) == SWITCH_STATUS_SUCCESS) { - switch_mutex_unlock(globals.detach2_mutex); + if (switch_mutex_trylock(verto_globals.detach2_mutex) == SWITCH_STATUS_SUCCESS) { + switch_mutex_unlock(verto_globals.detach2_mutex); } else { if (++tries < 10) { switch_cond_next(); @@ -1169,7 +1169,7 @@ static void tech_reattach(verto_pvt_t *tech_pvt, jsock_t *jsock) cJSON *msg = NULL; tech_pvt->detach_time = 0; - globals.detached--; + verto_globals.detached--; attach_wake(); switch_set_flag(tech_pvt, TFLAG_ATTACH_REQ); msg = jrpc_new_req("verto.attach", tech_pvt->call_id, ¶ms); @@ -1194,25 +1194,25 @@ static void drop_detached(void) verto_pvt_t *tech_pvt; switch_time_t now = switch_epoch_time_now(NULL); - switch_thread_rwlock_rdlock(globals.tech_rwlock); - for(tech_pvt = globals.tech_head; tech_pvt; tech_pvt = tech_pvt->next) { + switch_thread_rwlock_rdlock(verto_globals.tech_rwlock); + for(tech_pvt = verto_globals.tech_head; tech_pvt; tech_pvt = tech_pvt->next) { if (!switch_channel_up_nosig(tech_pvt->channel)) { continue; } - if (tech_pvt->detach_time && (now - tech_pvt->detach_time) > globals.detach_timeout) { + if (tech_pvt->detach_time && (now - tech_pvt->detach_time) > verto_globals.detach_timeout) { switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_RECOVERY_ON_TIMER_EXPIRE); } } - switch_thread_rwlock_unlock(globals.tech_rwlock); + switch_thread_rwlock_unlock(verto_globals.tech_rwlock); } static void attach_calls(jsock_t *jsock) { verto_pvt_t *tech_pvt; - switch_thread_rwlock_rdlock(globals.tech_rwlock); - for(tech_pvt = globals.tech_head; tech_pvt; tech_pvt = tech_pvt->next) { + switch_thread_rwlock_rdlock(verto_globals.tech_rwlock); + for(tech_pvt = verto_globals.tech_head; tech_pvt; tech_pvt = tech_pvt->next) { if (tech_pvt->detach_time && !strcmp(tech_pvt->jsock_uuid, jsock->uuid_str)) { if (!switch_channel_up_nosig(tech_pvt->channel)) { continue; @@ -1221,15 +1221,15 @@ static void attach_calls(jsock_t *jsock) tech_reattach(tech_pvt, jsock); } } - switch_thread_rwlock_unlock(globals.tech_rwlock); + switch_thread_rwlock_unlock(verto_globals.tech_rwlock); } static void detach_calls(jsock_t *jsock) { verto_pvt_t *tech_pvt; - switch_thread_rwlock_rdlock(globals.tech_rwlock); - for(tech_pvt = globals.tech_head; tech_pvt; tech_pvt = tech_pvt->next) { + switch_thread_rwlock_rdlock(verto_globals.tech_rwlock); + for(tech_pvt = verto_globals.tech_head; tech_pvt; tech_pvt = tech_pvt->next) { if (!strcmp(tech_pvt->jsock_uuid, jsock->uuid_str)) { if (!switch_channel_up_nosig(tech_pvt->channel)) { continue; @@ -1247,11 +1247,11 @@ static void detach_calls(jsock_t *jsock) switch_core_session_stop_media(tech_pvt->session); tech_pvt->detach_time = switch_epoch_time_now(NULL); - globals.detached++; + verto_globals.detached++; attach_wake(); } } - switch_thread_rwlock_unlock(globals.tech_rwlock); + switch_thread_rwlock_unlock(verto_globals.tech_rwlock); } static void process_jrpc_response(jsock_t *jsock, cJSON *json) @@ -1365,7 +1365,7 @@ static switch_status_t process_input(jsock_t *jsock, uint8_t *data, switch_ssize if (json) { - if (jsock->profile->debug || globals.debug) { + if (jsock->profile->debug || verto_globals.debug) { char *log_text = cJSON_Print(json); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "READ %s [%s]\n", jsock->name, log_text); free(log_text); @@ -2080,36 +2080,36 @@ static switch_bool_t auth_api_command(jsock_t *jsock, const char *api_cmd, const static void track_pvt(verto_pvt_t *tech_pvt) { - switch_thread_rwlock_wrlock(globals.tech_rwlock); - tech_pvt->next = globals.tech_head; - globals.tech_head = tech_pvt; - switch_thread_rwlock_unlock(globals.tech_rwlock); + switch_thread_rwlock_wrlock(verto_globals.tech_rwlock); + tech_pvt->next = verto_globals.tech_head; + verto_globals.tech_head = tech_pvt; + switch_thread_rwlock_unlock(verto_globals.tech_rwlock); } static void untrack_pvt(verto_pvt_t *tech_pvt) { verto_pvt_t *p, *last = NULL; - switch_thread_rwlock_wrlock(globals.tech_rwlock); + switch_thread_rwlock_wrlock(verto_globals.tech_rwlock); if (tech_pvt->detach_time) { - globals.detached--; + verto_globals.detached--; tech_pvt->detach_time = 0; attach_wake(); } - for(p = globals.tech_head; p; p = p->next) { + for(p = verto_globals.tech_head; p; p = p->next) { if (p == tech_pvt) { if (last) { last->next = p->next; } else { - globals.tech_head = p->next; + verto_globals.tech_head = p->next; } break; } last = p; } - switch_thread_rwlock_unlock(globals.tech_rwlock); + switch_thread_rwlock_unlock(verto_globals.tech_rwlock); } switch_endpoint_interface_t *verto_endpoint_interface = NULL; @@ -3674,7 +3674,7 @@ static switch_bool_t event_channel_check_auth(jsock_t *jsock, const char *event_ } } - if ((!globals.enable_fs_events && (!strcasecmp(event_channel, "FSevent") || (main_event_channel && !strcasecmp(main_event_channel, "FSevent")))) || + if ((!verto_globals.enable_fs_events && (!strcasecmp(event_channel, "FSevent") || (main_event_channel && !strcasecmp(main_event_channel, "FSevent")))) || !(switch_event_get_header(jsock->allowed_event_channels, event_channel) || (main_event_channel && switch_event_get_header(jsock->allowed_event_channels, main_event_channel)))) { ok = SWITCH_FALSE; @@ -3854,7 +3854,7 @@ static switch_bool_t verto__broadcast_func(const char *method, cJSON *params, js if (broadcast && broadcast->type == cJSON_True) { write_event(event_channel, NULL, jevent); } else { - switch_event_channel_broadcast(event_channel, &jevent, modname, globals.event_channel_id); + switch_event_channel_broadcast(event_channel, &jevent, modname, verto_globals.event_channel_id); } if (jsock->profile->mcast_pub.sock != ws_sock_invalid) { @@ -4303,14 +4303,14 @@ static void kill_profiles(void) verto_profile_t *pp; int sanity = 50; - switch_mutex_lock(globals.mutex); - for(pp = globals.profile_head; pp; pp = pp->next) { + switch_mutex_lock(verto_globals.mutex); + for(pp = verto_globals.profile_head; pp; pp = pp->next) { kill_profile(pp); } - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(verto_globals.mutex); - while(--sanity > 0 && globals.profile_threads > 0) { + while(--sanity > 0 && verto_globals.profile_threads > 0) { switch_yield(100000); } } @@ -4379,9 +4379,9 @@ static int runtime(verto_profile_t *profile) static void do_shutdown(void) { - globals.running = 0; + verto_globals.running = 0; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Shutting down (SIG %d)\n", globals.sig); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Shutting down (SIG %d)\n", verto_globals.sig); kill_profiles(); @@ -4437,8 +4437,8 @@ static void parse_ip(char *host, switch_size_t host_len, uint16_t *port, char *i static verto_profile_t *find_profile(const char *name) { verto_profile_t *p, *r = NULL; - switch_mutex_lock(globals.mutex); - for(p = globals.profile_head; p; p = p->next) { + switch_mutex_lock(verto_globals.mutex); + for(p = verto_globals.profile_head; p; p = p->next) { if (!strcmp(name, p->name)) { r = p; break; @@ -4452,7 +4452,7 @@ static verto_profile_t *find_profile(const char *name) if (r && switch_thread_rwlock_tryrdlock(r->rwlock) != SWITCH_STATUS_SUCCESS) { r = NULL; } - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(verto_globals.mutex); return r; } @@ -4462,14 +4462,14 @@ static switch_bool_t profile_exists(const char *name) switch_bool_t r = SWITCH_FALSE; verto_profile_t *p; - switch_mutex_lock(globals.mutex); - for(p = globals.profile_head; p; p = p->next) { + switch_mutex_lock(verto_globals.mutex); + for(p = verto_globals.profile_head; p; p = p->next) { if (!strcmp(p->name, name)) { r = SWITCH_TRUE; break; } } - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(verto_globals.mutex); return r; } @@ -4478,40 +4478,40 @@ static void del_profile(verto_profile_t *profile) { verto_profile_t *p, *last = NULL; - switch_mutex_lock(globals.mutex); - for(p = globals.profile_head; p; p = p->next) { + switch_mutex_lock(verto_globals.mutex); + for(p = verto_globals.profile_head; p; p = p->next) { if (p == profile) { if (last) { last->next = p->next; } else { - globals.profile_head = p->next; + verto_globals.profile_head = p->next; } - globals.profile_count--; + verto_globals.profile_count--; break; } last = p; } - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(verto_globals.mutex); } static switch_status_t add_profile(verto_profile_t *profile) { switch_status_t status = SWITCH_STATUS_FALSE; - switch_mutex_lock(globals.mutex); + switch_mutex_lock(verto_globals.mutex); if (!profile_exists(profile->name)) { status = SWITCH_STATUS_SUCCESS; } if (status == SWITCH_STATUS_SUCCESS) { - profile->next = globals.profile_head; - globals.profile_head = profile; - globals.profile_count++; + profile->next = verto_globals.profile_head; + verto_globals.profile_head = profile; + verto_globals.profile_count++; } - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(verto_globals.mutex); return status; } @@ -4785,16 +4785,16 @@ static switch_status_t parse_config(const char *cf) if (!strcasecmp(var, "debug")) { if (val) { - globals.debug = atoi(val); + verto_globals.debug = atoi(val); } } else if (!strcasecmp(var, "enable-presence") && val) { - globals.enable_presence = switch_true(val); + verto_globals.enable_presence = switch_true(val); } else if (!strcasecmp(var, "enable-fs-events") && val) { - globals.enable_fs_events = switch_true(val); + verto_globals.enable_fs_events = switch_true(val); } else if (!strcasecmp(var, "detach-timeout-sec") && val) { int tmp = atoi(val); if (tmp > 0) { - globals.detach_timeout = tmp; + verto_globals.detach_timeout = tmp; } } } @@ -4811,13 +4811,13 @@ static int init(void) parse_config("verto.conf"); - switch_mutex_lock(globals.mutex); - for(p = globals.profile_head; p; p = p->next) { + switch_mutex_lock(verto_globals.mutex); + for(p = verto_globals.profile_head; p; p = p->next) { verto_init_ssl(p); } - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(verto_globals.mutex); - globals.running = 1; + verto_globals.running = 1; return 0; } @@ -4857,8 +4857,8 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t stream->write_function(stream, "%25s\t%s\t %40s\t%s\n", "Name", " Type", "Data", "State"); stream->write_function(stream, "%s\n", line); - switch_mutex_lock(globals.mutex); - for(profile = globals.profile_head; profile; profile = profile->next) { + switch_mutex_lock(verto_globals.mutex); + for(profile = verto_globals.profile_head; profile; profile = profile->next) { for (i = 0; i < profile->i; i++) { char *tmpurl = switch_mprintf(strchr(profile->ip[i].local_ip, ':') ? "%s:[%s]:%d" : "%s:%s:%d", (profile->ip[i].secure == 1) ? "wss" : "ws", profile->ip[i].local_ip, profile->ip[i].local_port); @@ -4882,7 +4882,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t } switch_mutex_unlock(profile->mutex); } - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(verto_globals.mutex); stream->write_function(stream, "%s\n", line); stream->write_function(stream, "%d profile%s , %d client%s\n", cp, cp == 1 ? "" : "s", cc, cc == 1 ? "" : "s"); @@ -4901,8 +4901,8 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl stream->write_function(stream, "%s\n", header); stream->write_function(stream, "\n"); - switch_mutex_lock(globals.mutex); - for(profile = globals.profile_head; profile; profile = profile->next) { + switch_mutex_lock(verto_globals.mutex); + for(profile = verto_globals.profile_head; profile; profile = profile->next) { for (i = 0; i < profile->i; i++) { char *tmpurl = switch_mprintf(strchr(profile->ip[i].local_ip, ':') ? "%s:[%s]:%d" : "%s:%s:%d", (profile->ip[i].secure == 1) ? "wss" : "ws", profile->ip[i].local_ip, profile->ip[i].local_port); @@ -4921,7 +4921,7 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl } switch_mutex_unlock(profile->mutex); } - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(verto_globals.mutex); stream->write_function(stream, "\n"); return SWITCH_STATUS_SUCCESS; } @@ -4983,9 +4983,9 @@ static void *SWITCH_THREAD_FUNC profile_thread(switch_thread_t *thread, void *ob verto_profile_t *profile = (verto_profile_t *) obj; int sanity = 50; - switch_mutex_lock(globals.mutex); - globals.profile_threads++; - switch_mutex_unlock(globals.mutex); + switch_mutex_lock(verto_globals.mutex); + verto_globals.profile_threads++; + switch_mutex_unlock(verto_globals.mutex); profile->in_thread = 1; profile->running = 1; @@ -5009,9 +5009,9 @@ static void *SWITCH_THREAD_FUNC profile_thread(switch_thread_t *thread, void *ob switch_thread_rwlock_unlock(profile->rwlock); profile->in_thread = 0; - switch_mutex_lock(globals.mutex); - globals.profile_threads--; - switch_mutex_unlock(globals.mutex); + switch_mutex_lock(verto_globals.mutex); + verto_globals.profile_threads--; + switch_mutex_unlock(verto_globals.mutex); return NULL; @@ -5034,13 +5034,13 @@ static void run_profiles(void) { verto_profile_t *p; - switch_mutex_lock(globals.mutex); - for(p = globals.profile_head; p; p = p->next) { + switch_mutex_lock(verto_globals.mutex); + for(p = verto_globals.profile_head; p; p = p->next) { if (!p->in_thread) { run_profile_thread(p); } } - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(verto_globals.mutex); } @@ -5079,8 +5079,8 @@ static char *verto_get_dial_string(const char *uid, switch_stream_handle_t *rstr use_stream = &stream; } - switch_mutex_lock(globals.mutex); - for(profile = globals.profile_head; profile; profile = profile->next) { + switch_mutex_lock(verto_globals.mutex); + for(profile = verto_globals.profile_head; profile; profile = profile->next) { switch_mutex_lock(profile->mutex); @@ -5093,7 +5093,7 @@ static char *verto_get_dial_string(const char *uid, switch_stream_handle_t *rstr switch_mutex_unlock(profile->mutex); } - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(verto_globals.mutex); switch_safe_free(gen_uid); @@ -5253,7 +5253,7 @@ static switch_call_cause_t verto_outgoing_channel(switch_core_session_t *session void verto_broadcast(const char *event_channel, cJSON *json, const char *key, switch_event_channel_id_t id) { - if (globals.debug > 9) { + if (verto_globals.debug > 9) { char *json_text; if ((json_text = cJSON_Print(json))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "EVENT BROADCAST %s %s\n", event_channel, json_text); @@ -5298,8 +5298,8 @@ static int verto_send_chat(const char *uid, const char *call_id, cJSON *msg) return 1; } - switch_mutex_lock(globals.mutex); - for(profile = globals.profile_head; profile; profile = profile->next) { + switch_mutex_lock(verto_globals.mutex); + for(profile = verto_globals.profile_head; profile; profile = profile->next) { switch_mutex_lock(profile->mutex); @@ -5312,7 +5312,7 @@ static int verto_send_chat(const char *uid, const char *call_id, cJSON *msg) switch_mutex_unlock(profile->mutex); } - switch_mutex_unlock(globals.mutex); + switch_mutex_unlock(verto_globals.mutex); return hits; } @@ -5726,11 +5726,11 @@ static void presence_event_handler(switch_event_t *event) char *event_channel; const char *presence_id = switch_event_get_header(event, "channel-presence-id"); - if (!globals.running) { + if (!verto_globals.running) { return; } - if (!globals.enable_presence || zstr(presence_id)) { + if (!verto_globals.enable_presence || zstr(presence_id)) { return; } @@ -5772,7 +5772,7 @@ static void event_handler(switch_event_t *event) cJSON *msg = NULL, *data = NULL; char *event_channel; - if (!globals.enable_fs_events) { + if (!verto_globals.enable_fs_events) { return; } @@ -5826,31 +5826,31 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_verto_load) return SWITCH_STATUS_TERM; } - memset(&globals, 0, sizeof(globals)); - globals.pool = pool; + memset(&verto_globals, 0, sizeof(verto_globals)); + verto_globals.pool = pool; #ifndef WIN32 - globals.ready = SIGUSR1; + verto_globals.ready = SIGUSR1; #endif - globals.enable_presence = SWITCH_TRUE; - globals.enable_fs_events = SWITCH_FALSE; + verto_globals.enable_presence = SWITCH_TRUE; + verto_globals.enable_fs_events = SWITCH_FALSE; - switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool); + switch_mutex_init(&verto_globals.mutex, SWITCH_MUTEX_NESTED, verto_globals.pool); - switch_mutex_init(&globals.method_mutex, SWITCH_MUTEX_NESTED, globals.pool); - switch_core_hash_init(&globals.method_hash); + switch_mutex_init(&verto_globals.method_mutex, SWITCH_MUTEX_NESTED, verto_globals.pool); + switch_core_hash_init(&verto_globals.method_hash); - switch_thread_rwlock_create(&globals.event_channel_rwlock, globals.pool); - switch_core_hash_init(&globals.event_channel_hash); + switch_thread_rwlock_create(&verto_globals.event_channel_rwlock, verto_globals.pool); + switch_core_hash_init(&verto_globals.event_channel_hash); - switch_mutex_init(&globals.jsock_mutex, SWITCH_MUTEX_NESTED, globals.pool); - switch_core_hash_init(&globals.jsock_hash); + switch_mutex_init(&verto_globals.jsock_mutex, SWITCH_MUTEX_NESTED, verto_globals.pool); + switch_core_hash_init(&verto_globals.jsock_hash); - switch_thread_rwlock_create(&globals.tech_rwlock, globals.pool); + switch_thread_rwlock_create(&verto_globals.tech_rwlock, verto_globals.pool); - switch_mutex_init(&globals.detach_mutex, SWITCH_MUTEX_NESTED, globals.pool); - switch_mutex_init(&globals.detach2_mutex, SWITCH_MUTEX_NESTED, globals.pool); - switch_thread_cond_create(&globals.detach_cond, globals.pool); - globals.detach_timeout = 120; + switch_mutex_init(&verto_globals.detach_mutex, SWITCH_MUTEX_NESTED, verto_globals.pool); + switch_mutex_init(&verto_globals.detach2_mutex, SWITCH_MUTEX_NESTED, verto_globals.pool); + switch_thread_cond_create(&verto_globals.detach_cond, verto_globals.pool); + verto_globals.detach_timeout = 120; @@ -5866,7 +5866,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_verto_load) - switch_event_channel_bind(SWITCH_EVENT_CHANNEL_GLOBAL, verto_broadcast, &globals.event_channel_id); + switch_event_channel_bind(SWITCH_EVENT_CHANNEL_GLOBAL, verto_broadcast, &verto_globals.event_channel_id); r = init(); @@ -5894,11 +5894,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_verto_load) switch_core_register_secondary_recover_callback(modname, verto_recover_callback); - if (globals.enable_presence) { + if (verto_globals.enable_presence) { switch_event_bind(modname, SWITCH_EVENT_CHANNEL_CALLSTATE, SWITCH_EVENT_SUBCLASS_ANY, presence_event_handler, NULL); } - if (globals.enable_fs_events) { + if (verto_globals.enable_fs_events) { if (switch_event_bind(modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); return SWITCH_STATUS_GENERR; @@ -5933,31 +5933,31 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_verto_shutdown) attach_wake(); attach_wake(); - switch_core_hash_destroy(&globals.method_hash); - switch_core_hash_destroy(&globals.event_channel_hash); - switch_core_hash_destroy(&globals.jsock_hash); + switch_core_hash_destroy(&verto_globals.method_hash); + switch_core_hash_destroy(&verto_globals.event_channel_hash); + switch_core_hash_destroy(&verto_globals.jsock_hash); return SWITCH_STATUS_SUCCESS; } SWITCH_MODULE_RUNTIME_FUNCTION(mod_verto_runtime) { - switch_mutex_lock(globals.detach_mutex); + switch_mutex_lock(verto_globals.detach_mutex); - while(globals.running) { - if (globals.detached) { + while(verto_globals.running) { + if (verto_globals.detached) { drop_detached(); switch_yield(1000000); } else { - switch_mutex_lock(globals.detach2_mutex); - if (globals.running) { - switch_thread_cond_wait(globals.detach_cond, globals.detach_mutex); + switch_mutex_lock(verto_globals.detach2_mutex); + if (verto_globals.running) { + switch_thread_cond_wait(verto_globals.detach_cond, verto_globals.detach_mutex); } - switch_mutex_unlock(globals.detach2_mutex); + switch_mutex_unlock(verto_globals.detach2_mutex); } } - switch_mutex_unlock(globals.detach_mutex); + switch_mutex_unlock(verto_globals.detach_mutex); return SWITCH_STATUS_TERM; } diff --git a/src/mod/endpoints/mod_verto/mod_verto.h b/src/mod/endpoints/mod_verto/mod_verto.h index c39c74d681..16afcfd973 100644 --- a/src/mod/endpoints/mod_verto/mod_verto.h +++ b/src/mod/endpoints/mod_verto/mod_verto.h @@ -308,8 +308,6 @@ struct globals_s { }; -extern struct globals_s globals; - typedef switch_bool_t (*jrpc_func_t)(const char *method, cJSON *params, jsock_t *jsock, cJSON **response); diff --git a/src/mod/endpoints/mod_verto/ws.c b/src/mod/endpoints/mod_verto/ws.c index 2aee664111..a6fe8781c9 100644 --- a/src/mod/endpoints/mod_verto/ws.c +++ b/src/mod/endpoints/mod_verto/ws.c @@ -25,7 +25,7 @@ #define WS_NOBLOCK 0 #define SHA1_HASH_SIZE 20 -struct ws_globals_s ws_globals; +static struct ws_globals_s ws_globals; #ifndef WSS_STANDALONE @@ -107,13 +107,13 @@ void init_ssl(void) { assert(ws_globals.ssl_ctx); /* Disable SSLv2 */ - SSL_CTX_set_options(globals.ssl_ctx, SSL_OP_NO_SSLv2); + SSL_CTX_set_options(ws_globals.ssl_ctx, SSL_OP_NO_SSLv2); /* Disable SSLv3 */ - SSL_CTX_set_options(globals.ssl_ctx, SSL_OP_NO_SSLv3); + SSL_CTX_set_options(ws_globals.ssl_ctx, SSL_OP_NO_SSLv3); /* Disable TLSv1 */ - SSL_CTX_set_options(globals.ssl_ctx, SSL_OP_NO_TLSv1); + SSL_CTX_set_options(ws_globals.ssl_ctx, SSL_OP_NO_TLSv1); /* Disable Compression CRIME (Compression Ratio Info-leak Made Easy) */ - SSL_CTX_set_options(globals.ssl_ctx, SSL_OP_NO_COMPRESSION); + SSL_CTX_set_options(ws_globals.ssl_ctx, SSL_OP_NO_COMPRESSION); /* set the local certificate from CertFile */ SSL_CTX_use_certificate_file(ws_globals.ssl_ctx, ws_globals.cert, SSL_FILETYPE_PEM); /* set the private key from KeyFile */ diff --git a/src/mod/endpoints/mod_verto/ws.h b/src/mod/endpoints/mod_verto/ws.h index 56522a23df..12b3a2560d 100644 --- a/src/mod/endpoints/mod_verto/ws.h +++ b/src/mod/endpoints/mod_verto/ws.h @@ -61,7 +61,7 @@ struct ws_globals_s { char key[512]; }; -extern struct ws_globals_s ws_globals; +//extern struct ws_globals_s ws_globals; #ifndef WIN32 typedef int ws_socket_t; diff --git a/src/mod/event_handlers/mod_erlang_event/ei_helpers.c b/src/mod/event_handlers/mod_erlang_event/ei_helpers.c index 0769279dba..8df561a139 100644 --- a/src/mod/event_handlers/mod_erlang_event/ei_helpers.c +++ b/src/mod/event_handlers/mod_erlang_event/ei_helpers.c @@ -202,21 +202,21 @@ void ei_init_ref(ei_cnode * ec, erlang_ref * ref) memset(ref, 0, sizeof(*ref)); /* zero out the struct */ snprintf(ref->node, MAXATOMLEN, "%s", ec->thisnodename); - switch_mutex_lock(globals.ref_mutex); - globals.reference0++; - if (globals.reference0 >= MAX_REFERENCE) { - globals.reference0 = 0; - globals.reference1++; - if (globals.reference1 == 0) { - globals.reference2++; + switch_mutex_lock(mod_erlang_event_globals.ref_mutex); + mod_erlang_event_globals.reference0++; + if (mod_erlang_event_globals.reference0 >= MAX_REFERENCE) { + mod_erlang_event_globals.reference0 = 0; + mod_erlang_event_globals.reference1++; + if (mod_erlang_event_globals.reference1 == 0) { + mod_erlang_event_globals.reference2++; } } - ref->n[0] = globals.reference0; - ref->n[1] = globals.reference1; - ref->n[2] = globals.reference2; + ref->n[0] = mod_erlang_event_globals.reference0; + ref->n[1] = mod_erlang_event_globals.reference1; + ref->n[2] = mod_erlang_event_globals.reference2; - switch_mutex_unlock(globals.ref_mutex); + switch_mutex_unlock(mod_erlang_event_globals.ref_mutex); ref->creation = 1; /* why is this 1 */ ref->len = 3; /* why is this 3 */ diff --git a/src/mod/event_handlers/mod_erlang_event/handle_msg.c b/src/mod/event_handlers/mod_erlang_event/handle_msg.c index 06344e721f..56f0c45850 100644 --- a/src/mod/event_handlers/mod_erlang_event/handle_msg.c +++ b/src/mod/event_handlers/mod_erlang_event/handle_msg.c @@ -958,7 +958,7 @@ static switch_status_t handle_msg_bind(listener_t *listener, erlang_msg * msg, e binding->process.pid = msg->from; binding->listener = listener; - switch_thread_rwlock_wrlock(globals.bindings_rwlock); + switch_thread_rwlock_wrlock(mod_erlang_event_globals.bindings_rwlock); for (ptr = bindings.head; ptr && ptr->next; ptr = ptr->next); @@ -969,7 +969,7 @@ static switch_status_t handle_msg_bind(listener_t *listener, erlang_msg * msg, e } switch_xml_set_binding_sections(bindings.search_binding, switch_xml_get_binding_sections(bindings.search_binding) | section); - switch_thread_rwlock_unlock(globals.bindings_rwlock); + switch_thread_rwlock_unlock(mod_erlang_event_globals.bindings_rwlock); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "sections %d\n", switch_xml_get_binding_sections(bindings.search_binding)); diff --git a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c index 4bbe05a4dd..2cc7d680e3 100644 --- a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c +++ b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c @@ -62,7 +62,7 @@ static switch_status_t socket_logger(const switch_log_node_t *node, switch_log_l { listener_t *l; - switch_thread_rwlock_rdlock(globals.listener_rwlock); + switch_thread_rwlock_rdlock(mod_erlang_event_globals.listener_rwlock); for (l = listen_list.listeners; l; l = l->next) { if (switch_test_flag(l, LFLAG_LOG) && l->level >= node->level) { @@ -87,7 +87,7 @@ static switch_status_t socket_logger(const switch_log_node_t *node, switch_log_l } } - switch_thread_rwlock_unlock(globals.listener_rwlock); + switch_thread_rwlock_unlock(mod_erlang_event_globals.listener_rwlock); return SWITCH_STATUS_SUCCESS; } @@ -97,7 +97,7 @@ static void remove_binding(listener_t *listener, erlang_pid * pid) { struct erlang_binding *ptr, *lst = NULL; - switch_thread_rwlock_wrlock(globals.bindings_rwlock); + switch_thread_rwlock_wrlock(mod_erlang_event_globals.bindings_rwlock); switch_xml_set_binding_sections(bindings.search_binding, SWITCH_XML_SECTION_MAX); @@ -124,7 +124,7 @@ static void remove_binding(listener_t *listener, erlang_pid * pid) } } - switch_thread_rwlock_unlock(globals.bindings_rwlock); + switch_thread_rwlock_unlock(mod_erlang_event_globals.bindings_rwlock); } @@ -185,7 +185,7 @@ static void event_handler(switch_event_t *event) return; } - switch_thread_rwlock_rdlock(globals.listener_rwlock); + switch_thread_rwlock_rdlock(mod_erlang_event_globals.listener_rwlock); lp = listen_list.listeners; @@ -304,7 +304,7 @@ static void event_handler(switch_event_t *event) } } - switch_thread_rwlock_unlock(globals.listener_rwlock); + switch_thread_rwlock_unlock(mod_erlang_event_globals.listener_rwlock); } @@ -322,10 +322,10 @@ static void close_socket(switch_socket_t ** sock) static void add_listener(listener_t *listener) { /* add me to the listeners so I get events */ - switch_thread_rwlock_wrlock(globals.listener_rwlock); + switch_thread_rwlock_wrlock(mod_erlang_event_globals.listener_rwlock); listener->next = listen_list.listeners; listen_list.listeners = listener; - switch_thread_rwlock_unlock(globals.listener_rwlock); + switch_thread_rwlock_unlock(mod_erlang_event_globals.listener_rwlock); } @@ -333,7 +333,7 @@ static void remove_listener(listener_t *listener) { listener_t *l, *last = NULL; - switch_thread_rwlock_wrlock(globals.listener_rwlock); + switch_thread_rwlock_wrlock(mod_erlang_event_globals.listener_rwlock); for (l = listen_list.listeners; l; l = l->next) { if (l == listener) { if (last) { @@ -344,7 +344,7 @@ static void remove_listener(listener_t *listener) } last = l; } - switch_thread_rwlock_unlock(globals.listener_rwlock); + switch_thread_rwlock_unlock(mod_erlang_event_globals.listener_rwlock); } /* Search for a listener already talking to the specified node and lock for reading*/ @@ -352,14 +352,14 @@ static listener_t *find_listener(char *nodename) { listener_t *l = NULL; - switch_thread_rwlock_rdlock(globals.listener_rwlock); + switch_thread_rwlock_rdlock(mod_erlang_event_globals.listener_rwlock); for (l = listen_list.listeners; l; l = l->next) { if (!strncmp(nodename, l->peer_nodename, MAXNODELEN)) { switch_thread_rwlock_rdlock(l->rwlock); break; } } - switch_thread_rwlock_unlock(globals.listener_rwlock); + switch_thread_rwlock_unlock(mod_erlang_event_globals.listener_rwlock); return l; } @@ -465,7 +465,7 @@ static fetch_reply_t *new_fetch_reply(const char *uuid_str) reply->reply = NULL; switch_mutex_lock(reply->mutex); - switch_core_hash_insert_locked(globals.fetch_reply_hash, uuid_str, reply, globals.fetch_reply_mutex); + switch_core_hash_insert_locked(mod_erlang_event_globals.fetch_reply_hash, uuid_str, reply, mod_erlang_event_globals.fetch_reply_mutex); reply->state = reply_waiting; return reply; @@ -473,7 +473,7 @@ static fetch_reply_t *new_fetch_reply(const char *uuid_str) static void destroy_fetch_reply(fetch_reply_t *reply) { - switch_core_hash_delete_locked(globals.fetch_reply_hash, reply->uuid_str, globals.fetch_reply_mutex); + switch_core_hash_delete_locked(mod_erlang_event_globals.fetch_reply_hash, reply->uuid_str, mod_erlang_event_globals.fetch_reply_mutex); /* lock so nothing can have it while we delete it */ switch_mutex_lock(reply->mutex); switch_mutex_unlock(reply->mutex); @@ -488,13 +488,13 @@ fetch_reply_t *find_fetch_reply(const char *uuid) { fetch_reply_t *reply = NULL; - switch_mutex_lock(globals.fetch_reply_mutex); - if ((reply = switch_core_hash_find(globals.fetch_reply_hash, uuid))) { + switch_mutex_lock(mod_erlang_event_globals.fetch_reply_mutex); + if ((reply = switch_core_hash_find(mod_erlang_event_globals.fetch_reply_hash, uuid))) { if (switch_mutex_lock(reply->mutex) != SWITCH_STATUS_SUCCESS) { reply = NULL; } } - switch_mutex_unlock(globals.fetch_reply_mutex); + switch_mutex_unlock(mod_erlang_event_globals.fetch_reply_mutex); return reply; } @@ -530,10 +530,10 @@ static switch_xml_t erlang_fetch(const char *sectionstr, const char *tag_name, c section = switch_xml_parse_section_string((char *) sectionstr); - switch_thread_rwlock_rdlock(globals.bindings_rwlock); + switch_thread_rwlock_rdlock(mod_erlang_event_globals.bindings_rwlock); /* Keep the listener from getting pulled out from under us */ - switch_thread_rwlock_rdlock(globals.listener_rwlock); + switch_thread_rwlock_rdlock(mod_erlang_event_globals.listener_rwlock); for (ptr = bindings.head; ptr; ptr = ptr->next) { /* If we got listener_rwlock while a listner thread was dying after removing the listener @@ -570,8 +570,8 @@ static switch_xml_t erlang_fetch(const char *sectionstr, const char *tag_name, c switch_mutex_unlock(ptr->listener->sock_mutex); } - switch_thread_rwlock_unlock(globals.bindings_rwlock); - switch_thread_rwlock_unlock(globals.listener_rwlock); + switch_thread_rwlock_unlock(mod_erlang_event_globals.bindings_rwlock); + switch_thread_rwlock_unlock(mod_erlang_event_globals.listener_rwlock); ei_x_free(&buf); @@ -612,7 +612,7 @@ static switch_xml_t erlang_fetch(const char *sectionstr, const char *tag_name, c ei_decode_string_or_binary(rep->buff, &rep->index, size, xmlstr); - if (globals.debug) { + if (mod_erlang_event_globals.debug) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "got data %s after %d milliseconds from %s for %s!\n", xmlstr, (int) (switch_micro_time_now() - now) / 1000, p->winner, uuid_str); } @@ -1124,9 +1124,9 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj) { listener_t *listener = (listener_t *) obj; - switch_mutex_lock(globals.listener_count_mutex); + switch_mutex_lock(mod_erlang_event_globals.listener_count_mutex); prefs.threads++; - switch_mutex_unlock(globals.listener_count_mutex); + switch_mutex_unlock(mod_erlang_event_globals.listener_count_mutex); switch_assert(listener != NULL); @@ -1146,9 +1146,9 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj) remove_listener(listener); destroy_listener(listener); - switch_mutex_lock(globals.listener_count_mutex); + switch_mutex_lock(mod_erlang_event_globals.listener_count_mutex); prefs.threads--; - switch_mutex_unlock(globals.listener_count_mutex); + switch_mutex_unlock(mod_erlang_event_globals.listener_count_mutex); return NULL; } @@ -1794,7 +1794,7 @@ SWITCH_STANDARD_API(erlang_cmd) if (!strcasecmp(argv[0], "listeners")) { listener_t *l; - switch_thread_rwlock_rdlock(globals.listener_rwlock); + switch_thread_rwlock_rdlock(mod_erlang_event_globals.listener_rwlock); if (listen_list.listeners) { for (l = listen_list.listeners; l; l = l->next) { @@ -1808,12 +1808,12 @@ SWITCH_STANDARD_API(erlang_cmd) stream->write_function(stream, "No active listeners\n"); } - switch_thread_rwlock_unlock(globals.listener_rwlock); + switch_thread_rwlock_unlock(mod_erlang_event_globals.listener_rwlock); } else if (!strcasecmp(argv[0], "sessions") && argc == 2) { listener_t *l; int found = 0; - switch_thread_rwlock_rdlock(globals.listener_rwlock); + switch_thread_rwlock_rdlock(mod_erlang_event_globals.listener_rwlock); for (l = listen_list.listeners; l; l = l->next) { if (!strcasecmp(l->peer_nodename, argv[1])) { session_elem_t *sp; @@ -1839,7 +1839,7 @@ SWITCH_STANDARD_API(erlang_cmd) break; } } - switch_thread_rwlock_unlock(globals.listener_rwlock); + switch_thread_rwlock_unlock(mod_erlang_event_globals.listener_rwlock); if (!found) stream->write_function(stream, "Could not find a listener for %s\n", argv[1]); @@ -1847,7 +1847,7 @@ SWITCH_STANDARD_API(erlang_cmd) } else if (!strcasecmp(argv[0], "handlers")) { listener_t *l; - switch_thread_rwlock_rdlock(globals.listener_rwlock); + switch_thread_rwlock_rdlock(mod_erlang_event_globals.listener_rwlock); if (listen_list.listeners) { for (l = listen_list.listeners; l; l = l->next) { @@ -1875,12 +1875,12 @@ SWITCH_STANDARD_API(erlang_cmd) stream->write_function(stream, "No active handlers\n"); } - switch_thread_rwlock_unlock(globals.listener_rwlock); + switch_thread_rwlock_unlock(mod_erlang_event_globals.listener_rwlock); } else if (!strcasecmp(argv[0], "bindings")) { int found = 0; struct erlang_binding *ptr; - switch_thread_rwlock_rdlock(globals.bindings_rwlock); + switch_thread_rwlock_rdlock(mod_erlang_event_globals.bindings_rwlock); for (ptr = bindings.head; ptr; ptr = ptr->next) { @@ -1904,7 +1904,7 @@ SWITCH_STANDARD_API(erlang_cmd) found++; } - switch_thread_rwlock_unlock(globals.bindings_rwlock); + switch_thread_rwlock_unlock(mod_erlang_event_globals.bindings_rwlock); if (!found) { stream->write_function(stream, "No bindings\n"); @@ -1913,12 +1913,12 @@ SWITCH_STANDARD_API(erlang_cmd) } else if (!strcasecmp(argv[0], "debug")) { if (argc == 2) { if (!strcasecmp(argv[1], "on")) { - globals.debug = 1; + mod_erlang_event_globals.debug = 1; } else { - globals.debug = 0; + mod_erlang_event_globals.debug = 0; } } - stream->write_function(stream, "+OK debug %s\n", globals.debug ? "on" : "off"); + stream->write_function(stream, "+OK debug %s\n", mod_erlang_event_globals.debug ? "on" : "off"); } else { stream->write_function(stream, usage_string); @@ -1939,21 +1939,21 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_erlang_event_load) memset(&prefs, 0, sizeof(prefs)); - switch_thread_rwlock_create(&globals.listener_rwlock, pool); - switch_thread_rwlock_create(&globals.bindings_rwlock, pool); - switch_mutex_init(&globals.fetch_reply_mutex, SWITCH_MUTEX_DEFAULT, pool); - switch_mutex_init(&globals.listener_count_mutex, SWITCH_MUTEX_UNNESTED, pool); - switch_mutex_init(&globals.listener_mutex, SWITCH_MUTEX_NESTED, pool); - switch_core_hash_init(&globals.fetch_reply_hash); + switch_thread_rwlock_create(&mod_erlang_event_globals.listener_rwlock, pool); + switch_thread_rwlock_create(&mod_erlang_event_globals.bindings_rwlock, pool); + switch_mutex_init(&mod_erlang_event_globals.fetch_reply_mutex, SWITCH_MUTEX_DEFAULT, pool); + switch_mutex_init(&mod_erlang_event_globals.listener_count_mutex, SWITCH_MUTEX_UNNESTED, pool); + switch_mutex_init(&mod_erlang_event_globals.listener_mutex, SWITCH_MUTEX_NESTED, pool); + switch_core_hash_init(&mod_erlang_event_globals.fetch_reply_hash); /* intialize the unique reference stuff */ switch_mutex_init(&listen_list.sock_mutex, SWITCH_MUTEX_NESTED, pool); - switch_mutex_init(&globals.ref_mutex, SWITCH_MUTEX_NESTED, pool); - globals.reference0 = 0; - globals.reference1 = 0; - globals.reference2 = 0; + switch_mutex_init(&mod_erlang_event_globals.ref_mutex, SWITCH_MUTEX_NESTED, pool); + mod_erlang_event_globals.reference0 = 0; + mod_erlang_event_globals.reference1 = 0; + mod_erlang_event_globals.reference2 = 0; - if (switch_event_bind_removable(modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL, &globals.node) != SWITCH_STATUS_SUCCESS) { + if (switch_event_bind_removable(modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL, &mod_erlang_event_globals.node) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind to all events!\n"); close_socket(&listen_list.sock); return SWITCH_STATUS_GENERR; @@ -2181,10 +2181,10 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_erlang_event_shutdown) } } - switch_event_unbind(&globals.node); + switch_event_unbind(&mod_erlang_event_globals.node); switch_xml_unbind_search_function_ptr(erlang_fetch); - switch_thread_rwlock_wrlock(globals.listener_rwlock); + switch_thread_rwlock_wrlock(mod_erlang_event_globals.listener_rwlock); for (l = listen_list.listeners; l; l = l->next) { switch_os_sock_put(&sock, &l->sockdes, l->pool); @@ -2196,7 +2196,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_erlang_event_shutdown) WSACleanup(); #endif - switch_thread_rwlock_unlock(globals.listener_rwlock); + switch_thread_rwlock_unlock(mod_erlang_event_globals.listener_rwlock); switch_sleep(1500000); /* sleep for 1.5 seconds */ diff --git a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h index 2761c1848d..3ec5e5aad5 100644 --- a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h +++ b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h @@ -222,12 +222,12 @@ typedef struct prefs_struct prefs_t; /* shared globals */ #ifdef DEFINE_GLOBALS -globals_t globals; +globals_t mod_erlang_event_globals; listen_list_t listen_list; bindings_t bindings; prefs_t prefs; #else -extern globals_t globals; +extern globals_t mod_erlang_event_globals; extern listen_list_t listen_list; extern bindings_t bindings; extern prefs_t prefs; diff --git a/src/mod/event_handlers/mod_kazoo/kazoo_event_stream.c b/src/mod/event_handlers/mod_kazoo/kazoo_event_stream.c index 06874cd48d..3ca0e3acc7 100644 --- a/src/mod/event_handlers/mod_kazoo/kazoo_event_stream.c +++ b/src/mod/event_handlers/mod_kazoo/kazoo_event_stream.c @@ -73,11 +73,11 @@ static switch_status_t kazoo_event_dup(switch_event_t **clone, switch_event_t *e continue; } - if (strncmp(header->name, globals.kazoo_var_prefix, globals.var_prefix_length) + if (strncmp(header->name, kazoo_globals.kazoo_var_prefix, kazoo_globals.var_prefix_length) && filter && !switch_core_hash_find(filter, header->name) - && (!globals.send_all_headers) - && (!(globals.send_all_private_headers && is_private_header(header->name))) + && (!kazoo_globals.send_all_headers) + && (!(kazoo_globals.send_all_private_headers && is_private_header(header->name))) ) { continue; @@ -107,7 +107,7 @@ static void event_handler(switch_event_t *event) { ei_event_stream_t *event_stream = (ei_event_stream_t *) event->bind_user_data; /* if mod_kazoo or the event stream isn't running dont push a new event */ - if (!switch_test_flag(event_stream, LFLAG_RUNNING) || !switch_test_flag(&globals, LFLAG_RUNNING)) { + if (!switch_test_flag(event_stream, LFLAG_RUNNING) || !switch_test_flag(&kazoo_globals, LFLAG_RUNNING)) { return; } @@ -138,7 +138,7 @@ static void event_handler(switch_event_t *event) { /* try to clone the event and push it to the event stream thread */ /* TODO: someday maybe the filter comes from the event_stream (set during init only) * and is per-binding so we only send headers that a process requests */ - if (kazoo_event_dup(&clone, event, globals.event_filter) == SWITCH_STATUS_SUCCESS) { + if (kazoo_event_dup(&clone, event, kazoo_globals.event_filter) == SWITCH_STATUS_SUCCESS) { if (switch_queue_trypush(event_stream->queue, clone) != SWITCH_STATUS_SUCCESS) { /* if we couldn't place the cloned event into the listeners */ /* event queue make sure we destroy it, real good like */ @@ -157,9 +157,9 @@ static void *SWITCH_THREAD_FUNC event_stream_loop(switch_thread_t *thread, void char ipbuf[48]; const char *ip_addr; void *pop; - short event_stream_framing = globals.event_stream_framing; + short event_stream_framing = kazoo_globals.event_stream_framing; - switch_atomic_inc(&globals.threads); + switch_atomic_inc(&kazoo_globals.threads); switch_assert(event_stream != NULL); @@ -172,7 +172,7 @@ static void *SWITCH_THREAD_FUNC event_stream_loop(switch_thread_t *thread, void ,(void *)event_stream, ip_addr, port, event_stream->pid.node, event_stream->pid.creation ,event_stream->pid.num, event_stream->pid.serial); - while (switch_test_flag(event_stream, LFLAG_RUNNING) && switch_test_flag(&globals, LFLAG_RUNNING)) { + while (switch_test_flag(event_stream, LFLAG_RUNNING) && switch_test_flag(&kazoo_globals, LFLAG_RUNNING)) { const switch_pollfd_t *fds; int32_t numfds; @@ -226,9 +226,9 @@ static void *SWITCH_THREAD_FUNC event_stream_loop(switch_thread_t *thread, void short i = event_stream_framing; switch_size_t size = 1; - if(globals.event_stream_preallocate > 0) { - ebuf.buff = malloc(globals.event_stream_preallocate); - ebuf.buffsz = globals.event_stream_preallocate; + if(kazoo_globals.event_stream_preallocate > 0) { + ebuf.buff = malloc(kazoo_globals.event_stream_preallocate); + ebuf.buffsz = kazoo_globals.event_stream_preallocate; ebuf.index = 0; if(ebuf.buff == NULL) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not pre-allocate memory for mod_kazoo message\n"); @@ -241,7 +241,7 @@ static void *SWITCH_THREAD_FUNC event_stream_loop(switch_thread_t *thread, void ei_encode_switch_event(&ebuf, event); - if (globals.event_stream_preallocate > 0 && ebuf.buffsz > globals.event_stream_preallocate) { + if (kazoo_globals.event_stream_preallocate > 0 && ebuf.buffsz > kazoo_globals.event_stream_preallocate) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "increased event stream buffer size to %d\n", ebuf.buffsz); } @@ -292,7 +292,7 @@ static void *SWITCH_THREAD_FUNC event_stream_loop(switch_thread_t *thread, void /* clean up the memory */ switch_core_destroy_memory_pool(&event_stream->pool); - switch_atomic_dec(&globals.threads); + switch_atomic_dec(&kazoo_globals.threads); return NULL; } diff --git a/src/mod/event_handlers/mod_kazoo/kazoo_fetch_agent.c b/src/mod/event_handlers/mod_kazoo/kazoo_fetch_agent.c index 522722c700..006ffe32f0 100644 --- a/src/mod/event_handlers/mod_kazoo/kazoo_fetch_agent.c +++ b/src/mod/event_handlers/mod_kazoo/kazoo_fetch_agent.c @@ -136,7 +136,7 @@ static switch_xml_t fetch_handler(const char *section, const char *tag_name, con now = switch_micro_time_now(); - if (!switch_test_flag(&globals, LFLAG_RUNNING)) { + if (!switch_test_flag(&kazoo_globals, LFLAG_RUNNING)) { return xml; } @@ -144,7 +144,7 @@ static switch_xml_t fetch_handler(const char *section, const char *tag_name, con switch_thread_rwlock_rdlock(agent->lock); /* serialize access to current, used to round-robin requests */ - /* TODO: check globals for round-robin boolean or loop all clients */ + /* TODO: check kazoo_globals for round-robin boolean or loop all clients */ switch_mutex_lock(agent->current_client_mutex); if (!agent->current_client) { client = agent->clients; @@ -572,31 +572,31 @@ static switch_status_t handle_api_command_stream(ei_node_t *ei_node, switch_stre } switch_status_t bind_fetch_agents() { - bind_fetch_agent(SWITCH_XML_SECTION_CONFIG, &globals.config_fetch_binding); - bind_fetch_agent(SWITCH_XML_SECTION_DIRECTORY, &globals.directory_fetch_binding); - bind_fetch_agent(SWITCH_XML_SECTION_DIALPLAN, &globals.dialplan_fetch_binding); - bind_fetch_agent(SWITCH_XML_SECTION_CHATPLAN, &globals.chatplan_fetch_binding); - bind_fetch_agent(SWITCH_XML_SECTION_CHANNELS, &globals.channels_fetch_binding); + bind_fetch_agent(SWITCH_XML_SECTION_CONFIG, &kazoo_globals.config_fetch_binding); + bind_fetch_agent(SWITCH_XML_SECTION_DIRECTORY, &kazoo_globals.directory_fetch_binding); + bind_fetch_agent(SWITCH_XML_SECTION_DIALPLAN, &kazoo_globals.dialplan_fetch_binding); + bind_fetch_agent(SWITCH_XML_SECTION_CHATPLAN, &kazoo_globals.chatplan_fetch_binding); + bind_fetch_agent(SWITCH_XML_SECTION_CHANNELS, &kazoo_globals.channels_fetch_binding); return SWITCH_STATUS_SUCCESS; } switch_status_t unbind_fetch_agents() { - unbind_fetch_agent(&globals.config_fetch_binding); - unbind_fetch_agent(&globals.directory_fetch_binding); - unbind_fetch_agent(&globals.dialplan_fetch_binding); - unbind_fetch_agent(&globals.chatplan_fetch_binding); - unbind_fetch_agent(&globals.channels_fetch_binding); + unbind_fetch_agent(&kazoo_globals.config_fetch_binding); + unbind_fetch_agent(&kazoo_globals.directory_fetch_binding); + unbind_fetch_agent(&kazoo_globals.dialplan_fetch_binding); + unbind_fetch_agent(&kazoo_globals.chatplan_fetch_binding); + unbind_fetch_agent(&kazoo_globals.channels_fetch_binding); return SWITCH_STATUS_SUCCESS; } switch_status_t remove_xml_clients(ei_node_t *ei_node) { - remove_xml_client(ei_node, globals.config_fetch_binding); - remove_xml_client(ei_node, globals.directory_fetch_binding); - remove_xml_client(ei_node, globals.dialplan_fetch_binding); - remove_xml_client(ei_node, globals.chatplan_fetch_binding); - remove_xml_client(ei_node, globals.channels_fetch_binding); + remove_xml_client(ei_node, kazoo_globals.config_fetch_binding); + remove_xml_client(ei_node, kazoo_globals.directory_fetch_binding); + remove_xml_client(ei_node, kazoo_globals.dialplan_fetch_binding); + remove_xml_client(ei_node, kazoo_globals.chatplan_fetch_binding); + remove_xml_client(ei_node, kazoo_globals.channels_fetch_binding); return SWITCH_STATUS_SUCCESS; } @@ -644,17 +644,17 @@ switch_status_t add_fetch_handler(ei_node_t *ei_node, erlang_pid *from, switch_x switch_thread_rwlock_unlock(agent->lock); - ei_link(ei_node, ei_self(&globals.ei_cnode), from); + ei_link(ei_node, ei_self(&kazoo_globals.ei_cnode), from); return SWITCH_STATUS_SUCCESS; } switch_status_t remove_fetch_handlers(ei_node_t *ei_node, erlang_pid *from) { - remove_fetch_handler(ei_node, from, globals.config_fetch_binding); - remove_fetch_handler(ei_node, from, globals.directory_fetch_binding); - remove_fetch_handler(ei_node, from, globals.dialplan_fetch_binding); - remove_fetch_handler(ei_node, from, globals.chatplan_fetch_binding); - remove_fetch_handler(ei_node, from, globals.channels_fetch_binding); + remove_fetch_handler(ei_node, from, kazoo_globals.config_fetch_binding); + remove_fetch_handler(ei_node, from, kazoo_globals.directory_fetch_binding); + remove_fetch_handler(ei_node, from, kazoo_globals.dialplan_fetch_binding); + remove_fetch_handler(ei_node, from, kazoo_globals.chatplan_fetch_binding); + remove_fetch_handler(ei_node, from, kazoo_globals.channels_fetch_binding); return SWITCH_STATUS_SUCCESS; } @@ -686,11 +686,11 @@ switch_status_t fetch_reply(char *uuid_str, char *xml_str, switch_xml_binding_t } switch_status_t handle_api_command_streams(ei_node_t *ei_node, switch_stream_handle_t *stream) { - handle_api_command_stream(ei_node, stream, globals.config_fetch_binding); - handle_api_command_stream(ei_node, stream, globals.directory_fetch_binding); - handle_api_command_stream(ei_node, stream, globals.dialplan_fetch_binding); - handle_api_command_stream(ei_node, stream, globals.chatplan_fetch_binding); - handle_api_command_stream(ei_node, stream, globals.channels_fetch_binding); + handle_api_command_stream(ei_node, stream, kazoo_globals.config_fetch_binding); + handle_api_command_stream(ei_node, stream, kazoo_globals.directory_fetch_binding); + handle_api_command_stream(ei_node, stream, kazoo_globals.dialplan_fetch_binding); + handle_api_command_stream(ei_node, stream, kazoo_globals.chatplan_fetch_binding); + handle_api_command_stream(ei_node, stream, kazoo_globals.channels_fetch_binding); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/event_handlers/mod_kazoo/kazoo_node.c b/src/mod/event_handlers/mod_kazoo/kazoo_node.c index de8b16420a..ed4ed0f0fd 100644 --- a/src/mod/event_handlers/mod_kazoo/kazoo_node.c +++ b/src/mod/event_handlers/mod_kazoo/kazoo_node.c @@ -142,16 +142,16 @@ static void destroy_node_handler(ei_node_t *ei_node) { } static switch_status_t add_to_ei_nodes(ei_node_t *this_ei_node) { - switch_thread_rwlock_wrlock(globals.ei_nodes_lock); + switch_thread_rwlock_wrlock(kazoo_globals.ei_nodes_lock); - if (!globals.ei_nodes) { - globals.ei_nodes = this_ei_node; + if (!kazoo_globals.ei_nodes) { + kazoo_globals.ei_nodes = this_ei_node; } else { - this_ei_node->next = globals.ei_nodes; - globals.ei_nodes = this_ei_node; + this_ei_node->next = kazoo_globals.ei_nodes; + kazoo_globals.ei_nodes = this_ei_node; } - switch_thread_rwlock_unlock(globals.ei_nodes_lock); + switch_thread_rwlock_unlock(kazoo_globals.ei_nodes_lock); return SWITCH_STATUS_SUCCESS; } @@ -160,10 +160,10 @@ static switch_status_t remove_from_ei_nodes(ei_node_t *this_ei_node) { ei_node_t *ei_node, *prev = NULL; int found = 0; - switch_thread_rwlock_wrlock(globals.ei_nodes_lock); + switch_thread_rwlock_wrlock(kazoo_globals.ei_nodes_lock); /* try to find the event bindings list for the requestor */ - ei_node = globals.ei_nodes; + ei_node = kazoo_globals.ei_nodes; while(ei_node != NULL) { if (ei_node == this_ei_node) { found = 1; @@ -176,13 +176,13 @@ static switch_status_t remove_from_ei_nodes(ei_node_t *this_ei_node) { if (found) { if (!prev) { - globals.ei_nodes = this_ei_node->next; + kazoo_globals.ei_nodes = this_ei_node->next; } else { prev->next = ei_node->next; } } - switch_thread_rwlock_unlock(globals.ei_nodes_lock); + switch_thread_rwlock_unlock(kazoo_globals.ei_nodes_lock); return SWITCH_STATUS_SUCCESS; } @@ -301,7 +301,7 @@ static void *SWITCH_THREAD_FUNC bgapi3_exec(switch_thread_t *thread, void *obj) switch_malloc(send_msg, sizeof(*send_msg)); memcpy(&send_msg->pid, &acs->pid, sizeof(erlang_pid)); - if(!switch_test_flag(ei_node, LFLAG_RUNNING) || !switch_test_flag(&globals, LFLAG_RUNNING)) { + if(!switch_test_flag(ei_node, LFLAG_RUNNING) || !switch_test_flag(&kazoo_globals, LFLAG_RUNNING)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ignoring command while shuting down\n"); switch_atomic_dec(&ei_node->pending_bgapi); return NULL; @@ -351,7 +351,7 @@ static void *SWITCH_THREAD_FUNC bgapi4_exec(switch_thread_t *thread, void *obj) ei_send_msg_t *send_msg; switch_stream_handle_t stream = { 0 }; - if(!switch_test_flag(ei_node, LFLAG_RUNNING) || !switch_test_flag(&globals, LFLAG_RUNNING)) { + if(!switch_test_flag(ei_node, LFLAG_RUNNING) || !switch_test_flag(&kazoo_globals, LFLAG_RUNNING)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ignoring command while shuting down\n"); switch_atomic_dec(&ei_node->pending_bgapi); return NULL; @@ -544,7 +544,7 @@ static switch_status_t handle_request_exit(ei_node_t *ei_node, erlang_pid *pid, } static switch_status_t handle_request_link(ei_node_t *ei_node, erlang_pid *pid, ei_x_buff *buf, ei_x_buff *rbuf) { - ei_link(ei_node, ei_self(&globals.ei_cnode), pid); + ei_link(ei_node, ei_self(&kazoo_globals.ei_cnode), pid); return erlang_response_ok(rbuf); } @@ -674,21 +674,21 @@ static switch_status_t handle_request_bind(ei_node_t *ei_node, erlang_pid *pid, switch(section) { case SWITCH_XML_SECTION_CONFIG: - add_fetch_handler(ei_node, pid, globals.config_fetch_binding); - if(!globals.config_filters_fetched) + add_fetch_handler(ei_node, pid, kazoo_globals.config_fetch_binding); + if(!kazoo_globals.config_filters_fetched) fetch_config_filters(); break; case SWITCH_XML_SECTION_DIRECTORY: - add_fetch_handler(ei_node, pid, globals.directory_fetch_binding); + add_fetch_handler(ei_node, pid, kazoo_globals.directory_fetch_binding); break; case SWITCH_XML_SECTION_DIALPLAN: - add_fetch_handler(ei_node, pid, globals.dialplan_fetch_binding); + add_fetch_handler(ei_node, pid, kazoo_globals.dialplan_fetch_binding); break; case SWITCH_XML_SECTION_CHATPLAN: - add_fetch_handler(ei_node, pid, globals.chatplan_fetch_binding); + add_fetch_handler(ei_node, pid, kazoo_globals.chatplan_fetch_binding); break; case SWITCH_XML_SECTION_CHANNELS: - add_fetch_handler(ei_node, pid, globals.channels_fetch_binding); + add_fetch_handler(ei_node, pid, kazoo_globals.channels_fetch_binding); break; default: return erlang_response_badarg(rbuf); @@ -701,7 +701,7 @@ static switch_status_t handle_request_getpid(ei_node_t *ei_node, erlang_pid *pid if (rbuf) { ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "ok"); - ei_x_encode_pid(rbuf, ei_self(&globals.ei_cnode)); + ei_x_encode_pid(rbuf, ei_self(&kazoo_globals.ei_cnode)); } return SWITCH_STATUS_SUCCESS; @@ -870,7 +870,7 @@ static switch_status_t handle_request_event(ei_node_t *ei_node, erlang_pid *pid, if (!(event_stream = find_event_stream(ei_node->event_streams, pid))) { event_stream = new_event_stream(&ei_node->event_streams, pid); /* ensure we are notified if the requesting processes dies so we can clean up */ - ei_link(ei_node, ei_self(&globals.ei_cnode), pid); + ei_link(ei_node, ei_self(&kazoo_globals.ei_cnode), pid); } for (int i = 1; i <= length; i++) { @@ -947,19 +947,19 @@ static switch_status_t handle_request_fetch_reply(ei_node_t *ei_node, erlang_pid switch(section) { case SWITCH_XML_SECTION_CONFIG: - result = fetch_reply(uuid_str, xml_str, globals.config_fetch_binding); + result = fetch_reply(uuid_str, xml_str, kazoo_globals.config_fetch_binding); break; case SWITCH_XML_SECTION_DIRECTORY: - result = fetch_reply(uuid_str, xml_str, globals.directory_fetch_binding); + result = fetch_reply(uuid_str, xml_str, kazoo_globals.directory_fetch_binding); break; case SWITCH_XML_SECTION_DIALPLAN: - result = fetch_reply(uuid_str, xml_str, globals.dialplan_fetch_binding); + result = fetch_reply(uuid_str, xml_str, kazoo_globals.dialplan_fetch_binding); break; case SWITCH_XML_SECTION_CHATPLAN: - result = fetch_reply(uuid_str, xml_str, globals.chatplan_fetch_binding); + result = fetch_reply(uuid_str, xml_str, kazoo_globals.chatplan_fetch_binding); break; case SWITCH_XML_SECTION_CHANNELS: - result = fetch_reply(uuid_str, xml_str, globals.channels_fetch_binding); + result = fetch_reply(uuid_str, xml_str, kazoo_globals.channels_fetch_binding); break; default: switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Recieved fetch reply for an unknown configuration section: %s\n", section_str); @@ -1252,14 +1252,14 @@ static switch_status_t handle_erl_msg(ei_node_t *ei_node, erlang_msg *msg, ei_x_ static void *SWITCH_THREAD_FUNC receive_handler(switch_thread_t *thread, void *obj) { ei_node_t *ei_node = (ei_node_t *) obj; - switch_atomic_inc(&globals.threads); + switch_atomic_inc(&kazoo_globals.threads); switch_atomic_inc(&ei_node->receive_handlers); switch_assert(ei_node != NULL); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Starting erlang receive handler %p: %s (%s:%d)\n", (void *)ei_node, ei_node->peer_nodename, ei_node->remote_ip, ei_node->remote_port); - while (switch_test_flag(ei_node, LFLAG_RUNNING) && switch_test_flag(&globals, LFLAG_RUNNING)) { + while (switch_test_flag(ei_node, LFLAG_RUNNING) && switch_test_flag(&kazoo_globals, LFLAG_RUNNING)) { void *pop; if (switch_queue_pop_timeout(ei_node->received_msgs, &pop, 500000) == SWITCH_STATUS_SUCCESS) { @@ -1273,7 +1273,7 @@ static void *SWITCH_THREAD_FUNC receive_handler(switch_thread_t *thread, void *o switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Shutdown erlang receive handler %p: %s (%s:%d)\n", (void *)ei_node, ei_node->peer_nodename, ei_node->remote_ip, ei_node->remote_port); switch_atomic_dec(&ei_node->receive_handlers); - switch_atomic_dec(&globals.threads); + switch_atomic_dec(&kazoo_globals.threads); return NULL; } @@ -1283,7 +1283,7 @@ static void *SWITCH_THREAD_FUNC handle_node(switch_thread_t *thread, void *obj) ei_received_msg_t *received_msg = NULL; int fault_count = 0; - switch_atomic_inc(&globals.threads); + switch_atomic_inc(&kazoo_globals.threads); switch_assert(ei_node != NULL); @@ -1291,7 +1291,7 @@ static void *SWITCH_THREAD_FUNC handle_node(switch_thread_t *thread, void *obj) add_to_ei_nodes(ei_node); - while (switch_test_flag(ei_node, LFLAG_RUNNING) && switch_test_flag(&globals, LFLAG_RUNNING)) { + while (switch_test_flag(ei_node, LFLAG_RUNNING) && switch_test_flag(&kazoo_globals, LFLAG_RUNNING)) { int status; int send_msg_count = 0; void *pop; @@ -1299,9 +1299,9 @@ static void *SWITCH_THREAD_FUNC handle_node(switch_thread_t *thread, void *obj) if (!received_msg) { switch_malloc(received_msg, sizeof(*received_msg)); /* create a new buf for the erlang message and a rbuf for the reply */ - if(globals.receive_msg_preallocate > 0) { - received_msg->buf.buff = malloc(globals.receive_msg_preallocate); - received_msg->buf.buffsz = globals.receive_msg_preallocate; + if(kazoo_globals.receive_msg_preallocate > 0) { + received_msg->buf.buff = malloc(kazoo_globals.receive_msg_preallocate); + received_msg->buf.buffsz = kazoo_globals.receive_msg_preallocate; received_msg->buf.index = 0; if(received_msg->buf.buff == NULL) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not pre-allocate memory for mod_kazoo message\n"); @@ -1313,7 +1313,7 @@ static void *SWITCH_THREAD_FUNC handle_node(switch_thread_t *thread, void *obj) } while (switch_queue_trypop(ei_node->send_msgs, &pop) == SWITCH_STATUS_SUCCESS - && ++send_msg_count <= globals.send_msg_batch) { + && ++send_msg_count <= kazoo_globals.send_msg_batch) { ei_send_msg_t *send_msg = (ei_send_msg_t *) pop; ei_helper_send(ei_node, &send_msg->pid, &send_msg->buf); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sent erlang message to %s <%d.%d.%d>\n" @@ -1326,7 +1326,7 @@ static void *SWITCH_THREAD_FUNC handle_node(switch_thread_t *thread, void *obj) } /* wait for a erlang message, or timeout to check if the module is still running */ - status = ei_xreceive_msg_tmo(ei_node->nodefd, &received_msg->msg, &received_msg->buf, globals.receive_timeout); + status = ei_xreceive_msg_tmo(ei_node->nodefd, &received_msg->msg, &received_msg->buf, kazoo_globals.receive_timeout); switch (status) { case ERL_TICK: @@ -1340,7 +1340,7 @@ static void *SWITCH_THREAD_FUNC handle_node(switch_thread_t *thread, void *obj) switch_safe_free(received_msg); } - if (globals.receive_msg_preallocate > 0 && received_msg->buf.buffsz > globals.receive_msg_preallocate) { + if (kazoo_globals.receive_msg_preallocate > 0 && received_msg->buf.buffsz > kazoo_globals.receive_msg_preallocate) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "increased received message buffer size to %d\n", received_msg->buf.buffsz); } @@ -1360,7 +1360,7 @@ static void *SWITCH_THREAD_FUNC handle_node(switch_thread_t *thread, void *obj) case EIO: switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Erlang communication fault with node %p %s (%s:%d): socket closed or I/O error [fault count %d]\n", (void *)ei_node, ei_node->peer_nodename, ei_node->remote_ip, ei_node->remote_port, ++fault_count); - if (fault_count >= globals.io_fault_tolerance) { + if (fault_count >= kazoo_globals.io_fault_tolerance) { switch_clear_flag(ei_node, LFLAG_RUNNING); } @@ -1397,7 +1397,7 @@ static void *SWITCH_THREAD_FUNC handle_node(switch_thread_t *thread, void *obj) destroy_node_handler(ei_node); - switch_atomic_dec(&globals.threads); + switch_atomic_dec(&kazoo_globals.threads); return NULL; } @@ -1454,7 +1454,7 @@ switch_status_t new_kazoo_node(int nodefd, ErlConnect *conn) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "New erlang connection from node %s (%s:%d)\n", ei_node->peer_nodename, ei_node->remote_ip, ei_node->remote_port); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "New erlang connection to node %s (%s:%d)\n", ei_node->peer_nodename, ei_node->local_ip, ei_node->local_port); - for(i = 0; i < globals.num_worker_threads; i++) { + for(i = 0; i < kazoo_globals.num_worker_threads; i++) { switch_threadattr_create(&thd_attr, ei_node->pool); switch_threadattr_detach_set(thd_attr, 1); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); diff --git a/src/mod/event_handlers/mod_kazoo/kazoo_utils.c b/src/mod/event_handlers/mod_kazoo/kazoo_utils.c index d7ed341048..024e98b858 100644 --- a/src/mod/event_handlers/mod_kazoo/kazoo_utils.c +++ b/src/mod/event_handlers/mod_kazoo/kazoo_utils.c @@ -142,7 +142,7 @@ switch_socket_t *create_socket_with_port(switch_memory_pool_t *pool, switch_port switch_sockaddr_t *sa; switch_socket_t *socket; - if(switch_sockaddr_info_get(&sa, globals.ip, SWITCH_UNSPEC, port, 0, pool)) { + if(switch_sockaddr_info_get(&sa, kazoo_globals.ip, SWITCH_UNSPEC, port, 0, pool)) { return NULL; } @@ -162,9 +162,9 @@ switch_socket_t *create_socket_with_port(switch_memory_pool_t *pool, switch_port return NULL; } - switch_getnameinfo(&globals.hostname, sa, 0); + switch_getnameinfo(&kazoo_globals.hostname, sa, 0); - // if (globals.nat_map && switch_nat_get_type()) { + // if (kazoo_globals.nat_map && switch_nat_get_type()) { // switch_nat_add_mapping(port, SWITCH_NAT_TCP, NULL, SWITCH_FALSE); // } @@ -188,20 +188,20 @@ switch_status_t create_ei_cnode(const char *ip_addr, const char *name, struct ei if ((atsign = strchr(cnodename, '@'))) { /* we got a qualified node name, don't guess the host/domain */ - snprintf(nodename, MAXNODELEN + 1, "%s", globals.ei_nodename); + snprintf(nodename, MAXNODELEN + 1, "%s", kazoo_globals.ei_nodename); /* truncate the alivename at the @ */ *atsign = '\0'; } else { - if (zstr(globals.hostname) || !strncasecmp(globals.ip, "0.0.0.0", 7) || !strncasecmp(globals.ip, "::", 2)) { + if (zstr(kazoo_globals.hostname) || !strncasecmp(kazoo_globals.ip, "0.0.0.0", 7) || !strncasecmp(kazoo_globals.ip, "::", 2)) { memcpy(hostname, switch_core_get_hostname(), EI_MAXHOSTNAMELEN); } else { - memcpy(hostname, globals.hostname, EI_MAXHOSTNAMELEN); + memcpy(hostname, kazoo_globals.hostname, EI_MAXHOSTNAMELEN); } - snprintf(nodename, MAXNODELEN + 1, "%s@%s", globals.ei_nodename, hostname); + snprintf(nodename, MAXNODELEN + 1, "%s@%s", kazoo_globals.ei_nodename, hostname); } - if (globals.ei_shortname) { + if (kazoo_globals.ei_shortname) { char *off; if ((off = strchr(nodename, '.'))) { *off = '\0'; @@ -209,7 +209,7 @@ switch_status_t create_ei_cnode(const char *ip_addr, const char *name, struct ei } /* init the ec stuff */ - if (ei_connect_xinit(ei_cnode, hostname, cnodename, nodename, (Erl_IpAddr) ip_addr, globals.ei_cookie, 0) < 0) { + if (ei_connect_xinit(ei_cnode, hostname, cnodename, nodename, (Erl_IpAddr) ip_addr, kazoo_globals.ei_cookie, 0) < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to initialize the erlang interface connection structure\n"); return SWITCH_STATUS_FALSE; } @@ -654,9 +654,9 @@ static void *SWITCH_THREAD_FUNC fetch_config_filters_exec(switch_thread_t *threa switch_core_hash_insert(filter, var, "1"); } - old_filter = globals.event_filter; - globals.config_filters_fetched = 1; - globals.event_filter = filter; + old_filter = kazoo_globals.event_filter; + kazoo_globals.config_filters_fetched = 1; + kazoo_globals.event_filter = filter; if (old_filter) { switch_core_hash_destroy(&old_filter); } diff --git a/src/mod/event_handlers/mod_kazoo/mod_kazoo.c b/src/mod/event_handlers/mod_kazoo/mod_kazoo.c index e283cb5a96..b666920d3f 100644 --- a/src/mod/event_handlers/mod_kazoo/mod_kazoo.c +++ b/src/mod/event_handlers/mod_kazoo/mod_kazoo.c @@ -35,17 +35,17 @@ #define KAZOO_DESC "kazoo information" #define KAZOO_SYNTAX " []" -globals_t globals; +globals_t kazoo_globals; SWITCH_MODULE_LOAD_FUNCTION(mod_kazoo_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_kazoo_shutdown); SWITCH_MODULE_RUNTIME_FUNCTION(mod_kazoo_runtime); SWITCH_MODULE_DEFINITION(mod_kazoo, mod_kazoo_load, mod_kazoo_shutdown, mod_kazoo_runtime); -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_pref_ip, globals.ip); -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_pref_ei_cookie, globals.ei_cookie); -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_pref_ei_nodename, globals.ei_nodename); -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_pref_kazoo_var_prefix, globals.kazoo_var_prefix); +SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_pref_ip, kazoo_globals.ip); +SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_pref_ei_cookie, kazoo_globals.ei_cookie); +SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_pref_ei_nodename, kazoo_globals.ei_nodename); +SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_pref_kazoo_var_prefix, kazoo_globals.kazoo_var_prefix); static switch_status_t api_erlang_status(switch_stream_handle_t *stream) { switch_sockaddr_t *sa; @@ -54,21 +54,21 @@ static switch_status_t api_erlang_status(switch_stream_handle_t *stream) { const char *ip_addr; ei_node_t *ei_node; - switch_socket_addr_get(&sa, SWITCH_FALSE, globals.acceptor); + switch_socket_addr_get(&sa, SWITCH_FALSE, kazoo_globals.acceptor); port = switch_sockaddr_get_port(sa); ip_addr = switch_get_addr(ipbuf, sizeof (ipbuf), sa); stream->write_function(stream, "Running %s\n", VERSION); - stream->write_function(stream, "Listening for new Erlang connections on %s:%u with cookie %s\n", ip_addr, port, globals.ei_cookie); - stream->write_function(stream, "Registered as Erlang node %s, visible as %s\n", globals.ei_cnode.thisnodename, globals.ei_cnode.thisalivename); + stream->write_function(stream, "Listening for new Erlang connections on %s:%u with cookie %s\n", ip_addr, port, kazoo_globals.ei_cookie); + stream->write_function(stream, "Registered as Erlang node %s, visible as %s\n", kazoo_globals.ei_cnode.thisnodename, kazoo_globals.ei_cnode.thisalivename); - if (globals.ei_compat_rel) { - stream->write_function(stream, "Using Erlang compatibility mode: %d\n", globals.ei_compat_rel); + if (kazoo_globals.ei_compat_rel) { + stream->write_function(stream, "Using Erlang compatibility mode: %d\n", kazoo_globals.ei_compat_rel); } - switch_thread_rwlock_rdlock(globals.ei_nodes_lock); - ei_node = globals.ei_nodes; + switch_thread_rwlock_rdlock(kazoo_globals.ei_nodes_lock); + ei_node = kazoo_globals.ei_nodes; if (!ei_node) { stream->write_function(stream, "No erlang nodes connected\n"); } else { @@ -87,7 +87,7 @@ static switch_status_t api_erlang_status(switch_stream_handle_t *stream) { ei_node = ei_node->next; } } - switch_thread_rwlock_unlock(globals.ei_nodes_lock); + switch_thread_rwlock_unlock(kazoo_globals.ei_nodes_lock); return SWITCH_STATUS_SUCCESS; } @@ -96,7 +96,7 @@ static switch_status_t api_erlang_event_filter(switch_stream_handle_t *stream) { switch_hash_index_t *hi = NULL; int column = 0; - for (hi = (switch_hash_index_t *)switch_core_hash_first_iter(globals.event_filter, hi); hi; hi = switch_core_hash_next(&hi)) { + for (hi = (switch_hash_index_t *)switch_core_hash_first_iter(kazoo_globals.event_filter, hi); hi; hi = switch_core_hash_next(&hi)) { const void *key; void *val; switch_core_hash_this(hi, &key, NULL, &val); @@ -112,7 +112,7 @@ static switch_status_t api_erlang_event_filter(switch_stream_handle_t *stream) { column = 0; } - stream->write_function(stream, "%-50s", globals.kazoo_var_prefix); + stream->write_function(stream, "%-50s", kazoo_globals.kazoo_var_prefix); return SWITCH_STATUS_SUCCESS; } @@ -120,13 +120,13 @@ static switch_status_t api_erlang_event_filter(switch_stream_handle_t *stream) { static switch_status_t api_erlang_nodes_list(switch_stream_handle_t *stream) { ei_node_t *ei_node; - switch_thread_rwlock_rdlock(globals.ei_nodes_lock); - ei_node = globals.ei_nodes; + switch_thread_rwlock_rdlock(kazoo_globals.ei_nodes_lock); + ei_node = kazoo_globals.ei_nodes; while(ei_node != NULL) { stream->write_function(stream, "%s (%s)\n", ei_node->peer_nodename, ei_node->remote_ip); ei_node = ei_node->next; } - switch_thread_rwlock_unlock(globals.ei_nodes_lock); + switch_thread_rwlock_unlock(kazoo_globals.ei_nodes_lock); return SWITCH_STATUS_SUCCESS; } @@ -135,13 +135,13 @@ static switch_status_t api_erlang_nodes_count(switch_stream_handle_t *stream) { ei_node_t *ei_node; int count = 0; - switch_thread_rwlock_rdlock(globals.ei_nodes_lock); - ei_node = globals.ei_nodes; + switch_thread_rwlock_rdlock(kazoo_globals.ei_nodes_lock); + ei_node = kazoo_globals.ei_nodes; while(ei_node != NULL) { count++; ei_node = ei_node->next; } - switch_thread_rwlock_unlock(globals.ei_nodes_lock); + switch_thread_rwlock_unlock(kazoo_globals.ei_nodes_lock); stream->write_function(stream, "%d\n", count); @@ -153,13 +153,13 @@ static switch_status_t api_complete_erlang_node(const char *line, const char *cu switch_status_t status = SWITCH_STATUS_FALSE; ei_node_t *ei_node; - switch_thread_rwlock_rdlock(globals.ei_nodes_lock); - ei_node = globals.ei_nodes; + switch_thread_rwlock_rdlock(kazoo_globals.ei_nodes_lock); + ei_node = kazoo_globals.ei_nodes; while(ei_node != NULL) { switch_console_push_match(&my_matches, ei_node->peer_nodename); ei_node = ei_node->next; } - switch_thread_rwlock_unlock(globals.ei_nodes_lock); + switch_thread_rwlock_unlock(kazoo_globals.ei_nodes_lock); if (my_matches) { *matches = my_matches; @@ -185,7 +185,7 @@ static switch_status_t handle_node_api_event_stream(ei_event_stream_t *event_str ip_addr = switch_get_addr(ipbuf, sizeof (ipbuf), sa); if (zstr(ip_addr)) { - ip_addr = globals.ip; + ip_addr = kazoo_globals.ip; } stream->write_function(stream, "%s:%d -> disconnected\n" @@ -272,20 +272,20 @@ static switch_status_t handle_node_api_command(ei_node_t *ei_node, switch_stream static switch_status_t api_erlang_node_command(switch_stream_handle_t *stream, const char *nodename, uint32_t command) { ei_node_t *ei_node; - switch_thread_rwlock_rdlock(globals.ei_nodes_lock); - ei_node = globals.ei_nodes; + switch_thread_rwlock_rdlock(kazoo_globals.ei_nodes_lock); + ei_node = kazoo_globals.ei_nodes; while(ei_node != NULL) { int length = strlen(ei_node->peer_nodename); if (!strncmp(ei_node->peer_nodename, nodename, length)) { handle_node_api_command(ei_node, stream, command); - switch_thread_rwlock_unlock(globals.ei_nodes_lock); + switch_thread_rwlock_unlock(kazoo_globals.ei_nodes_lock); return SWITCH_STATUS_SUCCESS; } ei_node = ei_node->next; } - switch_thread_rwlock_unlock(globals.ei_nodes_lock); + switch_thread_rwlock_unlock(kazoo_globals.ei_nodes_lock); return SWITCH_STATUS_NOTFOUND; } @@ -340,16 +340,16 @@ static int read_cookie_from_file(char *filename) { static switch_status_t config(void) { char *cf = "kazoo.conf"; switch_xml_t cfg, xml, child, param; - globals.send_all_headers = 0; - globals.send_all_private_headers = 1; - globals.connection_timeout = 500; - globals.receive_timeout = 200; - globals.receive_msg_preallocate = 2000; - globals.event_stream_preallocate = 4000; - globals.send_msg_batch = 10; - globals.event_stream_framing = 2; - globals.port = 0; - globals.io_fault_tolerance = 10; + kazoo_globals.send_all_headers = 0; + kazoo_globals.send_all_private_headers = 1; + kazoo_globals.connection_timeout = 500; + kazoo_globals.receive_timeout = 200; + kazoo_globals.receive_msg_preallocate = 2000; + kazoo_globals.event_stream_preallocate = 4000; + kazoo_globals.send_msg_batch = 10; + kazoo_globals.event_stream_framing = 2; + kazoo_globals.port = 0; + kazoo_globals.io_fault_tolerance = 10; if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open configuration file %s\n", cf); @@ -365,7 +365,7 @@ static switch_status_t config(void) { set_pref_ip(val); } else if (!strcmp(var, "listen-port")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set bind port: %s\n", val); - globals.port = atoi(val); + kazoo_globals.port = atoi(val); } else if (!strcmp(var, "cookie")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set cookie: %s\n", val); set_pref_ei_cookie(val); @@ -377,43 +377,43 @@ static switch_status_t config(void) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set node name: %s\n", val); set_pref_ei_nodename(val); } else if (!strcmp(var, "shortname")) { - globals.ei_shortname = switch_true(val); + kazoo_globals.ei_shortname = switch_true(val); } else if (!strcmp(var, "kazoo-var-prefix")) { set_pref_kazoo_var_prefix(val); } else if (!strcmp(var, "compat-rel")) { if (atoi(val) >= 7) - globals.ei_compat_rel = atoi(val); + kazoo_globals.ei_compat_rel = atoi(val); else switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid compatibility release '%s' specified\n", val); } else if (!strcmp(var, "nat-map")) { - globals.nat_map = switch_true(val); + kazoo_globals.nat_map = switch_true(val); } else if (!strcmp(var, "send-all-headers")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set send-all-headers: %s\n", val); - globals.send_all_headers = switch_true(val); + kazoo_globals.send_all_headers = switch_true(val); } else if (!strcmp(var, "send-all-private-headers")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set send-all-private-headers: %s\n", val); - globals.send_all_private_headers = switch_true(val); + kazoo_globals.send_all_private_headers = switch_true(val); } else if (!strcmp(var, "connection-timeout")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set connection-timeout: %s\n", val); - globals.connection_timeout = atoi(val); + kazoo_globals.connection_timeout = atoi(val); } else if (!strcmp(var, "receive-timeout")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set receive-timeout: %s\n", val); - globals.receive_timeout = atoi(val); + kazoo_globals.receive_timeout = atoi(val); } else if (!strcmp(var, "receive-msg-preallocate")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set receive-msg-preallocate: %s\n", val); - globals.receive_msg_preallocate = atoi(val); + kazoo_globals.receive_msg_preallocate = atoi(val); } else if (!strcmp(var, "event-stream-preallocate")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set event-stream-preallocate: %s\n", val); - globals.event_stream_preallocate = atoi(val); + kazoo_globals.event_stream_preallocate = atoi(val); } else if (!strcmp(var, "send-msg-batch-size")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set send-msg-batch-size: %s\n", val); - globals.send_msg_batch = atoi(val); + kazoo_globals.send_msg_batch = atoi(val); } else if (!strcmp(var, "event-stream-framing")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set event-stream-framing: %s\n", val); - globals.event_stream_framing = atoi(val); + kazoo_globals.event_stream_framing = atoi(val); } else if (!strcmp(var, "io-fault-tolerance")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set io-fault-tolerance: %s\n", val); - globals.io_fault_tolerance = atoi(val); + kazoo_globals.io_fault_tolerance = atoi(val); } } } @@ -427,68 +427,68 @@ static switch_status_t config(void) { switch_core_hash_insert(filter, var, "1"); } - globals.event_filter = filter; + kazoo_globals.event_filter = filter; } switch_xml_free(xml); } - if (globals.receive_msg_preallocate < 0) { + if (kazoo_globals.receive_msg_preallocate < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid receive message preallocate value, disabled\n"); - globals.receive_msg_preallocate = 0; + kazoo_globals.receive_msg_preallocate = 0; } - if (globals.event_stream_preallocate < 0) { + if (kazoo_globals.event_stream_preallocate < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid event stream preallocate value, disabled\n"); - globals.event_stream_preallocate = 0; + kazoo_globals.event_stream_preallocate = 0; } - if (globals.send_msg_batch < 1) { + if (kazoo_globals.send_msg_batch < 1) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid send message batch size, reverting to default\n"); - globals.send_msg_batch = 10; + kazoo_globals.send_msg_batch = 10; } - if (globals.io_fault_tolerance < 1) { + if (kazoo_globals.io_fault_tolerance < 1) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid I/O fault tolerance, reverting to default\n"); - globals.io_fault_tolerance = 10; + kazoo_globals.io_fault_tolerance = 10; } - if (!globals.event_filter) { + if (!kazoo_globals.event_filter) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Event filter not found in configuration, using default\n"); - globals.event_filter = create_default_filter(); + kazoo_globals.event_filter = create_default_filter(); } - if (globals.event_stream_framing < 1 || globals.event_stream_framing > 4) { + if (kazoo_globals.event_stream_framing < 1 || kazoo_globals.event_stream_framing > 4) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid event stream framing value, using default\n"); - globals.event_stream_framing = 2; + kazoo_globals.event_stream_framing = 2; } - if (zstr(globals.kazoo_var_prefix)) { + if (zstr(kazoo_globals.kazoo_var_prefix)) { set_pref_kazoo_var_prefix("variable_ecallmgr*"); - globals.var_prefix_length = 17; //ignore the * + kazoo_globals.var_prefix_length = 17; //ignore the * } else { /* we could use the global pool but then we would have to conditionally * free the pointer if it was not drawn from the XML */ char *buf; - int size = switch_snprintf(NULL, 0, "variable_%s*", globals.kazoo_var_prefix) + 1; + int size = switch_snprintf(NULL, 0, "variable_%s*", kazoo_globals.kazoo_var_prefix) + 1; switch_malloc(buf, size); - switch_snprintf(buf, size, "variable_%s*", globals.kazoo_var_prefix); - switch_safe_free(globals.kazoo_var_prefix); - globals.kazoo_var_prefix = buf; - globals.var_prefix_length = size - 2; //ignore the * + switch_snprintf(buf, size, "variable_%s*", kazoo_globals.kazoo_var_prefix); + switch_safe_free(kazoo_globals.kazoo_var_prefix); + kazoo_globals.kazoo_var_prefix = buf; + kazoo_globals.var_prefix_length = size - 2; //ignore the * } - if (!globals.num_worker_threads) { + if (!kazoo_globals.num_worker_threads) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Number of worker threads not found in configuration, using default\n"); - globals.num_worker_threads = 10; + kazoo_globals.num_worker_threads = 10; } - if (zstr(globals.ip)) { + if (zstr(kazoo_globals.ip)) { set_pref_ip("0.0.0.0"); } - if (zstr(globals.ei_cookie)) { + if (zstr(kazoo_globals.ei_cookie)) { int res; char *home_dir = getenv("HOME"); char path_buf[1024]; @@ -506,12 +506,12 @@ static switch_status_t config(void) { } } - if (!globals.ei_nodename) { + if (!kazoo_globals.ei_nodename) { set_pref_ei_nodename("freeswitch"); } - if (!globals.nat_map) { - globals.nat_map = 0; + if (!kazoo_globals.nat_map) { + kazoo_globals.nat_map = 0; } return SWITCH_STATUS_SUCCESS; @@ -524,16 +524,16 @@ static switch_status_t create_acceptor() { const char *ip_addr; /* if the config has specified an erlang release compatibility then pass that along to the erlang interface */ - if (globals.ei_compat_rel) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Compatability with OTP R%d requested\n", globals.ei_compat_rel); - ei_set_compat_rel(globals.ei_compat_rel); + if (kazoo_globals.ei_compat_rel) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Compatability with OTP R%d requested\n", kazoo_globals.ei_compat_rel); + ei_set_compat_rel(kazoo_globals.ei_compat_rel); } - if (!(globals.acceptor = create_socket_with_port(globals.pool, globals.port))) { + if (!(kazoo_globals.acceptor = create_socket_with_port(kazoo_globals.pool, kazoo_globals.port))) { return SWITCH_STATUS_SOCKERR; } - switch_socket_addr_get(&sa, SWITCH_FALSE, globals.acceptor); + switch_socket_addr_get(&sa, SWITCH_FALSE, kazoo_globals.acceptor); port = switch_sockaddr_get_port(sa); ip_addr = switch_get_addr(ipbuf, sizeof (ipbuf), sa); @@ -541,18 +541,18 @@ static switch_status_t create_acceptor() { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Erlang connection acceptor listening on %s:%u\n", ip_addr, port); /* try to initialize the erlang interface */ - if (create_ei_cnode(ip_addr, globals.ei_nodename, &globals.ei_cnode) != SWITCH_STATUS_SUCCESS) { + if (create_ei_cnode(ip_addr, kazoo_globals.ei_nodename, &kazoo_globals.ei_cnode) != SWITCH_STATUS_SUCCESS) { return SWITCH_STATUS_SOCKERR; } /* tell the erlang port manager where we can be reached. this returns a file descriptor pointing to epmd or -1 */ - if ((globals.epmdfd = ei_publish(&globals.ei_cnode, port)) == -1) { + if ((kazoo_globals.epmdfd = ei_publish(&kazoo_globals.ei_cnode, port)) == -1) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to publish port to epmd. Try starting it yourself or run an erl shell with the -sname or -name option.\n"); return SWITCH_STATUS_SOCKERR; } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connected to epmd and published erlang cnode name %s at port %d\n", globals.ei_cnode.thisnodename, port); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connected to epmd and published erlang cnode name %s at port %d\n", kazoo_globals.ei_cnode.thisnodename, port); return SWITCH_STATUS_SUCCESS; } @@ -638,10 +638,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_kazoo_load) { switch_api_interface_t *api_interface = NULL; switch_application_interface_t *app_interface = NULL; - memset(&globals, 0, sizeof(globals)); + memset(&kazoo_globals, 0, sizeof(kazoo_globals)); - globals.pool = pool; - globals.ei_nodes = NULL; + kazoo_globals.pool = pool; + kazoo_globals.ei_nodes = NULL; if(config() != SWITCH_STATUS_SUCCESS) { // TODO: what would we need to clean up here? @@ -652,7 +652,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_kazoo_load) { if(create_acceptor() != SWITCH_STATUS_SUCCESS) { // TODO: what would we need to clean up here switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to create erlang connection acceptor!\n"); - close_socket(&globals.acceptor); + close_socket(&kazoo_globals.acceptor); return SWITCH_STATUS_TERM; } @@ -671,9 +671,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_kazoo_load) { switch_console_set_complete("add erlang node ::erlang::node fetch_bindings"); switch_console_add_complete_func("::erlang::node", api_complete_erlang_node); - switch_thread_rwlock_create(&globals.ei_nodes_lock, pool); + switch_thread_rwlock_create(&kazoo_globals.ei_nodes_lock, pool); - switch_set_flag(&globals, LFLAG_RUNNING); + switch_set_flag(&kazoo_globals, LFLAG_RUNNING); /* create all XML fetch agents */ bind_fetch_agents(); @@ -695,10 +695,10 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_kazoo_shutdown) { switch_console_del_complete_func("::erlang::node"); /* stop taking new requests and start shuting down the threads */ - switch_clear_flag(&globals, LFLAG_RUNNING); + switch_clear_flag(&kazoo_globals, LFLAG_RUNNING); /* give everyone time to cleanly shutdown */ - while (switch_atomic_read(&globals.threads)) { + while (switch_atomic_read(&kazoo_globals.threads)) { switch_yield(100000); if (++sanity >= 200) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to kill all threads, continuing. This probably wont end well.....good luck!\n"); @@ -706,31 +706,31 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_kazoo_shutdown) { } } - if (globals.event_filter) { - switch_core_hash_destroy(&globals.event_filter); + if (kazoo_globals.event_filter) { + switch_core_hash_destroy(&kazoo_globals.event_filter); } - switch_thread_rwlock_wrlock(globals.ei_nodes_lock); - switch_thread_rwlock_unlock(globals.ei_nodes_lock); - switch_thread_rwlock_destroy(globals.ei_nodes_lock); + switch_thread_rwlock_wrlock(kazoo_globals.ei_nodes_lock); + switch_thread_rwlock_unlock(kazoo_globals.ei_nodes_lock); + switch_thread_rwlock_destroy(kazoo_globals.ei_nodes_lock); /* close the connection to epmd and the acceptor */ - close_socketfd(&globals.epmdfd); - close_socket(&globals.acceptor); + close_socketfd(&kazoo_globals.epmdfd); + close_socket(&kazoo_globals.acceptor); /* remove all XML fetch agents */ unbind_fetch_agents(); /* Close the port we reserved for uPnP/Switch behind firewall, if necessary */ - // if (globals.nat_map && switch_nat_get_type()) { - // switch_nat_del_mapping(globals.port, SWITCH_NAT_TCP); + // if (kazoo_globals.nat_map && switch_nat_get_type()) { + // switch_nat_del_mapping(kazoo_globals.port, SWITCH_NAT_TCP); // } /* clean up our allocated preferences */ - switch_safe_free(globals.ip); - switch_safe_free(globals.ei_cookie); - switch_safe_free(globals.ei_nodename); - switch_safe_free(globals.kazoo_var_prefix); + switch_safe_free(kazoo_globals.ip); + switch_safe_free(kazoo_globals.ei_cookie); + switch_safe_free(kazoo_globals.ei_nodename); + switch_safe_free(kazoo_globals.kazoo_var_prefix); return SWITCH_STATUS_SUCCESS; } @@ -738,11 +738,11 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_kazoo_shutdown) { SWITCH_MODULE_RUNTIME_FUNCTION(mod_kazoo_runtime) { switch_os_socket_t os_socket; - switch_atomic_inc(&globals.threads); + switch_atomic_inc(&kazoo_globals.threads); - switch_os_sock_get(&os_socket, globals.acceptor); + switch_os_sock_get(&os_socket, kazoo_globals.acceptor); - while (switch_test_flag(&globals, LFLAG_RUNNING)) { + while (switch_test_flag(&kazoo_globals, LFLAG_RUNNING)) { int nodefd; ErlConnect conn; @@ -752,19 +752,19 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_kazoo_runtime) { errno = 0; /* wait here for an erlang node to connect, timming out to check if our module is still running every now-and-again */ - if ((nodefd = ei_accept_tmo(&globals.ei_cnode, (int) os_socket, &conn, globals.connection_timeout)) == ERL_ERROR) { + if ((nodefd = ei_accept_tmo(&kazoo_globals.ei_cnode, (int) os_socket, &conn, kazoo_globals.connection_timeout)) == ERL_ERROR) { if (erl_errno == ETIMEDOUT) { continue; } else if (errno) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Erlang connection acceptor socket error %d %d\n", erl_errno, errno); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, - "Erlang node connection failed - ensure your cookie matches '%s' and you are using a good nodename\n", globals.ei_cookie); + "Erlang node connection failed - ensure your cookie matches '%s' and you are using a good nodename\n", kazoo_globals.ei_cookie); } continue; } - if (!switch_test_flag(&globals, LFLAG_RUNNING)) { + if (!switch_test_flag(&kazoo_globals, LFLAG_RUNNING)) { break; } @@ -774,7 +774,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_kazoo_runtime) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Erlang connection acceptor shut down\n"); - switch_atomic_dec(&globals.threads); + switch_atomic_dec(&kazoo_globals.threads); return SWITCH_STATUS_TERM; } diff --git a/src/mod/event_handlers/mod_kazoo/mod_kazoo.h b/src/mod/event_handlers/mod_kazoo/mod_kazoo.h index 9e28707c38..9de7db6ea0 100644 --- a/src/mod/event_handlers/mod_kazoo/mod_kazoo.h +++ b/src/mod/event_handlers/mod_kazoo/mod_kazoo.h @@ -122,7 +122,7 @@ struct globals_s { int io_fault_tolerance; }; typedef struct globals_s globals_t; -extern globals_t globals; +extern globals_t kazoo_globals; /* kazoo_node.c */ switch_status_t new_kazoo_node(int nodefd, ErlConnect *conn); diff --git a/src/mod/event_handlers/mod_rayo/rayo_cpa_component.c b/src/mod/event_handlers/mod_rayo/rayo_cpa_component.c index 81a708b1a9..a2fa679a2b 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_cpa_component.c +++ b/src/mod/event_handlers/mod_rayo/rayo_cpa_component.c @@ -35,7 +35,7 @@ /** * Module globals */ -struct { +static struct { /** signal subscribers */ switch_hash_t *subscribers; /** synchronizes access to subscribers */ diff --git a/src/mod/languages/mod_managed/freeswitch_managed.h b/src/mod/languages/mod_managed/freeswitch_managed.h index 13ffe5d552..df66f0b3bc 100644 --- a/src/mod/languages/mod_managed/freeswitch_managed.h +++ b/src/mod/languages/mod_managed/freeswitch_managed.h @@ -26,7 +26,7 @@ * Michael Giagnocavo * Jeff Lenk - Modified class to support Dotnet * - * freeswitch_managed.h -- Header for ManagedSession and globals + * freeswitch_managed.h -- Header for ManagedSession and managed_globals * */ @@ -60,13 +60,13 @@ struct mod_managed_globals { #endif }; typedef struct mod_managed_globals mod_managed_globals; -extern mod_managed_globals globals; +extern mod_managed_globals managed_globals; #endif #ifdef _MANAGED #define ATTACH_THREADS #else -#define ATTACH_THREADS mono_thread_attach(globals.domain); +#define ATTACH_THREADS mono_thread_attach(managed_globals.domain); #endif #ifdef WIN32 diff --git a/src/mod/languages/mod_managed/mod_managed.cpp b/src/mod/languages/mod_managed/mod_managed.cpp index bc627483f4..3ad7c519d6 100644 --- a/src/mod/languages/mod_managed/mod_managed.cpp +++ b/src/mod/languages/mod_managed/mod_managed.cpp @@ -67,7 +67,7 @@ SWITCH_STANDARD_API(managedlist_api_function); /* List modules */ #define MOD_MANAGED_IMAGE_NAME "FreeSWITCH" #define MOD_MANAGED_CLASS_NAME "Loader" -mod_managed_globals globals = { 0 }; +mod_managed_globals managed_globals = { 0 }; // Global delegates to call managed functions typedef int (*runFunction)(const char *data, void *sessionPtr); @@ -201,14 +201,14 @@ switch_status_t loadRuntime() #endif switch_snprintf(filename, 256, "%s%s%s", SWITCH_GLOBAL_dirs.mod_dir, SWITCH_PATH_SEPARATOR, MOD_MANAGED_DLL); - globals.domain = mono_jit_init(filename); + managed_globals.domain = mono_jit_init(filename); /* Already got a Mono domain? */ - if ((globals.domain = mono_get_root_domain())) { - mono_thread_attach(globals.domain); - globals.embedded = SWITCH_TRUE; + if ((managed_globals.domain = mono_get_root_domain())) { + mono_thread_attach(managed_globals.domain); + managed_globals.embedded = SWITCH_TRUE; } else { - if (!(globals.domain = mono_jit_init(filename))) { + if (!(managed_globals.domain = mono_jit_init(filename))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mono_jit_init failed.\n"); return SWITCH_STATUS_FALSE; } @@ -221,11 +221,11 @@ switch_status_t loadRuntime() switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Calling mono_assembly_loaded.\n"); - if (!(globals.mod_mono_asm = mono_assembly_loaded(name))) { + if (!(managed_globals.mod_mono_asm = mono_assembly_loaded(name))) { /* Open the assembly */ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Calling mono_domain_assembly_open.\n"); - globals.mod_mono_asm = mono_domain_assembly_open(globals.domain, filename); - if (!globals.mod_mono_asm) { + managed_globals.mod_mono_asm = mono_domain_assembly_open(managed_globals.domain, filename); + if (!managed_globals.mod_mono_asm) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mono_domain_assembly_open failed.\n"); return SWITCH_STATUS_FALSE; } @@ -254,14 +254,14 @@ switch_status_t findLoader() { /* Find loader class and methods */ MonoClass * loaderClass; - MonoImage * img = mono_assembly_get_image(globals.mod_mono_asm); + MonoImage * img = mono_assembly_get_image(managed_globals.mod_mono_asm); if (!(loaderClass = mono_class_from_name(img, MOD_MANAGED_IMAGE_NAME, MOD_MANAGED_CLASS_NAME))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find " MOD_MANAGED_IMAGE_NAME "." MOD_MANAGED_CLASS_NAME " class.\n"); return SWITCH_STATUS_FALSE; } - if (!(globals.loadMethod = getMethod(MOD_MANAGED_IMAGE_NAME "." MOD_MANAGED_CLASS_NAME ":Load()", loaderClass))) { + if (!(managed_globals.loadMethod = getMethod(MOD_MANAGED_IMAGE_NAME "." MOD_MANAGED_CLASS_NAME ":Load()", loaderClass))) { return SWITCH_STATUS_FALSE; } @@ -317,7 +317,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_managed_load) *module_interface = switch_loadable_module_create_module_interface(pool, modname); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Loading mod_managed (Common Language Infrastructure), " MOD_MANAGED_VERSION "\n"); - globals.pool = pool; + managed_globals.pool = pool; if (loadRuntime() != SWITCH_STATUS_SUCCESS) { return SWITCH_STATUS_FALSE; @@ -340,11 +340,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_managed_load) } #else /* Not sure if this is necesary on the loading thread */ - mono_thread_attach(globals.domain); + mono_thread_attach(managed_globals.domain); /* Run loader */ MonoObject * exception = NULL; - MonoObject * objResult = mono_runtime_invoke(globals.loadMethod, NULL, NULL, &exception); + MonoObject * objResult = mono_runtime_invoke(managed_globals.loadMethod, NULL, NULL, &exception); if (exception) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Load threw an exception.\n"); mono_print_unhandled_exception(exception); @@ -381,7 +381,7 @@ SWITCH_STANDARD_API(managedrun_api_function) return SWITCH_STATUS_SUCCESS; } #ifndef _MANAGED - mono_thread_attach(globals.domain); + mono_thread_attach(managed_globals.domain); #endif if (executeBackgroundDelegate(cmd)) { stream->write_function(stream, "+OK\n"); @@ -401,7 +401,7 @@ SWITCH_STANDARD_API(managed_api_function) return SWITCH_STATUS_SUCCESS; } #ifndef _MANAGED - mono_thread_attach(globals.domain); + mono_thread_attach(managed_globals.domain); #endif if (!(executeDelegate(cmd, stream, stream->param_event))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Execute failed for %s (unknown module or exception).\n", cmd); @@ -419,7 +419,7 @@ SWITCH_STANDARD_APP(managed_app_function) return; } #ifndef _MANAGED - mono_thread_attach(globals.domain); + mono_thread_attach(managed_globals.domain); #endif if (!(runDelegate(data, session))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Application run failed for %s (unknown module or exception).\n", data); @@ -436,7 +436,7 @@ SWITCH_STANDARD_API(managedreload_api_function) return SWITCH_STATUS_SUCCESS; } #ifndef _MANAGED - mono_thread_attach(globals.domain); + mono_thread_attach(managed_globals.domain); #endif if (!(reloadDelegate(cmd))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Execute failed for %s (unknown module or exception).\n", cmd); @@ -450,7 +450,7 @@ SWITCH_STANDARD_API(managedreload_api_function) SWITCH_STANDARD_API(managedlist_api_function) { #ifndef _MANAGED - mono_thread_attach(globals.domain); + mono_thread_attach(managed_globals.domain); #endif listDelegate(cmd, stream, stream->param_event); #ifndef _MANAGED diff --git a/src/mod/languages/mod_managed/mono28.patch b/src/mod/languages/mod_managed/mono28.patch index 7ec60f596c..a19fa2e37a 100644 --- a/src/mod/languages/mod_managed/mono28.patch +++ b/src/mod/languages/mod_managed/mono28.patch @@ -36,7 +36,7 @@ index 1d0b6a7..13ffe5d 100644 #include #include #include -@@ -73,7 +72,7 @@ extern mod_managed_globals globals; +@@ -73,7 +72,7 @@ extern mod_managed_globals managed_globals; #ifdef WIN32 #define RESULT_FREE(x) CoTaskMemFree(x) #else @@ -68,8 +68,8 @@ index ec2d866..87e831f 100644 + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Calling mono_assembly_loaded.\n"); -- if (!(globals.mod_mono_asm = mono_assembly_loaded(&name))) { -+ if (!(globals.mod_mono_asm = mono_assembly_loaded(name))) { +- if (!(managed_globals.mod_mono_asm = mono_assembly_loaded(&name))) { ++ if (!(managed_globals.mod_mono_asm = mono_assembly_loaded(name))) { /* Open the assembly */ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Calling mono_domain_assembly_open.\n"); - globals.mod_mono_asm = mono_domain_assembly_open(globals.domain, filename); + managed_globals.mod_mono_asm = mono_domain_assembly_open(managed_globals.domain, filename); diff --git a/src/mod/languages/mod_v8/mod_v8.cpp b/src/mod/languages/mod_v8/mod_v8.cpp index 4590b96867..61600714e4 100644 --- a/src/mod/languages/mod_v8/mod_v8.cpp +++ b/src/mod/languages/mod_v8/mod_v8.cpp @@ -118,7 +118,7 @@ typedef struct { set *event_handlers; } mod_v8_global_t; -mod_v8_global_t globals = { 0 }; +static mod_v8_global_t globals = { 0 }; /* Loadable module struct, used for external extension modules */ typedef struct { diff --git a/src/mod/xml_int/mod_xml_rpc/ws.c b/src/mod/xml_int/mod_xml_rpc/ws.c index 76f66bcfc9..5ca7d1cb3c 100644 --- a/src/mod/xml_int/mod_xml_rpc/ws.c +++ b/src/mod/xml_int/mod_xml_rpc/ws.c @@ -5,7 +5,7 @@ #endif #define SHA1_HASH_SIZE 20 -struct globals_s globals; +static struct globals_s globals; #ifndef WSS_STANDALONE