FS-5340 --resolve
This commit is contained in:
parent
032761c0f5
commit
eeeb4fa445
|
@ -600,6 +600,7 @@ struct sofia_profile {
|
|||
sofia_gateway_t *gateways;
|
||||
//su_home_t *home;
|
||||
switch_hash_t *chat_hash;
|
||||
switch_hash_t *reg_nh_hash;
|
||||
switch_hash_t *mwi_debounce_hash;
|
||||
//switch_core_db_t *master_db;
|
||||
switch_thread_rwlock_t *rwlock;
|
||||
|
@ -1107,6 +1108,7 @@ int sofia_glue_check_nat(sofia_profile_t *profile, const char *network_ip);
|
|||
switch_status_t sofia_glue_ext_address_lookup(sofia_profile_t *profile, char **ip, switch_port_t *port,
|
||||
const char *sourceip, switch_memory_pool_t *pool);
|
||||
void sofia_reg_check_socket(sofia_profile_t *profile, const char *call_id, const char *network_addr, const char *network_ip);
|
||||
void sofia_reg_close_handles(sofia_profile_t *profile);
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
|
|
|
@ -2611,6 +2611,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
|||
}
|
||||
|
||||
sofia_clear_pflag_locked(profile, PFLAG_RUNNING);
|
||||
sofia_reg_close_handles(profile);
|
||||
|
||||
switch_core_session_hupall_matching_var("sofia_profile_name", profile->name, SWITCH_CAUSE_MANAGER_REQUEST);
|
||||
sanity = 10;
|
||||
|
@ -2628,7 +2629,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
|||
sofia_reg_unregister(profile);
|
||||
nua_shutdown(profile->nua);
|
||||
|
||||
sanity = 10;
|
||||
sanity = 100;
|
||||
while (!sofia_test_pflag(profile, PFLAG_SHUTDOWN) || profile->queued_events > 0) {
|
||||
su_root_step(profile->s_root, 1000);
|
||||
if (!--sanity) {
|
||||
|
@ -2702,6 +2703,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
|||
|
||||
sofia_glue_del_profile(profile);
|
||||
switch_core_hash_destroy(&profile->chat_hash);
|
||||
switch_core_hash_destroy(&profile->reg_nh_hash);
|
||||
switch_core_hash_destroy(&profile->mwi_debounce_hash);
|
||||
|
||||
switch_thread_rwlock_unlock(profile->rwlock);
|
||||
|
@ -3622,6 +3624,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
|
|||
|
||||
profile->dbname = switch_core_strdup(profile->pool, url);
|
||||
switch_core_hash_init(&profile->chat_hash, profile->pool);
|
||||
switch_core_hash_init(&profile->reg_nh_hash, profile->pool);
|
||||
switch_core_hash_init(&profile->mwi_debounce_hash, profile->pool);
|
||||
switch_thread_rwlock_create(&profile->rwlock, profile->pool);
|
||||
switch_mutex_init(&profile->flag_mutex, SWITCH_MUTEX_NESTED, profile->pool);
|
||||
|
|
|
@ -644,9 +644,10 @@ void sofia_reg_check_socket(sofia_profile_t *profile, const char *call_id, const
|
|||
|
||||
switch_snprintf(key, sizeof(key), "%s%s%s", call_id, network_addr, network_ip);
|
||||
switch_mutex_lock(profile->flag_mutex);
|
||||
if ((hnh = switch_core_hash_find(profile->chat_hash, key))) {
|
||||
switch_core_hash_delete(profile->chat_hash, key);
|
||||
if ((hnh = switch_core_hash_find(profile->reg_nh_hash, key))) {
|
||||
switch_core_hash_delete(profile->reg_nh_hash, key);
|
||||
nua_handle_unref(hnh);
|
||||
nua_handle_destroy(hnh);
|
||||
}
|
||||
switch_mutex_unlock(profile->flag_mutex);
|
||||
}
|
||||
|
@ -1082,6 +1083,33 @@ static int debounce_check(sofia_profile_t *profile, const char *user, const char
|
|||
return r;
|
||||
}
|
||||
|
||||
void sofia_reg_close_handles(sofia_profile_t *profile)
|
||||
{
|
||||
nua_handle_t *nh = NULL;
|
||||
switch_hash_index_t *hi;
|
||||
const void *var;
|
||||
void *val;
|
||||
|
||||
|
||||
switch_mutex_lock(profile->flag_mutex);
|
||||
if (profile->reg_nh_hash) {
|
||||
top:
|
||||
for (hi = switch_hash_first(NULL, profile->reg_nh_hash); hi; hi = switch_hash_next(hi)) {
|
||||
switch_hash_this(hi, &var, NULL, &val);
|
||||
if ((nh = (nua_handle_t *) val)) {
|
||||
nua_handle_unref(nh);
|
||||
nua_handle_destroy(nh);
|
||||
switch_core_hash_delete(profile->reg_nh_hash, (char *) var);
|
||||
goto top;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch_mutex_unlock(profile->flag_mutex);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip,
|
||||
sofia_dispatch_event_t *de, sofia_regtype_t regtype, char *key,
|
||||
|
@ -1699,7 +1727,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
|
|||
switch_snprintf(key, sizeof(key), "%s%s%s", call_id, network_ip, network_port_c);
|
||||
|
||||
switch_mutex_lock(profile->flag_mutex);
|
||||
hnh = switch_core_hash_find(profile->chat_hash, key);
|
||||
hnh = switch_core_hash_find(profile->reg_nh_hash, key);
|
||||
switch_mutex_unlock(profile->flag_mutex);
|
||||
|
||||
if (!hnh) {
|
||||
|
@ -1716,7 +1744,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
|
|||
*sofia_private_p = sofia_private;
|
||||
nua_handle_bind(nh, sofia_private);
|
||||
nua_handle_ref(nh);
|
||||
switch_core_hash_insert(profile->chat_hash, key, nh);
|
||||
switch_core_hash_insert(profile->reg_nh_hash, key, nh);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue