diff -r feb2f1e115c6 -r c858850f3d3a src/server/daemon/configmanager.c --- a/src/server/daemon/configmanager.c Mon May 06 14:54:40 2013 +0200 +++ b/src/server/daemon/configmanager.c Thu May 09 13:19:51 2013 +0200 @@ -94,6 +94,32 @@ return vs; } +int cfgmgr_reload_file(ConfigFile *f, ServerConfiguration *conf, int *reload) { + struct stat s; + if(stat(f->file.ptr, &s) != 0) { + fprintf( + stderr, + "Error: Cannot get stat of file %s\n", f->file.ptr); + perror("cfgmgr_load_config: stat"); + return -1; + } + + //printf("1 time: %d - %d\n", f->last_modified, s.st_mtim.tv_sec); + if(f->last_modified != s.st_mtim.tv_sec) { + /* reload the file */ + printf("reload: %s\n", f->file.ptr); + log_ereport( + LOG_INFORM, + "reload configuration file: %s", + f->file.ptr); + f->reload(f, conf); + f->last_modified = s.st_mtim.tv_sec; + if(reload) { + *reload = 1; + } + } + return 0; +} int cfgmgr_load_config() { int cfgreload = 0; @@ -102,25 +128,9 @@ UcxMapIterator iter = ucx_map_iterator(config_files); ConfigFile *f; UCX_MAP_FOREACH(f, iter) { - struct stat s; - if(stat(f->file.ptr, &s) != 0) { - fprintf( - stderr, - "Error: Cannot get stat of file %s\n", f->file.ptr); - perror("cfgmgr_load_config: stat"); + if(cfgmgr_reload_file(f, current_config, &cfgreload) == -1) { return -1; } - - if(f->last_modified != s.st_mtim.tv_sec) { - /* reload the file */ - //printf("reload: %s\n", sstrdup(f->file).ptr); - log_ereport( - LOG_INFORM, - "reload configuration file: %s", - f->file.ptr); - f->reload(f, current_config); - cfgreload = 1; - } } struct stat s; @@ -181,13 +191,20 @@ printf("no reconfig required!\n"); config = current_config; } - + ServerConfiguration *old_conf = NULL; + if(current_config != config) { + old_conf = current_config; + } current_config = config; + if(old_conf) { + cfg_unref(old_conf); + } return 0; } ServerConfiguration *cfgmgr_get_server_config() { + //cfg_ref(current_config); return current_config; }