switch_hash_t *database_hash;
switch_hash_t *secondary_recover_hash;
switch_mutex_t *mutex;
+ switch_thread_rwlock_t *chat_rwlock;
switch_memory_pool_t *pool;
};
added++;
}
+ switch_thread_rwlock_wrlock(loadable_modules.chat_rwlock);
switch_core_hash_insert(loadable_modules.chat_hash, ptr->interface_name, (const void *) ptr);
+ switch_thread_rwlock_unlock(loadable_modules.chat_rwlock);
}
}
}
replying = switch_event_get_header(message_event, "replying");
if (!switch_true(replying) && !switch_stristr("global", proto) && !switch_true(switch_event_get_header(message_event, "skip_global_process"))) {
- switch_mutex_lock(loadable_modules.mutex);
+ switch_thread_rwlock_rdlock(loadable_modules.chat_rwlock);
for (hi = switch_core_hash_first(loadable_modules.chat_hash); hi; hi = switch_core_hash_next(&hi)) {
switch_core_hash_this(hi, &var, NULL, &val);
}
}
switch_safe_free(hi);
- switch_mutex_unlock(loadable_modules.mutex);
+ switch_thread_rwlock_unlock(loadable_modules.chat_rwlock);
}
switch_event_fire(&event);
removed++;
}
+ switch_thread_rwlock_wrlock(loadable_modules.chat_rwlock);
switch_core_hash_delete(loadable_modules.chat_hash, ptr->interface_name);
+ switch_thread_rwlock_unlock(loadable_modules.chat_rwlock);
}
}
}
switch_core_hash_init_nocase(&loadable_modules.dialplan_hash);
switch_core_hash_init(&loadable_modules.secondary_recover_hash);
switch_mutex_init(&loadable_modules.mutex, SWITCH_MUTEX_NESTED, loadable_modules.pool);
-
+ switch_thread_rwlock_create(&loadable_modules.chat_rwlock, loadable_modules.pool);
+
if (!autoload) return SWITCH_STATUS_SUCCESS;
/*