diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-08-16 21:09:46 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-08-16 21:09:46 +0000 |
commit | dbec3d56c146801fad339a1d46a388865b18ffb4 (patch) | |
tree | 8fda811f62cb6ffb99847befb7b74b1519ea95ba /channels | |
parent | 0fb9c73a989207650aa3ba603824e4593809611b (diff) |
Don't reload a configuration file if nothing has changed.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@79747 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_agent.c | 19 | ||||
-rw-r--r-- | channels/chan_alsa.c | 3 | ||||
-rw-r--r-- | channels/chan_gtalk.c | 3 | ||||
-rw-r--r-- | channels/chan_h323.c | 14 | ||||
-rw-r--r-- | channels/chan_iax2.c | 20 | ||||
-rw-r--r-- | channels/chan_jingle.c | 3 | ||||
-rw-r--r-- | channels/chan_mgcp.c | 22 | ||||
-rw-r--r-- | channels/chan_misdn.c | 2 | ||||
-rw-r--r-- | channels/chan_oss.c | 3 | ||||
-rw-r--r-- | channels/chan_phone.c | 4 | ||||
-rw-r--r-- | channels/chan_sip.c | 16 | ||||
-rw-r--r-- | channels/chan_skinny.c | 3 | ||||
-rw-r--r-- | channels/chan_vpb.cc | 28 | ||||
-rw-r--r-- | channels/chan_zap.c | 31 | ||||
-rw-r--r-- | channels/iax2-provision.c | 11 | ||||
-rw-r--r-- | channels/iax2-provision.h | 2 | ||||
-rw-r--r-- | channels/misdn/chan_misdn_config.h | 2 | ||||
-rw-r--r-- | channels/misdn_config.c | 10 |
18 files changed, 113 insertions, 83 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c index 880501ac9..c4e0ecb61 100644 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -976,7 +976,7 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state) * * \returns Always 0, or so it seems. */ -static int read_agent_config(void) +static int read_agent_config(int reload) { struct ast_config *cfg; struct ast_config *ucfg; @@ -986,17 +986,19 @@ static int read_agent_config(void) const char *catname; const char *hasagent; int genhasagent; + struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; group = 0; autologoff = 0; wrapuptime = 0; ackcall = 0; endcall = 1; - cfg = ast_config_load(config); + cfg = ast_config_load(config, config_flags); if (!cfg) { ast_log(LOG_NOTICE, "No agent configuration found -- agent support disabled\n"); return 0; - } + } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) + return -1; AST_LIST_LOCK(&agents); AST_LIST_TRAVERSE(&agents, p, list) { p->dead = 1; @@ -1081,7 +1083,7 @@ static int read_agent_config(void) } v = v->next; } - if ((ucfg = ast_config_load("users.conf"))) { + if ((ucfg = ast_config_load("users.conf", config_flags)) && ucfg != CONFIG_STATUS_FILEUNCHANGED) { genhasagent = ast_true(ast_variable_retrieve(ucfg, "general", "hasagent")); catname = ast_category_browse(ucfg, NULL); while(catname) { @@ -2276,7 +2278,7 @@ static int load_module(void) return -1; } /* Read in the config */ - if (!read_agent_config()) + if (!read_agent_config(0)) return AST_MODULE_LOAD_DECLINE; if (persistent_agents) reload_agents(); @@ -2299,9 +2301,10 @@ static int load_module(void) static int reload(void) { - read_agent_config(); - if (persistent_agents) - reload_agents(); + if (!read_agent_config(1)) { + if (persistent_agents) + reload_agents(); + } return 0; } diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c index a2a10e85f..f043cbde3 100644 --- a/channels/chan_alsa.c +++ b/channels/chan_alsa.c @@ -1082,13 +1082,14 @@ static int load_module(void) { struct ast_config *cfg; struct ast_variable *v; + struct ast_flags config_flags = { 0 }; /* Copy the default jb config over global_jbconf */ memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf)); strcpy(mohinterpret, "default"); - if (!(cfg = ast_config_load(config))) + if (!(cfg = ast_config_load(config, config_flags))) return AST_MODULE_LOAD_DECLINE; v = ast_variable_browse(cfg, "general"); diff --git a/channels/chan_gtalk.c b/channels/chan_gtalk.c index b4306fefe..22d8a29b6 100644 --- a/channels/chan_gtalk.c +++ b/channels/chan_gtalk.c @@ -1702,8 +1702,9 @@ static int gtalk_load_config(void) struct gtalk_candidate *global_candidates = NULL; struct hostent *hp; struct ast_hostent ahp; + struct ast_flags config_flags = { 0 }; - cfg = ast_config_load(GOOGLE_CONFIG); + cfg = ast_config_load(GOOGLE_CONFIG, config_flags); if (!cfg) return 0; diff --git a/channels/chan_h323.c b/channels/chan_h323.c index 36f42e878..6da113ddb 100644 --- a/channels/chan_h323.c +++ b/channels/chan_h323.c @@ -2812,13 +2812,23 @@ static int reload_config(int is_reload) int is_user, is_peer, is_alias; char _gatekeeper[100]; int gk_discover, gk_disable, gk_changed; + struct ast_flags config_flags = { is_reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; - cfg = ast_config_load(config); + cfg = ast_config_load(config, config_flags); /* We *must* have a config file otherwise stop immediately */ if (!cfg) { ast_log(LOG_NOTICE, "Unable to load config %s, H.323 disabled\n", config); return 1; + } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { + ucfg = ast_config_load("users.conf", config_flags); + if (ucfg == CONFIG_STATUS_FILEUNCHANGED) + return 0; + ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); + cfg = ast_config_load(config, config_flags); + } else { + ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); + ucfg = ast_config_load("users.conf", config_flags); } /* fire up the H.323 Endpoint */ @@ -2851,8 +2861,6 @@ static int reload_config(int is_reload) /* Copy the default jb config over global_jbconf */ memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf)); - /* Load configuration from users.conf */ - ucfg = ast_config_load("users.conf"); if (ucfg) { struct ast_variable *gen; int genhas_h323; diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 6f41fdb69..333ccb2fe 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -9776,15 +9776,26 @@ static int set_config(char *config_file, int reload) struct iax2_user *user; struct iax2_peer *peer; struct ast_netsock *ns; + struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; #if 0 static unsigned short int last_port=0; #endif - cfg = ast_config_load(config_file); - + cfg = ast_config_load(config_file, config_flags); + if (!cfg) { ast_log(LOG_ERROR, "Unable to load config %s\n", config_file); return -1; + } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { + ucfg = ast_config_load("users.conf", config_flags); + if (ucfg == CONFIG_STATUS_FILEUNCHANGED) + return 0; + /* Otherwise we need to reread both files */ + ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); + cfg = ast_config_load(config_file, config_flags); + } else { /* iax.conf changed, gotta reread users.conf, too */ + ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); + ucfg = ast_config_load("users.conf", config_flags); } /* Reset global codec prefs */ @@ -10048,7 +10059,6 @@ static int set_config(char *config_file, int reload) } iax2_capability = capability; - ucfg = ast_config_load("users.conf"); if (ucfg) { struct ast_variable *gen; int genhasiax; @@ -10176,7 +10186,7 @@ static int reload_config(void) iax2_poke_peer(peer, 0); AST_LIST_UNLOCK(&peers); reload_firmware(); - iax_provision_reload(); + iax_provision_reload(1); return 0; } @@ -11097,7 +11107,7 @@ static int load_module(void) AST_LIST_UNLOCK(&peers); reload_firmware(); - iax_provision_reload(); + iax_provision_reload(0); return AST_MODULE_LOAD_SUCCESS; } diff --git a/channels/chan_jingle.c b/channels/chan_jingle.c index 8a3321c05..9848b9665 100644 --- a/channels/chan_jingle.c +++ b/channels/chan_jingle.c @@ -1567,8 +1567,9 @@ static int jingle_load_config(void) struct ast_codec_pref prefs; struct aji_client_container *clients; struct jingle_candidate *global_candidates = NULL; + struct ast_flags config_flags = { 0 }; - cfg = ast_config_load(JINGLE_CONFIG); + cfg = ast_config_load(JINGLE_CONFIG, config_flags); if (!cfg) return 0; diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index 64d300faf..c4229e0a1 100644 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -422,8 +422,8 @@ static void start_rtp(struct mgcp_subchannel *sub); static void handle_response(struct mgcp_endpoint *p, struct mgcp_subchannel *sub, int result, unsigned int ident, struct mgcp_request *resp); static void dump_cmd_queues(struct mgcp_endpoint *p, struct mgcp_subchannel *sub); -static int mgcp_do_reload(void); static int mgcp_reload(int fd, int argc, char *argv[]); +static int reload_config(int reload); static struct ast_channel *mgcp_request(const char *type, int format, void *data, int *cause); static int mgcp_call(struct ast_channel *ast, char *dest, int timeout); @@ -3379,7 +3379,7 @@ static void *do_monitor(void *data) ast_mutex_unlock(&mgcp_reload_lock); if (reloading) { ast_verb(1, "Reloading MGCP\n"); - mgcp_do_reload(); + reload_config(1); /* Add an I/O event to our UDP socket */ if (mgcpsock > -1) mgcpsock_read_id = ast_io_add(io, mgcpsock, mgcpsock_read, AST_IO_IN, NULL); @@ -4042,7 +4042,7 @@ static void prune_gateways(void) ast_mutex_unlock(&gatelock); } -static int reload_config(void) +static int reload_config(int reload) { struct ast_config *cfg; struct ast_variable *v; @@ -4052,18 +4052,21 @@ static int reload_config(void) struct ast_hostent ahp; struct hostent *hp; int format; + struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; if (gethostname(ourhost, sizeof(ourhost)-1)) { ast_log(LOG_WARNING, "Unable to get hostname, MGCP disabled\n"); return 0; } - cfg = ast_config_load(config); + cfg = ast_config_load(config, config_flags); /* We *must* have a config file otherwise stop immediately */ if (!cfg) { ast_log(LOG_NOTICE, "Unable to load config %s, MGCP disabled\n", config); return 0; - } + } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) + return 0; + memset(&bindaddr, 0, sizeof(bindaddr)); dtmfmode = 0; @@ -4222,7 +4225,7 @@ static int load_module(void) return AST_MODULE_LOAD_FAILURE; } - if (reload_config()) + if (reload_config(0)) return AST_MODULE_LOAD_DECLINE; /* Make sure we can register our mgcp channel type */ @@ -4242,13 +4245,6 @@ static int load_module(void) return AST_MODULE_LOAD_SUCCESS; } -/*! \brief mgcp_do_reload: Reload module */ -static int mgcp_do_reload(void) -{ - reload_config(); - return 0; -} - static int mgcp_reload(int fd, int argc, char *argv[]) { static int deprecated = 0; diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c index eb19e0326..96c55da8d 100644 --- a/channels/chan_misdn.c +++ b/channels/chan_misdn.c @@ -4753,7 +4753,7 @@ static int load_module(void) return AST_MODULE_LOAD_DECLINE; } - if (misdn_cfg_init(max_ports)) { + if (misdn_cfg_init(max_ports, 0)) { ast_log(LOG_ERROR, "Unable to initialize misdn_config.\n"); return AST_MODULE_LOAD_DECLINE; } diff --git a/channels/chan_oss.c b/channels/chan_oss.c index 6256deb37..42e054609 100644 --- a/channels/chan_oss.c +++ b/channels/chan_oss.c @@ -1577,12 +1577,13 @@ static int load_module(void) { struct ast_config *cfg = NULL; char *ctg = NULL; + struct ast_flags config_flags = { 0 }; /* Copy the default jb config over global_jbconf */ memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf)); /* load config file */ - if (!(cfg = ast_config_load(config))) { + if (!(cfg = ast_config_load(config, config_flags))) { ast_log(LOG_NOTICE, "Unable to load config %s\n", config); return AST_MODULE_LOAD_DECLINE; } diff --git a/channels/chan_phone.c b/channels/chan_phone.c index e99b74ee9..49b9cf77a 100644 --- a/channels/chan_phone.c +++ b/channels/chan_phone.c @@ -1347,7 +1347,9 @@ static int load_module(void) struct phone_pvt *tmp; int mode = MODE_IMMEDIATE; int txgain = DEFAULT_GAIN, rxgain = DEFAULT_GAIN; /* default gain 1.0 */ - cfg = ast_config_load(config); + struct ast_flags config_flags = { 0 }; + + cfg = ast_config_load(config, config_flags); /* We *must* have a config file otherwise stop immediately */ if (!cfg) { diff --git a/channels/chan_sip.c b/channels/chan_sip.c index f096ffa73..4df005db1 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -17629,16 +17629,27 @@ 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 }; int auto_sip_domains = FALSE; struct sockaddr_in old_bindaddr = bindaddr; int registry_count = 0, peer_count = 0, user_count = 0; - cfg = ast_config_load(config); + cfg = ast_config_load(config, config_flags); /* We *must* have a config file otherwise stop immediately */ if (!cfg) { ast_log(LOG_NOTICE, "Unable to load config %s\n", config); return -1; + } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { + ucfg = ast_config_load("users.conf", config_flags); + if (ucfg == CONFIG_STATUS_FILEUNCHANGED) + return 0; + /* Must reread both files, because one changed */ + ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); + cfg = ast_config_load(config, config_flags); + } else { + ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); + ucfg = ast_config_load("users.conf", config_flags); } /* Initialize copy of current global_regcontext for later use in removing stale contexts */ @@ -18007,7 +18018,6 @@ static int reload_config(enum channelreloadreason reason) authl = add_realm_authentication(authl, v->value, v->lineno); } - ucfg = ast_config_load("users.conf"); if (ucfg) { struct ast_variable *gen; int genhassip, genregistersip; @@ -18181,7 +18191,7 @@ static int reload_config(enum channelreloadreason reason) /* Load the list of manual NOTIFY types to support */ if (notify_types) ast_config_destroy(notify_types); - notify_types = ast_config_load(notify_config); + notify_types = ast_config_load(notify_config, config_flags); /* Done, tell the manager */ manager_event(EVENT_FLAG_SYSTEM, "ChannelReload", "ChannelType: SIP\r\nReloadReason: %s\r\nRegistry_Count: %d\r\nPeer_Count: %d\r\nUser_Count: %d\r\n\r\n", channelreloadreason2txt(reason), registry_count, peer_count, user_count); diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index d9629ed2f..f8e22d93e 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -5142,12 +5142,13 @@ static int reload_config(void) int oldport = ntohs(bindaddr.sin_port); char *stringp, *context, *oldregcontext; char newcontexts[AST_MAX_CONTEXT], oldcontexts[AST_MAX_CONTEXT]; + struct ast_flags config_flags = { 0 }; if (gethostname(ourhost, sizeof(ourhost))) { ast_log(LOG_WARNING, "Unable to get hostname, Skinny disabled\n"); return 0; } - cfg = ast_config_load(config); + cfg = ast_config_load(config, config_flags); /* We *must* have a config file otherwise stop immediately */ if (!cfg) { diff --git a/channels/chan_vpb.cc b/channels/chan_vpb.cc index bcc3f6834..852872714 100644 --- a/channels/chan_vpb.cc +++ b/channels/chan_vpb.cc @@ -2636,7 +2636,7 @@ static float parse_gain_value(char *gain_type, char *value) } -int unload_module() +static int unload_module() { struct vpb_pvt *p; /* First, take us out of the channel loop */ @@ -2701,10 +2701,11 @@ int unload_module() return 0; } -int load_module() +static int load_module() { struct ast_config *cfg; struct ast_variable *v; + struct ast_flags config_flags = { 0 }; struct vpb_pvt *tmp; int board = 0, group = 0; ast_group_t callgroup = 0; @@ -2721,7 +2722,7 @@ int load_module() int bal3 = -1; char * callerid = NULL; - cfg = ast_config_load(config); + cfg = ast_config_load(config, config_flags); /* We *must* have a config file otherwise stop immediately */ if (!cfg) { @@ -2897,29 +2898,10 @@ int load_module() return error; } -int usecount() -{ - return usecnt; -} - -const char *description() -{ - return (char *) desc; -} - -const char *key() -{ - return ASTERISK_GPL_KEY; -} - /**/ #if defined(__cplusplus) || defined(c_plusplus) } #endif /**/ -AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "VoiceTronix API driver", - .load = load_module, - .unload = unload_module, - .reload = reload, - ); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "VoiceTronix API driver"); diff --git a/channels/chan_zap.c b/channels/chan_zap.c index 35be3ecdf..d4feae885 100644 --- a/channels/chan_zap.c +++ b/channels/chan_zap.c @@ -12623,27 +12623,37 @@ static int process_zap(struct zt_chan_conf *confp, struct ast_variable *v, int r static int setup_zap(int reload) { - struct ast_config *cfg; + struct ast_config *cfg, *ucfg; struct ast_variable *v; struct zt_chan_conf base_conf = zt_chan_conf_default(); struct zt_chan_conf conf; - int res; + struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; + int res, x; #ifdef HAVE_PRI char *c; int spanno; - int i, x; + int i; int logicalspan; int trunkgroup; int dchannels[NUM_DCHANS]; #endif - cfg = ast_config_load(config); + cfg = ast_config_load(config, config_flags); /* Error if we have no config file */ if (!cfg) { ast_log(LOG_ERROR, "Unable to load config %s\n", config); return 0; + } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { + ucfg = ast_config_load("users.conf", config_flags); + if (ucfg == CONFIG_STATUS_FILEUNCHANGED) + return 0; + ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); + cfg = ast_config_load(config, config_flags); + } else { + ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); + ucfg = ast_config_load("users.conf", config_flags); } /* It's a little silly to lock it, but we mind as well just to be sure */ @@ -12718,25 +12728,24 @@ static int setup_zap(int reload) ast_config_destroy(cfg); if (res) return res; - cfg = ast_config_load("users.conf"); - if (cfg) { + if (ucfg) { char *cat; const char *chans; process_zap(&base_conf, ast_variable_browse(cfg, "general"), 1, 1); - for (cat = ast_category_browse(cfg, NULL); cat ; cat = ast_category_browse(cfg, cat)) { + for (cat = ast_category_browse(ucfg, NULL); cat ; cat = ast_category_browse(ucfg, cat)) { if (!strcasecmp(cat, "general")) continue; - chans = ast_variable_retrieve(cfg, cat, "zapchan"); + chans = ast_variable_retrieve(ucfg, cat, "zapchan"); if (!ast_strlen_zero(chans)) { if (memcpy(&conf, &base_conf, sizeof(conf)) == NULL) { ast_log(LOG_ERROR, "Not enough memory for conf copy\n"); - ast_config_destroy(cfg); + ast_config_destroy(ucfg); return -1; } - process_zap(&conf, ast_variable_browse(cfg, cat), reload, 0); + process_zap(&conf, ast_variable_browse(ucfg, cat), reload, 0); } } - ast_config_destroy(cfg); + ast_config_destroy(ucfg); } #ifdef HAVE_PRI if (!reload) { diff --git a/channels/iax2-provision.c b/channels/iax2-provision.c index dd3419a9e..031897fc7 100644 --- a/channels/iax2-provision.c +++ b/channels/iax2-provision.c @@ -485,12 +485,13 @@ int iax_provision_unload(void) return 0; } -int iax_provision_reload(void) +int iax_provision_reload(int reload) { struct ast_config *cfg; struct iax_template *cur, *prev, *next; char *cat; int found = 0; + struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; if (!provinit) iax_provision_init(); /* Mark all as dead. No need for locking */ @@ -499,8 +500,8 @@ int iax_provision_reload(void) cur->dead = 1; cur = cur->next; } - cfg = ast_config_load("iaxprov.conf"); - if (cfg) { + cfg = ast_config_load("iaxprov.conf", config_flags); + if (cfg != NULL && cfg != CONFIG_STATUS_FILEUNCHANGED) { /* Load as appropriate */ cat = ast_category_browse(cfg, NULL); while(cat) { @@ -512,7 +513,9 @@ int iax_provision_reload(void) cat = ast_category_browse(cfg, cat); } ast_config_destroy(cfg); - } else + } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) + return 0; + else ast_log(LOG_NOTICE, "No IAX provisioning configuration found, IAX provisioning disabled.\n"); ast_mutex_lock(&provlock); /* Drop dead entries while locked */ diff --git a/channels/iax2-provision.h b/channels/iax2-provision.h index d95150253..b1dfd06d0 100644 --- a/channels/iax2-provision.h +++ b/channels/iax2-provision.h @@ -46,7 +46,7 @@ #define PROV_FLAG_DIS_THREEWAY (1 << 7) /* Three-way calling, transfer disabled */ char *iax_provflags2str(char *buf, int buflen, unsigned int flags); -int iax_provision_reload(void); +int iax_provision_reload(int reload); int iax_provision_unload(void); int iax_provision_build(struct iax_ie_data *provdata, unsigned int *signature, const char *template, int force); int iax_provision_version(unsigned int *signature, const char *template, int force); diff --git a/channels/misdn/chan_misdn_config.h b/channels/misdn/chan_misdn_config.h index 2708da4d3..87481deb3 100644 --- a/channels/misdn/chan_misdn_config.h +++ b/channels/misdn/chan_misdn_config.h @@ -108,7 +108,7 @@ enum misdn_cfg_method { }; /* you must call misdn_cfg_init before any other function of this header file */ -int misdn_cfg_init(int max_ports); +int misdn_cfg_init(int max_ports, int reload); void misdn_cfg_reload(void); void misdn_cfg_destroy(void); diff --git a/channels/misdn_config.c b/channels/misdn_config.c index bdd14370c..008f0f6e4 100644 --- a/channels/misdn_config.c +++ b/channels/misdn_config.c @@ -1063,7 +1063,7 @@ static void _fill_defaults (void) void misdn_cfg_reload (void) { - misdn_cfg_init (0); + misdn_cfg_init(0, 1); } void misdn_cfg_destroy (void) @@ -1082,18 +1082,20 @@ void misdn_cfg_destroy (void) ast_mutex_destroy(&config_mutex); } -int misdn_cfg_init (int this_max_ports) +int misdn_cfg_init(int this_max_ports, int reload) { char config[] = "misdn.conf"; char *cat, *p; int i; struct ast_config *cfg; struct ast_variable *v; + struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; - if (!(cfg = AST_LOAD_CFG(config))) { + if (!(cfg = AST_LOAD_CFG(config, config_flags))) { ast_log(LOG_WARNING, "missing file: misdn.conf\n"); return -1; - } + } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) + return 0; ast_mutex_init(&config_mutex); |