53 return ucx_map_sstr_get(config_files, name); |
53 return ucx_map_sstr_get(config_files, name); |
54 } |
54 } |
55 |
55 |
56 int cfgmgr_load_config() { |
56 int cfgmgr_load_config() { |
57 int cfgreload = 0; |
57 int cfgreload = 0; |
58 /* check config files */ |
58 |
59 for(int i=0;i<config_files->size;i++) { |
59 /* check config files */ |
60 UcxMapElement *elm = &config_files->map[i]; |
60 UcxMapIterator iter = ucx_map_iterator(config_files); |
61 while(elm != NULL) { |
61 UCX_MAP_FOREACH(ConfigFile*, f, config_files, iter) { |
62 /*check file */ |
62 struct stat s; |
63 ConfigFile *f = elm->data; |
63 if(stat(f->file.ptr, &s) != 0) { |
|
64 fprintf( |
|
65 stderr, |
|
66 "Error: Cannot get stat of file %s\n", f->file.ptr); |
|
67 perror("cfgmgr_load_config: stat"); |
|
68 return -1; |
|
69 } |
64 |
70 |
65 if(f != NULL) { |
71 if(f->last_modified != s.st_mtim.tv_sec) { |
66 struct stat s; |
72 /* reload the file */ |
67 if(stat(f->file.ptr, &s) != 0) { |
73 f->reload(f, current_config); |
68 fprintf( |
74 cfgreload = 1; |
69 stderr, |
|
70 "Error: Cannot get stat of file %s\n", f->file.ptr); |
|
71 perror("cfgmgr_load_config: stat"); |
|
72 return -1; |
|
73 } |
|
74 |
|
75 if(f->last_modified != s.st_mtim.tv_sec) { |
|
76 /* reload the file */ |
|
77 f->reload(f, current_config); |
|
78 cfgreload = 1; |
|
79 } |
|
80 } |
|
81 |
|
82 elm = elm->next; |
|
83 } |
75 } |
84 } |
76 } |
85 |
77 |
86 struct stat s; |
78 struct stat s; |
87 if(stat("conf/server.conf", &s) != 0) { |
79 if(stat("conf/server.conf", &s) != 0) { |