[Freeswitch-svn] [commit] r10729 - freeswitch/branches/cseket/src/mod/applications/mod_voicemail
FreeSWITCH SVN
cseket at freeswitch.org
Fri Dec 12 02:20:25 PST 2008
Author: cseket
Date: Fri Dec 12 05:20:25 2008
New Revision: 10729
Log:
memory leak version of MODAPP-177
Modified:
freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c
Modified: freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c
==============================================================================
--- freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c (original)
+++ freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c Fri Dec 12 05:20:25 2008
@@ -266,7 +266,7 @@
static switch_status_t load_config(void)
{
char *cf = "voicemail.conf";
- vm_profile_t *profile = NULL, *oldprofile = NULL;
+ vm_profile_t *profile = NULL;
switch_xml_t cfg, xml, settings, param, x_profile, x_profiles, x_email;
switch_hash_index_t *hi;
void *val;
@@ -376,6 +376,7 @@
char *record_title = "FreeSWITCH Voicemail";
char *record_comment = "FreeSWITCH Voicemail";
char *record_copyright = "http://www.freeswitch.org";
+ int change_profile = 0;
switch_bool_t auto_playback_recordings = SWITCH_TRUE;
@@ -389,8 +390,12 @@
continue;
}
- oldprofile = switch_core_hash_find(globals.profile_hash, name);
- profile = create_profile(name);
+ if (!(profile = switch_core_hash_find(globals.profile_hash, name))) {
+ profile = create_profile(name);
+ } else {
+ change_profile = 1;
+ switch_thread_rwlock_wrlock(profile->rwlock);
+ }
if ((x_email = switch_xml_child(x_profile, "email"))) {
if ((param = switch_xml_child(x_email, "body"))) {
@@ -672,6 +677,15 @@
}
}
+#ifdef SWITCH_HAVE_ODBC
+ if (profile->odbc_dsn && profile->master_odbc) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Closing ODBC Database! %s\n", profile->name);
+ switch_odbc_handle_destroy(&profile->master_odbc);
+ profile->odbc_dsn = NULL;
+ profile->odbc_user = NULL;
+ profile->odbc_pass = NULL;
+ }
+#endif
if (!switch_strlen_zero(odbc_dsn) && !switch_strlen_zero(odbc_user) && !switch_strlen_zero(odbc_pass)) {
profile->odbc_dsn = odbc_dsn;
@@ -818,23 +832,13 @@
switch_copy_string(profile->file_ext, file_ext, sizeof(profile->file_ext));
switch_mutex_init(&profile->mutex, SWITCH_MUTEX_NESTED, profile->pool);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Added Profile %s\n", profile->name);
- if (oldprofile) {
-
- /* wait */
- /* deadlock on concurrent voicemail rescan */
- while (switch_thread_rwlock_trywrlock_timeout(oldprofile->rwlock, 10) != SWITCH_STATUS_SUCCESS);
-
+ if (change_profile) {
+ switch_thread_rwlock_unlock(profile->rwlock);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Added Profile %s\n", profile->name);
switch_mutex_lock(globals.mutex);
- /* change the profile*/
- switch_core_hash_delete(globals.profile_hash, oldprofile->name);
switch_core_hash_insert(globals.profile_hash, profile->name, profile);
switch_mutex_unlock(globals.mutex);
-
- destroy_profile(oldprofile);
-
- } else {
- switch_core_hash_insert(globals.profile_hash, profile->name, profile);
}
}
More information about the Freeswitch-svn
mailing list