FS-10025: fix global symbol scope issue causing modules to use another modules global pointer

This commit is contained in:
Mike Jerris committed 2017-02-09 17:23:30 -06:00
1 parent c125ab7315
commit a3ee7595bb
31 files changed
+526 -528

No files matched your search

+1 -1
View File
@@ -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,
+52 -52
View File
@@ -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;
+1 -1
View File
@@ -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),
+3 -3
View File
@@ -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;
+152 -152
View File
@@ -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 {
@@ -294,7 +294,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);
}
@@ -317,22 +317,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)
@@ -340,13 +340,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) {
@@ -356,12 +356,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;
}
@@ -414,12 +414,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;
@@ -453,7 +453,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);
@@ -504,9 +504,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;
}
@@ -603,7 +603,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);
@@ -669,7 +669,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) {
@@ -725,7 +725,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);
@@ -734,7 +734,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);
@@ -763,9 +763,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:
@@ -780,9 +780,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";
@@ -1100,13 +1100,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;
}
@@ -1116,11 +1116,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 {
@@ -1128,7 +1128,7 @@ static void attach_jsock(jsock_t *jsock)
cJSON *msg = NULL;
msg = jrpc_new_req("verto.punt", NULL, &params);
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;
@@ -1137,10 +1137,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)
@@ -1149,9 +1149,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)
@@ -1161,15 +1161,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();
@@ -1187,7 +1187,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, &params);
@@ -1212,25 +1212,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;
@@ -1239,15 +1239,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;
@@ -1265,11 +1265,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)
@@ -1383,7 +1383,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);
@@ -2098,36 +2098,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;
@@ -3738,7 +3738,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;
@@ -3918,7 +3918,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) {
@@ -4367,14 +4367,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);
}
}
@@ -4443,9 +4443,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();
@@ -4501,8 +4501,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;
@@ -4516,7 +4516,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;
}
@@ -4526,14 +4526,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;
}
@@ -4542,40 +4542,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;
}
@@ -4849,16 +4849,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;
}
}
}
@@ -4875,13 +4875,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;
}
@@ -4921,8 +4921,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);
@@ -4946,7 +4946,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");
@@ -4965,8 +4965,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, "<profiles>\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);
@@ -4985,7 +4985,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, "</profiles>\n");
return SWITCH_STATUS_SUCCESS;
}
@@ -5047,9 +5047,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;
@@ -5073,9 +5073,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;
@@ -5098,13 +5098,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);
}
@@ -5252,8 +5252,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);
@@ -5266,7 +5266,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);
@@ -5429,7 +5429,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);
@@ -5474,8 +5474,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);
@@ -5488,7 +5488,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;
}
@@ -5902,11 +5902,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;
}
@@ -5948,7 +5948,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;
}
@@ -6002,31 +6002,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;
@@ -6042,7 +6042,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();
@@ -6070,11 +6070,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;
@@ -6109,31 +6109,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;
}
-2
View File
@@ -320,8 +320,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);
+5 -5
View File
@@ -28,7 +28,7 @@
#define WS_WRITE_SANITY 2000
#define SHA1_HASH_SIZE 20
struct ws_globals_s ws_globals;
static struct ws_globals_s ws_globals;
#ifndef WSS_STANDALONE
@@ -110,13 +110,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 */
+1 -1
View File
@@ -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;