add mutex around gateway access on per-profile basis and token based access to global profiles to prevent hanging on to the hash mutex while doing sql stmts which may cause issues/slowdowns

This commit is contained in:
Anthony Minessale
2011-06-16 14:32:08 -05:00
parent dc61e08e5d
commit 9df8169d1f
6 changed files with 221 additions and 209 deletions
+8 -5
View File
@@ -134,7 +134,7 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now)
*/
sofia_gateway_t *gateway_ptr;
switch_mutex_lock(mod_sofia_globals.hash_mutex);
switch_mutex_lock(profile->gw_mutex);
for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) {
sofia_gateway_subscription_t *gw_sub_ptr;
@@ -235,7 +235,7 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now)
switch_safe_free(user_via);
}
}
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
switch_mutex_unlock(profile->gw_mutex);
}
void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
@@ -244,7 +244,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
switch_event_t *event;
char *pkey;
switch_mutex_lock(mod_sofia_globals.hash_mutex);
switch_mutex_lock(profile->gw_mutex);
for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) {
if (gateway_ptr->deleted && gateway_ptr->state == REG_STATE_NOREG) {
if (last) {
@@ -447,7 +447,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
sofia_reg_fire_custom_gateway_state_event(gateway_ptr, 0, NULL);
}
}
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
switch_mutex_unlock(profile->gw_mutex);
}
@@ -2735,11 +2735,14 @@ switch_status_t sofia_reg_add_gateway(sofia_profile_t *profile, const char *key,
switch_status_t status = SWITCH_STATUS_FALSE;
char *pkey = switch_mprintf("%s::%s", profile->name, key);
switch_mutex_lock(mod_sofia_globals.hash_mutex);
switch_mutex_lock(profile->gw_mutex);
gateway->next = profile->gateways;
profile->gateways = gateway;
switch_mutex_unlock(profile->gw_mutex);
switch_mutex_lock(mod_sofia_globals.hash_mutex);
if (!switch_core_hash_find(mod_sofia_globals.gateway_hash, key)) {
status = switch_core_hash_insert(mod_sofia_globals.gateway_hash, key, gateway);
}