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;
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:
}
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;
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) {
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);
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);
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);
}
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,
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) {
*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);
}
}