@@ -47,9 +47,10 @@ namespace
4747DbgCtl dbg_ctl{" filemanager" };
4848
4949swoc::Errata
50- handle_file_reload (std::string const &fileName, std::string const &configName)
50+ process_config_update (std::string const &fileName, std::string const &configName)
5151{
52- Dbg (dbg_ctl, " handling reload %s - %s" , fileName.c_str (), configName.c_str ());
52+ Dbg (dbg_ctl, " Config update requested for '%s'. [%s]" , fileName.empty () ? " Unknown" : fileName.c_str (),
53+ configName.empty () ? " No config record associated" : configName.c_str ());
5354 swoc::Errata ret;
5455 // TODO: make sure records holds the name after change, if not we should change it.
5556 if (fileName == ts::filename::RECORDS) {
@@ -58,13 +59,12 @@ handle_file_reload(std::string const &fileName, std::string const &configName)
5859 } else {
5960 ret.note (" Error reading {}" , fileName).note (zret);
6061 }
61- } else {
62- RecT rec_type;
63- char *data = const_cast <char *>(configName.c_str ());
64- if (RecGetRecordType (data, &rec_type) == REC_ERR_OKAY && rec_type == RECT_CONFIG) {
65- RecSetSyncRequired (data);
62+ } else if (!configName.empty ()) { // Could be the case we have a child file to reload with no related config record.
63+ RecT rec_type;
64+ if (auto r = RecGetRecordType (configName.c_str (), &rec_type); r == REC_ERR_OKAY && rec_type == RECT_CONFIG) {
65+ RecSetSyncRequired (configName.c_str ());
6666 } else {
67- ret. note ( " Unknown file change {}. " , configName);
67+ Dbg (dbg_ctl, " Couldn't set RecSetSyncRequired for %s - RecGetRecordType ret = %d " , configName. c_str (), r );
6868 }
6969 }
7070
@@ -85,7 +85,7 @@ const std::string NA_STR{"N/A"};
8585FileManager::FileManager ()
8686{
8787 ink_mutex_init (&accessLock);
88- this ->registerCallback (&handle_file_reload );
88+ this ->registerCallback (&process_config_update );
8989
9090 // Register the files registry jsonrpc endpoint
9191 rpc::add_method_handler (" filemanager.get_files_registry" ,
@@ -137,38 +137,15 @@ FileManager::addFileHelper(const char *fileName, const char *configName, bool ro
137137 bindings.emplace (configManager->getFileName (), std::move (configManager));
138138}
139139
140- // bool FileManager::getConfigManagerObj(char* fileName, ConfigManager** rbPtr)
141- //
142- // Sets rbPtr to the ConfigManager object associated
143- // with the passed in fileName.
144- //
145- // If there is no binding, false is returned
146- //
147- bool
148- FileManager::getConfigObj (const char *fileName, ConfigManager **rbPtr)
149- {
150- ink_mutex_acquire (&accessLock);
151- auto it = bindings.find (fileName);
152- bool found = it != bindings.end ();
153- ink_mutex_release (&accessLock);
154-
155- *rbPtr = found ? it->second .get () : nullptr ;
156- return found;
157- }
158-
159140swoc::Errata
160141FileManager::fileChanged (std::string const &fileName, std::string const &configName)
161142{
162- Dbg (dbg_ctl, " file changed %s" , fileName.c_str ());
163143 swoc::Errata ret;
164144
165145 std::lock_guard<std::mutex> guard (_callbacksMutex);
166146 for (auto const &call : _configCallbacks) {
167147 if (auto const &r = call (fileName, configName); !r) {
168- Dbg (dbg_ctl, " something back from callback %s" , fileName.c_str ());
169- if (ret.empty ()) {
170- ret.note (" Errors while reloading configurations." );
171- }
148+ Dbg (dbg_ctl, " Something came back from the callback associated with %s" , fileName.c_str ());
172149 ret.note (r);
173150 }
174151 }
@@ -218,10 +195,7 @@ FileManager::rereadConfig()
218195 // happen at all...
219196 if (rb->checkForUserUpdate (FileManager::ROLLBACK_CHECK_AND_UPDATE)) {
220197 Dbg (dbg_ctl, " File %s changed." , it.first .c_str ());
221- auto const &r = fileChanged (rb->getFileName (), rb->getConfigName ());
222-
223- if (!r) {
224- ret.note (" Errors while reloading configurations." );
198+ if (auto const &r = fileChanged (rb->getFileName (), rb->getConfigName ()); !r) {
225199 ret.note (r);
226200 }
227201
@@ -261,9 +235,6 @@ FileManager::rereadConfig()
261235 for (size_t i = 0 ; i < n; i++) {
262236 if (std::find (changedFiles.begin (), changedFiles.end (), parentFileNeedChange[i]) == changedFiles.end ()) {
263237 if (auto const &r = fileChanged (parentFileNeedChange[i]->getFileName (), parentFileNeedChange[i]->getConfigName ()); !r) {
264- if (ret.empty ()) {
265- ret.note (" Error while handling parent file name changed." );
266- }
267238 ret.note (r);
268239 }
269240 }
@@ -276,18 +247,12 @@ FileManager::rereadConfig()
276247 if (found && enabled.value ()) {
277248 if (auto const &r = fileChanged (" proxy.config.body_factory.template_sets_dir" , " proxy.config.body_factory.template_sets_dir" );
278249 !r) {
279- if (ret.empty ()) {
280- ret.note (" Error while loading body factory templates" );
281- }
282250 ret.note (r);
283251 }
284252 }
285253
286254 if (auto const &r = fileChanged (" proxy.config.ssl.server.ticket_key.filename" , " proxy.config.ssl.server.ticket_key.filename" );
287255 !r) {
288- if (ret.empty ()) {
289- ret.note (" Error while loading ticket keys" );
290- }
291256 ret.note (r);
292257 }
293258
@@ -429,7 +394,6 @@ FileManager::ConfigManager::checkForUserUpdate(FileManager::RollBackCheckType ho
429394 fileLastModified = TS_ARCHIVE_STAT_MTIME (fileInfo);
430395 // TODO: syslog????
431396 }
432- Dbg (dbg_ctl, " User has changed config file %s\n " , fileName.c_str ());
433397 result = true ;
434398 } else {
435399 result = false ;
0 commit comments