From 0ec6b81376a47ad6ab3667918671e077f3c7f9a1 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sat, 19 Nov 2011 17:10:16 -0600 Subject: [PATCH] FS-3706 see if this helps, otherwise can you test it on other platforms? --- src/mod/applications/mod_commands/mod_commands.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index d01adc658a..1f4984aa19 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -45,6 +45,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_commands_shutdown); SWITCH_MODULE_DEFINITION(mod_commands, mod_commands_load, mod_commands_shutdown, NULL); +static switch_mutex_t *reload_mutex = NULL; struct cb_helper { uint32_t row_process; @@ -2004,6 +2005,8 @@ SWITCH_STANDARD_API(load_function) return SWITCH_STATUS_SUCCESS; } + switch_mutex_lock(reload_mutex); + if (switch_xml_reload(&err) == SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "+OK Reloading XML\n"); } @@ -2014,6 +2017,8 @@ SWITCH_STANDARD_API(load_function) stream->write_function(stream, "-ERR [%s]\n", err); } + switch_mutex_unlock(reload_mutex); + return SWITCH_STATUS_SUCCESS; } @@ -2053,12 +2058,16 @@ SWITCH_STANDARD_API(unload_function) return SWITCH_STATUS_SUCCESS; } + switch_mutex_lock(reload_mutex); + if (switch_loadable_module_unload_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) cmd, force, &err) == SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "+OK\n"); } else { stream->write_function(stream, "-ERR [%s]\n", err); } + switch_mutex_unlock(reload_mutex); + return SWITCH_STATUS_SUCCESS; } @@ -2096,6 +2105,8 @@ SWITCH_STANDARD_API(reload_function) return SWITCH_STATUS_SUCCESS; } + switch_mutex_lock(reload_mutex); + if (switch_loadable_module_unload_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) cmd, force, &err) == SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "+OK module unloaded\n"); } else { @@ -2112,6 +2123,8 @@ SWITCH_STANDARD_API(reload_function) stream->write_function(stream, "-ERR loading module [%s]\n", err); } + switch_mutex_unlock(reload_mutex); + return SWITCH_STATUS_SUCCESS; } @@ -5238,6 +5251,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) *module_interface = switch_loadable_module_create_module_interface(pool, modname); switch_thread_rwlock_create(&bgapi_rwlock, pool); + switch_mutex_init(&reload_mutex, SWITCH_MUTEX_NESTED, pool); + SWITCH_ADD_API(commands_api_interface, "acl", "compare an ip to an acl list", acl_function, " "); SWITCH_ADD_API(commands_api_interface, "alias", "Alias", alias_function, ALIAS_SYNTAX);