diff --git a/channels/chan_h323.c b/channels/chan_h323.c index 6da113ddba76ece1ca95cdd4255fd4ac1cb5f9d6..a1dd3723a3573f610b1e5d64c67f639c16927e91 100644 --- a/channels/chan_h323.c +++ b/channels/chan_h323.c @@ -2831,6 +2831,12 @@ static int reload_config(int is_reload) ucfg = ast_config_load("users.conf", config_flags); } + if (is_reload) { + delete_users(); + delete_aliases(); + prune_peers(); + } + /* fire up the H.323 Endpoint */ if (!h323_end_point_exist()) { h323_end_point_create(); @@ -3085,9 +3091,6 @@ static int h323_reload(int fd, int argc, char *argv[]) static int h323_do_reload(void) { - delete_users(); - delete_aliases(); - prune_peers(); reload_config(1); return 0; } diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 3822b277a481ba743afed212af066a7cef189bf7..08352a6e57a7ac16008e481583ab8beea67b215c 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -9898,6 +9898,22 @@ static void set_timing(void) #endif } +static void set_config_destroy(void) +{ + strcpy(accountcode, ""); + strcpy(language, ""); + strcpy(mohinterpret, "default"); + strcpy(mohsuggest, ""); + global_max_trunk_mtu = MAX_TRUNK_MTU; + trunkmaxsize = MAX_TRUNKDATA; + amaflags = 0; + delayreject = 0; + ast_clear_flag((&globalflags), IAX_NOTRANSFER); + ast_clear_flag((&globalflags), IAX_TRANSFERMEDIA); + ast_clear_flag((&globalflags), IAX_USEJITTERBUF); + ast_clear_flag((&globalflags), IAX_FORCEJITTERBUF); + delete_users(); +} /*! \brief Load configuration */ static int set_config(char *config_file, int reload) @@ -9928,7 +9944,7 @@ static int set_config(char *config_file, int reload) } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { ucfg = ast_config_load("users.conf", config_flags); if (ucfg == CONFIG_STATUS_FILEUNCHANGED) - return 0; + return 1; /* Otherwise we need to reread both files */ ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); cfg = ast_config_load(config_file, config_flags); @@ -9937,6 +9953,10 @@ static int set_config(char *config_file, int reload) ucfg = ast_config_load("users.conf", config_flags); } + if (reload) { + set_config_destroy(); + } + /* Reset global codec prefs */ memset(&prefs, 0 , sizeof(struct ast_codec_pref)); @@ -10295,35 +10315,23 @@ static int reload_config(void) struct iax2_registry *reg; struct iax2_peer *peer; - strcpy(accountcode, ""); - strcpy(language, ""); - strcpy(mohinterpret, "default"); - strcpy(mohsuggest, ""); - global_max_trunk_mtu = MAX_TRUNK_MTU; - trunkmaxsize = MAX_TRUNKDATA; - amaflags = 0; - delayreject = 0; - ast_clear_flag((&globalflags), IAX_NOTRANSFER); - ast_clear_flag((&globalflags), IAX_TRANSFERMEDIA); - ast_clear_flag((&globalflags), IAX_USEJITTERBUF); - ast_clear_flag((&globalflags), IAX_FORCEJITTERBUF); - delete_users(); - set_config(config, 1); - prune_peers(); - prune_users(); - trunk_timed = trunk_untimed = 0; - trunk_nmaxmtu = trunk_maxmtu = 0; + if (set_config(config, 1) == 1) { + prune_peers(); + prune_users(); + trunk_timed = trunk_untimed = 0; + trunk_nmaxmtu = trunk_maxmtu = 0; - AST_LIST_LOCK(®istrations); - AST_LIST_TRAVERSE(®istrations, reg, entry) - iax2_do_register(reg); - AST_LIST_UNLOCK(®istrations); + AST_LIST_LOCK(®istrations); + AST_LIST_TRAVERSE(®istrations, reg, entry) + iax2_do_register(reg); + AST_LIST_UNLOCK(®istrations); - /* Qualify hosts, too */ - AST_LIST_LOCK(&peers); - AST_LIST_TRAVERSE(&peers, peer, entry) - iax2_poke_peer(peer, 0); - AST_LIST_UNLOCK(&peers); + /* Qualify hosts, too */ + AST_LIST_LOCK(&peers); + AST_LIST_TRAVERSE(&peers, peer, entry) + iax2_poke_peer(peer, 0); + AST_LIST_UNLOCK(&peers); + } reload_firmware(); iax_provision_reload(1); diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 7a95c1d76579ab108b4e207b613268007dd86386..0784fe90f0c3edbd5d2e7c19d409933ed168cac1 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -17626,7 +17626,7 @@ static int reload_config(enum channelreloadreason reason) char *cat, *stringp, *context, *oldregcontext; char newcontexts[AST_MAX_CONTEXT], oldcontexts[AST_MAX_CONTEXT]; struct ast_flags dummy[2]; - struct ast_flags config_flags = { CONFIG_FLAG_FILEUNCHANGED }; + struct ast_flags config_flags = { reason == CHANNEL_MODULE_LOAD ? 0 : CONFIG_FLAG_FILEUNCHANGED }; int auto_sip_domains = FALSE; struct sockaddr_in old_bindaddr = bindaddr; int registry_count = 0, peer_count = 0, user_count = 0; @@ -17640,7 +17640,7 @@ static int reload_config(enum channelreloadreason reason) } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { ucfg = ast_config_load("users.conf", config_flags); if (ucfg == CONFIG_STATUS_FILEUNCHANGED) - return 0; + return 1; /* Must reread both files, because one changed */ ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); cfg = ast_config_load(config, config_flags); @@ -17648,7 +17648,35 @@ static int reload_config(enum channelreloadreason reason) ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); ucfg = ast_config_load("users.conf", config_flags); } - + + if (reason != CHANNEL_MODULE_LOAD) { + ast_debug(4, "--------------- SIP reload started\n"); + + clear_realm_authentication(authl); + clear_sip_domains(); + authl = NULL; + + /* First, destroy all outstanding registry calls */ + /* This is needed, since otherwise active registry entries will not be destroyed */ + ASTOBJ_CONTAINER_TRAVERSE(®l, 1, do { + ASTOBJ_RDLOCK(iterator); + if (iterator->call) { + ast_debug(3, "Destroying active SIP dialog for registry %s@%s\n", iterator->username, iterator->hostname); + /* This will also remove references to the registry */ + iterator->call = sip_destroy(iterator->call); + } + ASTOBJ_UNLOCK(iterator); + + } while(0)); + + /* Then, actually destroy users and registry */ + ASTOBJ_CONTAINER_DESTROYALL(&userl, sip_destroy_user); + ast_debug(4, "--------------- Done destroying user list\n"); + ASTOBJ_CONTAINER_DESTROYALL(®l, sip_registry_destroy); + ast_debug(4, "--------------- Done destroying registry list\n"); + ASTOBJ_CONTAINER_MARKALL(&peerl); + } + /* Initialize copy of current global_regcontext for later use in removing stale contexts */ ast_copy_string(oldcontexts, global_regcontext, sizeof(oldcontexts)); oldregcontext = oldcontexts; @@ -18690,31 +18718,6 @@ static void sip_send_all_registers(void) /*! \brief Reload module */ static int sip_do_reload(enum channelreloadreason reason) { - ast_debug(4, "--------------- SIP reload started\n"); - - clear_realm_authentication(authl); - clear_sip_domains(); - authl = NULL; - - /* First, destroy all outstanding registry calls */ - /* This is needed, since otherwise active registry entries will not be destroyed */ - ASTOBJ_CONTAINER_TRAVERSE(®l, 1, do { - ASTOBJ_RDLOCK(iterator); - if (iterator->call) { - ast_debug(3, "Destroying active SIP dialog for registry %s@%s\n", iterator->username, iterator->hostname); - /* This will also remove references to the registry */ - iterator->call = sip_destroy(iterator->call); - } - ASTOBJ_UNLOCK(iterator); - - } while(0)); - - /* Then, actually destroy users and registry */ - ASTOBJ_CONTAINER_DESTROYALL(&userl, sip_destroy_user); - ast_debug(4, "--------------- Done destroying user list\n"); - ASTOBJ_CONTAINER_DESTROYALL(®l, sip_registry_destroy); - ast_debug(4, "--------------- Done destroying registry list\n"); - ASTOBJ_CONTAINER_MARKALL(&peerl); reload_config(reason); /* Prune peers who still are supposed to be deleted */ diff --git a/channels/chan_zap.c b/channels/chan_zap.c index 60d9e2e9d4a4d086923913a223a6d5c914564a39..2bb905c603ce7296e9c1263ef835d0ccfcf984b1 100644 --- a/channels/chan_zap.c +++ b/channels/chan_zap.c @@ -10712,7 +10712,7 @@ static int zap_restart(void) destroy_channel(NULL, iflist, 1); } ast_debug(1, "Channels destroyed. Now re-reading config.\n"); - if (setup_zap(1) != 0) { + if (setup_zap(2) != 0) { ast_log(LOG_WARNING, "Reload channels from zap config failed!\n"); return 1; } @@ -12629,7 +12629,7 @@ static int setup_zap(int reload) struct ast_variable *v; struct zt_chan_conf base_conf = zt_chan_conf_default(); struct zt_chan_conf conf; - struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; + struct ast_flags config_flags = { reload == 1 ? CONFIG_FLAG_FILEUNCHANGED : 0 }; int res; #ifdef HAVE_PRI